Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the loading of project configuration before cleanup #6117

Merged
merged 3 commits into from Feb 20, 2021
Merged

Fix the loading of project configuration before cleanup #6117

merged 3 commits into from Feb 20, 2021

Conversation

rolandsaven
Copy link
Contributor

I came across an issue with the clean command when multiple applications are set up using the include property in the global codeception.yml.

Content of codeception.yml

include:
  - applications/*/
  - plugins/*/

Before the changes:

# php vendor/bin/codecept clean
Cleaning up output /var/www/html/tests/_output/...
Cleaning up output /var/www/html/tests/_output/...
Cleaning up output /var/www/html/plugins/someRandomPlugin/tests/_output/...

After the changes:

# php vendor/bin/codecept clean
Cleaning up output /var/www/html/tests/_output/...
Cleaning up output /var/www/html/applications/someRandomApplication/tests/_output/...
Cleaning up output /var/www/html/plugins/someRandomPlugin/tests/_output/...

Let me know if that is ok

@Naktibalda
Copy link
Member

We have tests of include functionality in https://github.com/Codeception/Codeception/blob/4.1/tests/cli/IncludedCest.php

Could you add another test method to run clean command and verify the output?

@rolandsaven
Copy link
Contributor Author

hey @Naktibalda, that is fine just submitted it but I wonder what would be your proposal for the failing errors on windows?

It seems like the generated paths on windows are wrong ...\pianist\tests/... - could it be that it's using the string from within the configuration file? Would realpath() help in Configuration::logDir() or somewhere in Configuration::outputDir())?

@Naktibalda
Copy link
Member

Yes, it looks like / is coming from included configuration.

Nothing is broken, I think that it would be safer to fix the test by making it check for / instead of {$ds} in appropriate places.

@rolandsaven
Copy link
Contributor Author

rolandsaven commented Feb 19, 2021

make sense @Naktibalda - fixed

yeah, it's during assign from config where it goes south - here and here

@Naktibalda
Copy link
Member

Thanks, I tested your change and it really solves the problem.

I discovered 2 issues while testing it:

  1. The test deletes .gitkeep files in _output directories, so it is difficult to rerun it and it makes unwanted changes in working copy when testing locally. I will change doEmptyDir method to leave .gitkeep files.
  2. Test passed in 5.0 branch even though it was supposed to fail - test execution stopped on failed assertion but the outcome was PASSED.
IncludedCest: Clean included
Signature: IncludedCest:cleanIncluded
Test: tests/cli/IncludedCest.php:cleanIncluded
Scenario --
  creating dirs
 I am in path "tests/data/included"
  Moved to /.../Codeception/tests/data/included
 I execute command "clean"
  Cleaning up output /.../Codeception/tests/data/included/_log/...
  Cleaning up output /.../Codeception/tests/data/included/_log/...
  Cleaning up output /.../Codeception/tests/data/included/jazz/tests/_log/...
  Cleaning up output /.../Codeception/tests/data/included/jazz/pianist/tests/_log/...
  Done
 I see in shell output "included/_log"
 I see in shell output "included/jazz/tests/_log"
 I see in shell output "included/jazz/pianist/tests/_log"
 I see in shell output "included/shire/tests/_log"
 PASSED
IncludedCest: Clean included
Signature: IncludedCest:cleanIncluded
Test: tests/cli/IncludedCest.php:cleanIncluded
Scenario --
  creating dirs
 I am in path "tests/data/included"
  Moved to /.../Codeception/tests/data/included
 I execute command "clean"
  Cleaning up output /.../Codeception/tests/data/included/_log/...
  Cleaning up output /.../Codeception/tests/data/included/_log/...
  Cleaning up output /.../Codeception/tests/data/included/jazz/tests/_log/...
  Cleaning up output /.../Codeception/tests/data/included/jazz/pianist/tests/_log/...
  Done
 I see in shell output "included/_log"
 I see in shell output "included/foo/tests/_log"
 PASSED

  deleting dirs

@Naktibalda Naktibalda merged commit 532cbb7 into Codeception:4.1 Feb 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants