Skip to content

Conversation

@snellingio
Copy link
Collaborator

@snellingio snellingio commented Aug 7, 2025

What:

  • Bug Fix
  • New Feature

Description:

See the 4.x PR #1431

Fixes issue where --colors=never option was being disregarded when using --parallel flag.

Problem:
When running tests with both --parallel and --colors=never options, ANSI color codes were still being output, inconsistent with non-parallel mode behavior.

Root Cause:
The issue occurred in three places:

  1. Worker processes (bin/worker.php): Were hardcoded to use decorated output (true)
  2. Main parallel process (src/Plugins/Parallel.php): Was not passing decoration setting to CleanConsoleOutput
  3. Progress printer (CompactPrinter): Was hardcoded to use decorated output

Solution:

  • Modified worker processes to respect the --colors parameter from command line arguments
  • Updated main parallel process to check --colors option and pass decoration setting to output
  • Added CompactPrinter::create() method to accept decoration parameter and updated ResultPrinter to use it

Testing:

  • Added test case to verify --colors=never works correctly in parallel mode
  • Verified existing functionality still works
  • Manual testing confirms ANSI codes are properly suppressed when --colors=never is used with --parallel
# This should show NO ANSI color codes
vendor/bin/pest --parallel --colors=never

# This should show ANSI color codes (default behavior)  
vendor/bin/pest --parallel --colors=always

Related:

Closes #1258

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.
@snellingio snellingio changed the title fix: respect --colors=never option in parallel mode [3.x] fix: respect --colors=never option in parallel mode Aug 7, 2025
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.
@snellingio snellingio force-pushed the fix/parallel-colors-never branch from 0f14d40 to c2b6f40 Compare August 7, 2025 22:37
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);
Copy link
Collaborator Author

@snellingio snellingio Aug 7, 2025

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);
Copy link
Collaborator Author

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)),
Copy link
Collaborator Author

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',
Copy link
Collaborator Author

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)
Copy link
Collaborator Author

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.

@snellingio
Copy link
Collaborator Author

Closing these out since there isn't much interest in fixing.

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.

[Bug]: --parallel ignores or changes other commandline arguments

1 participant