Skip to content

Commit 37466e9

Browse files
schlesseraclaude
andcommitted
Build Phars of the bundle one after the other when collecting coverage
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c0ff210 commit 37466e9

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎utils/behat-parallel.php‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ function wp_cli_tests_collect_scenarios( $features_folder, $tags ) {
157157
$filter = '' !== $tags ? new TagFilter( $tags ) : null;
158158
$scenarios = [];
159159

160+
// With code coverage, building a Phar of the bundle itself rewrites its Composer autoloader
161+
// for the duration of the build, which would break the scenarios of the other workers.
162+
$phar_shared = in_array( (string) getenv( 'WP_CLI_TEST_COVERAGE' ), [ 'true', '1' ], true )
163+
&& ! file_exists( 'vendor/wp-cli/wp-cli-bundle/utils/make-phar.php' )
164+
&& file_exists( 'utils/make-phar.php' );
165+
160166
$files = glob( $features_folder . '/*.feature' );
161167
sort( $files );
162168

@@ -188,7 +194,8 @@ function wp_cli_tests_collect_scenarios( $features_folder, $tags ) {
188194
$scenarios[] = [
189195
'path' => $file . ':' . $scenario->getLine(),
190196
'cost' => $cost,
191-
'shared' => (bool) preg_match( WP_CLI_TESTS_SHARED_RESOURCES, $text ),
197+
'shared' => (bool) preg_match( WP_CLI_TESTS_SHARED_RESOURCES, $text )
198+
|| ( $phar_shared && preg_match( '/^a new Phar/m', $text ) ),
192199
];
193200
}
194201
}

0 commit comments

Comments
 (0)