-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Run tests in parallel by default #22939
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
Open
NickSdot
wants to merge
9
commits into
php:master
Choose a base branch
from
NickSdot:perf/parallel-by-default
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ed3bda4
Run tests in parallel by default
NickSdot 3b1fa27
Reduce parallel test batch size
NickSdot 6fae5ea
review: replaced optional Filter dependency with a regex
NickSdot 9a7cd62
review: switched automatic worker cleanup to --CLEAN--
NickSdot add2ecd
run-tests: used process-specific information files
NickSdot 5e835e5
review: moved `run-test-info-*.php` to `sys_get_temp_dir()``
NickSdot a5d2c22
review: style nit
NickSdot 5a874af
review: style nit
NickSdot 25c1ab5
fix: isolated test fixtures
NickSdot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| --TEST-- | ||
| Automatic worker detection is capped for regular and instrumented runs | ||
| --SKIPIF-- | ||
| <?php | ||
| if (PHP_OS_FAMILY === 'Windows') { | ||
| die('skip requires a POSIX shell'); | ||
| } | ||
| ?> | ||
| --ENV-- | ||
| TEST_PHP_FORK_SERVER=0 | ||
| --FILE-- | ||
| <?php | ||
| $root = __DIR__ . '/automatic_worker_limit_' . getmypid(); | ||
| $bin = $root . '/bin'; | ||
| $tests = $root . '/tests'; | ||
| mkdir($bin, recursive: true); | ||
| mkdir($tests); | ||
|
|
||
| $nproc = $bin . '/nproc'; | ||
| file_put_contents($nproc, "#!/bin/sh\nprintf '64\\n'\n"); | ||
| chmod($nproc, 0755); | ||
|
|
||
| $testFiles = []; | ||
| for ($i = 0; $i < 11; $i++) { | ||
| $testFiles[] = $file = $tests . "/$i.phpt"; | ||
| file_put_contents($file, <<<PHPT | ||
| --TEST-- | ||
| worker cap $i | ||
| --FILE-- | ||
| <?php echo "ok\\n"; ?> | ||
| --EXPECT-- | ||
| ok | ||
| PHPT); | ||
| } | ||
|
|
||
| $environment = [ | ||
| 'PATH' => $bin . PATH_SEPARATOR . getenv('PATH'), | ||
| 'TEST_PHP_EXECUTABLE' => getenv('TEST_PHP_EXECUTABLE'), | ||
| 'TEST_PHP_FORK_SERVER' => '0', | ||
| ]; | ||
| foreach (['TEMP', 'TMPDIR'] as $name) { | ||
| if (($value = getenv($name)) !== false) { | ||
| $environment[$name] = $value; | ||
| } | ||
| } | ||
|
|
||
| $runTests = static function (array $arguments) use ($environment, $testFiles): array { | ||
| $process = proc_open( | ||
| [ | ||
| getenv('TEST_PHP_EXECUTABLE'), | ||
| dirname(__DIR__, 2) . '/run-tests.php', | ||
| '-q', | ||
| '--no-progress', | ||
| ...$arguments, | ||
| ...$testFiles, | ||
| ], | ||
| [ | ||
| 0 => ['pipe', 'r'], | ||
| 1 => ['pipe', 'w'], | ||
| 2 => ['redirect', 1], | ||
| ], | ||
| $pipes, | ||
| null, | ||
| $environment, | ||
| ); | ||
| fclose($pipes[0]); | ||
| $output = stream_get_contents($pipes[1]); | ||
| fclose($pipes[1]); | ||
|
|
||
| return [proc_close($process), $output]; | ||
| }; | ||
|
|
||
| [$exitCode, $output] = $runTests([]); | ||
| var_dump($exitCode); | ||
| var_dump(str_contains($output, 'Spawning 10 workers...')); | ||
| var_dump(str_contains($output, 'Spawning 11 workers...')); | ||
|
|
||
| [$exitCode, $output] = $runTests(['--asan']); | ||
| var_dump($exitCode); | ||
| var_dump(str_contains($output, 'Spawning 2 workers...')); | ||
| var_dump(str_contains($output, 'Spawning 10 workers...')); | ||
|
|
||
| [$exitCode, $output] = $runTests(['--asan', '-j3']); | ||
| var_dump($exitCode); | ||
| var_dump(str_contains($output, 'Spawning 3 workers...')); | ||
| ?> | ||
| --CLEAN-- | ||
| <?php | ||
| foreach (glob(__DIR__ . '/automatic_worker_limit_*') ?: [] as $root) { | ||
| foreach (glob($root . '/tests/*.phpt') ?: [] as $file) { | ||
| unlink($file); | ||
| } | ||
| @unlink($root . '/bin/nproc'); | ||
| @rmdir($root . '/tests'); | ||
| @rmdir($root . '/bin'); | ||
| @rmdir($root); | ||
| } | ||
| ?> | ||
| --EXPECT-- | ||
| int(0) | ||
| bool(true) | ||
| bool(false) | ||
| int(0) | ||
| bool(true) | ||
| bool(false) | ||
| int(0) | ||
| bool(true) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.