-
-
Notifications
You must be signed in to change notification settings - Fork 442
[3.x] fix: respect --colors=never option in parallel mode #1430
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
Conversation
Fixes issue where --colors=never option was being disregarded when using --parallel flag. The problem occurred in three places: 1. Worker processes were hardcoded to use decorated output 2. Main parallel process was not passing decoration setting to CleanConsoleOutput 3. CompactPrinter was hardcoded to use decorated output This change ensures that when --colors=never is specified, all components of the parallel execution pipeline properly disable ANSI color codes.
The snapshot needed to be updated to reflect the addition of our new test 'parallel mode respects --colors=never option' which increases the test count by 1 test and 3 assertions.
The ray() method in src/Expectation.php is legitimate debugging functionality that has existed since 2021 with proper test coverage. Adding it to the allowed dependencies list resolves the failing Arch test.
0f14d40 to
c2b6f40
Compare
Updates snapshot to reflect: - Arch tests now passing (dependencies test allows ray) - New parallel colors test included - Final count: 1145 passed tests (2739 assertions)
|
|
||
| $output = new ConsoleOutput(OutputInterface::VERBOSITY_NORMAL, true); | ||
| $isDecorated = $workerArgv->getParameterOption('--colors', 'always') !== 'never'; | ||
| $output = new ConsoleOutput(OutputInterface::VERBOSITY_NORMAL, $isDecorated); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worker processes were hardcoded to use decorated output (true), causing --colors=never to be ignored in parallel mode. Now respects the --colors parameter from command line arguments.
| $input = new ArgvInput($filteredArguments); | ||
| $isDecorated = $input->getParameterOption('--colors', 'always') !== 'never'; | ||
| $output = new CleanConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, $isDecorated); | ||
| $exitCode = $this->paratestCommand()->run($input, $output); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Main parallel process wasn't passing decoration setting to CleanConsoleOutput. Now checks --colors option and passes the decoration setting.
| new ConsoleOutput(decorated: true), | ||
| new Style(new ConsoleOutput(decorated: true)), | ||
| new ConsoleOutput(decorated: $decorated), | ||
| new Style(new ConsoleOutput(decorated: $decorated)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added create() method to accept decoration parameter. Previously, CompactPrinter was hardcoded to use decorated output, ignoring --colors=never in parallel mode.
| 'dd', | ||
| 'dump', | ||
| 'expect', | ||
| 'ray', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually stumps me a bit -- because everyone else's pipelines pass.
Had to have Claude help me, and they pointed out that the issue seems to be that ray is already used here: https://github.com/pestphp/pest/blob/3.x/src/Expectation.php#L176
| - visual snapshot of help command output | ||
|
|
||
| Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 38 todos, 33 skipped, 1144 passed (2736 assertions) | ||
| Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 38 todos, 33 skipped, 1145 passed (2739 assertions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if I'm supposed to update the snapshot or not.
|
Closing these out since there isn't much interest in fixing. |
What:
Description:
See the 4.x PR #1431
Fixes issue where
--colors=neveroption was being disregarded when using--parallelflag.Problem:
When running tests with both
--paralleland--colors=neveroptions, ANSI color codes were still being output, inconsistent with non-parallel mode behavior.Root Cause:
The issue occurred in three places:
bin/worker.php): Were hardcoded to use decorated output (true)src/Plugins/Parallel.php): Was not passing decoration setting toCleanConsoleOutputCompactPrinter): Was hardcoded to use decorated outputSolution:
--colorsparameter from command line arguments--colorsoption and pass decoration setting to outputCompactPrinter::create()method to accept decoration parameter and updatedResultPrinterto use itTesting:
--colors=neverworks correctly in parallel mode--colors=neveris used with--parallelRelated:
Closes #1258