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

Unset SHELL_VERBOSITY environment variable before execution of command #13

Merged
merged 4 commits into from
Jan 13, 2023

Conversation

Naktibalda
Copy link
Member

While testing Codeception, I noticed that some cli tests fail when Codeception is executed with -v flag.

For example RunSkippedCept:

Codeception$ ./codecept run cli RunSkippedCept
Codeception PHP Testing Framework v5.0.6 https://helpukrainewin.org

Cli Tests (1) -----------------------------------------------------------------------------------------------------------------------
✔ RunSkippedCept: Run skipped test (0.09s)
-------------------------------------------------------------------------------------------------------------------------------------
Time: 00:00.283, Memory: 8.00 MB

OK (1 test, 3 assertions)

Codeception$ ./codecept run cli RunSkippedCept -v
Codeception PHP Testing Framework v5.0.6 https://helpukrainewin.org

Cli Tests (1) -----------------------------------------------------------------------------------------------------------------------
Modules: Filesystem, Cli, CliHelper, CodeHelper, Asserts
-------------------------------------------------------------------------------------------------------------------------------------
✖ RunSkippedCept: Run skipped test (0.09s)
-------------------------------------------------------------------------------------------------------------------------------------
Time: 00:00.286, Memory: 8.00 MB

There was 1 failure:
1) RunSkippedCept: Run skipped test
 Test  tests/cli/RunSkippedCept.php
 Step  See in shell output "run with `-v` to get more info"
 Fail  Failed asserting that 'Codeception PHP Testing Framework v5.0.6 https://helpukrainewin.org\n
\n
Skipped Tests (1) -------------------------------------------------------------------------------------------------------------------\n
Modules: SkipHelper\n
-------------------------------------------------------------------------------------------------------------------------------------\n
S SkipMeCept: Skip it\n
-------------------------------------------------------------------------------------------------------------------------------------\n
Time: 00:00.019, Memory: 6.00 MB\n
\n
There was 1 skipped test:\n
1) SkipMeCept: Skip it\n
 Test  tests/skipped/SkipMeCept.php\n
OK, but incomplete, skipped, or useless tests!\n
Tests: 1, Assertions: 0, Skipped: 1.' contains "run with `-v` to get more info".

Scenario Steps:

 5. $I->seeInShellOutput("run with `-v` to get more info") at tests/cli/RunSkippedCept.php:9
 4. $I->seeInShellOutput("OK, but incomplete, skipped, or useless tests!") at tests/cli/RunSkippedCept.php:8
 3. $I->seeInShellOutput("S SkipMeCept: Skip it") at tests/cli/RunSkippedCept.php:7
 2. $I->executeCommand("run skipped SkipMeCept.php") at tests/cli/RunSkippedCept.php:6
 1. $I->amInPath("tests/data/sandbox") at tests/cli/RunSkippedCept.php:5

During investigation I discovered that \Symfony\Component\Console\Application::configureIO method sets SHELL_VERBOSITY variable which affects verbosity of the child process:
https://github.com/symfony/console/blob/3e294254f2191762c1d137aed4b94e966965e985/Application.php#L958

\Symfony\Component\Console\Tester\ApplicationTester unsets SHELL_VERBOSITY too, so it seems like a good approach to unset it in Cli::runShellCommand.

@Naktibalda Naktibalda merged commit a3a101f into master Jan 13, 2023
@Naktibalda Naktibalda deleted the unset-shell-verbosity branch January 13, 2023 18:41
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

1 participant