mirror of
https://github.com/pestphp/pest.git
synced 2026-12-03 22:45:06 +01:00
fix: accept --no-results and the --do-not-* test run history options with --parallel (#1982)
* fix: accept `--no-results` and the `--do-not-*` test run history options with `--parallel` * Update success snapshot count --------- Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com> Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ namespace Pest\Plugins\Parallel\Handlers;
|
||||
|
||||
use Pest\Contracts\Plugins\HandlesArguments;
|
||||
use Pest\Plugins\Concerns\HandleArguments;
|
||||
use Pest\Plugins\Parallel as ParallelPlugin;
|
||||
use Pest\Plugins\Parallel\Paratest\WrapperRunner;
|
||||
|
||||
/**
|
||||
@@ -19,12 +20,24 @@ final class Parallel implements HandlesArguments
|
||||
'--parallel',
|
||||
'-p',
|
||||
'--no-output',
|
||||
'--no-results',
|
||||
'--cache-result',
|
||||
'--do-not-cache-result',
|
||||
'--record-test-run-history',
|
||||
'--do-not-record-test-run-history',
|
||||
];
|
||||
|
||||
private const array ARGS_THAT_DISABLE_TEST_RUN_HISTORY = [
|
||||
'--do-not-cache-result',
|
||||
'--do-not-record-test-run-history',
|
||||
];
|
||||
|
||||
public function handleArguments(array $arguments): array
|
||||
{
|
||||
if (array_any(self::ARGS_THAT_DISABLE_TEST_RUN_HISTORY, fn (string $argument): bool => $this->hasArgument($argument, $arguments))) {
|
||||
ParallelPlugin::setGlobal(WrapperRunner::DO_NOT_RECORD_TEST_RUN_HISTORY, true);
|
||||
}
|
||||
|
||||
$args = array_reduce(self::ARGS_TO_REMOVE, fn (array $args, string $arg): array => $this->popArgument($arg, $args), $arguments);
|
||||
|
||||
return $this->pushArgument('--runner='.WrapperRunner::class, $args);
|
||||
|
||||
@@ -14,6 +14,7 @@ use ParaTest\RunnerInterface;
|
||||
use ParaTest\WrapperRunner\MissingResultsException;
|
||||
use ParaTest\WrapperRunner\SuiteLoader;
|
||||
use ParaTest\WrapperRunner\WrapperWorker;
|
||||
use Pest\Plugins\Parallel;
|
||||
use Pest\Plugins\Tia;
|
||||
use Pest\Result;
|
||||
use Pest\TestSuite;
|
||||
@@ -64,6 +65,8 @@ use function usleep;
|
||||
*/
|
||||
final class WrapperRunner implements RunnerInterface
|
||||
{
|
||||
public const string DO_NOT_RECORD_TEST_RUN_HISTORY = 'DO_NOT_RECORD_TEST_RUN_HISTORY';
|
||||
|
||||
public static ?TestResult $result = null;
|
||||
|
||||
private const int CYCLE_SLEEP = 1000;
|
||||
@@ -472,7 +475,7 @@ final class WrapperRunner implements RunnerInterface
|
||||
|
||||
self::$result = $testResultSum;
|
||||
|
||||
if ($this->options->configuration->recordTestRunHistory()) {
|
||||
if ($this->options->configuration->recordTestRunHistory() && Parallel::getGlobal(self::DO_NOT_RECORD_TEST_RUN_HISTORY) !== true) {
|
||||
$resultCacheSum = new DefaultTestRunHistory($this->options->configuration->testRunHistoryFile());
|
||||
foreach ($this->resultCacheFiles as $resultCacheFile) {
|
||||
$resultCache = new DefaultTestRunHistory($resultCacheFile->getPathname());
|
||||
|
||||
@@ -2269,6 +2269,12 @@
|
||||
✓ parallel lets extensions register event subscribers
|
||||
✓ parallel can have multiple exclude-groups
|
||||
✓ parallel can have multiple groups
|
||||
✓ parallel accepts the options that the workers ignore with ('--no-results')
|
||||
✓ parallel accepts the options that the workers ignore with ('--do-not-cache-result')
|
||||
✓ parallel accepts the options that the workers ignore with ('--do-not-record-test-run-history')
|
||||
✓ parallel records the test run history
|
||||
✓ parallel does not record the test run history when asked not to with ('--do-not-cache-result')
|
||||
✓ parallel does not record the test run history when asked not to with ('--do-not-record-test-run-history')
|
||||
|
||||
PASS Tests\Visual\ParallelNestedDatasets
|
||||
✓ parallel loads nested datasets from nested directories
|
||||
@@ -2302,4 +2308,4 @@
|
||||
✓ pass with dataset with ('my-datas-set-value')
|
||||
✓ within describe → pass with dataset with ('my-datas-set-value')
|
||||
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 37 skipped, 1629 passed (3599 assertions)
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 37 skipped, 1635 passed (3610 assertions)
|
||||
|
||||
@@ -71,3 +71,37 @@ test('parallel can have multiple groups', function () use ($run): void {
|
||||
->toContain('Tests: 2 passed (2 assertions)')
|
||||
->toContain('Parallel: 3 processes');
|
||||
})->skipOnWindows();
|
||||
|
||||
test('parallel accepts the options that the workers ignore', function (string $option) use ($run): void {
|
||||
expect($run('tests/Fixtures/Inheritance', $option))
|
||||
->toContain('Tests: 1 skipped, 1 passed (1 assertions)')
|
||||
->toContain('Parallel: 3 processes');
|
||||
})->with([
|
||||
'--no-results',
|
||||
'--do-not-cache-result',
|
||||
'--do-not-record-test-run-history',
|
||||
])->skipOnWindows();
|
||||
|
||||
test('parallel records the test run history', function () use ($run): void {
|
||||
$cacheDirectory = sys_get_temp_dir().'/pest-parallel-history-'.bin2hex(random_bytes(8));
|
||||
|
||||
$run('tests/Fixtures/Inheritance', '--cache-directory='.$cacheDirectory);
|
||||
|
||||
expect($cacheDirectory.'/test-run-history')->toBeFile();
|
||||
|
||||
unlink($cacheDirectory.'/test-run-history');
|
||||
rmdir($cacheDirectory);
|
||||
})->skipOnWindows();
|
||||
|
||||
test('parallel does not record the test run history when asked not to', function (string $option) use ($run): void {
|
||||
$cacheDirectory = sys_get_temp_dir().'/pest-parallel-history-'.bin2hex(random_bytes(8));
|
||||
|
||||
expect($run('tests/Fixtures/Inheritance', '--cache-directory='.$cacheDirectory, $option))
|
||||
->toContain('Tests: 1 skipped, 1 passed (1 assertions)')
|
||||
->and($cacheDirectory.'/test-run-history')->not->toBeFile();
|
||||
|
||||
rmdir($cacheDirectory);
|
||||
})->with([
|
||||
'--do-not-cache-result',
|
||||
'--do-not-record-test-run-history',
|
||||
])->skipOnWindows();
|
||||
|
||||
Reference in New Issue
Block a user