-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Bring back --repeat CLI option
#6397
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
nikophil
wants to merge
21
commits into
sebastianbergmann:main
Choose a base branch
from
nikophil:feat/repeat-option
base: main
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
21 commits
Select commit
Hold shift + click to select a range
bb47770
Add basic phpt test with repeat option
nikophil 6b5f2b2
implement naive simple --repeat functionality
nikophil 6286d21
Repeat tests using RepeatTestSuite
nikophil 3ef7738
Handle dependent tests with --repeat
nikophil ec603b7
Handle data providers with --repeat
nikophil 1f5c46c
Repeat phpt tests
nikophil eb4829f
Handle test suite loaded from path with --repeat
nikophil e079b71
--repeat value should be a positive integer
nikophil 6a9fadd
cs fixer
nikophil c6ec4c0
add @internal tag on markSkippedForErrorInPreviousRepetition
nikophil 638b334
rename $repeat into $repeatTimes
nikophil ab52255
fix tests
nikophil 1773e58
add --repeat to the cli help
nikophil 32e3acb
handle when no cli arguments
nikophil a34f966
add test which uses #[RunTestsInSeparateProcesses]
nikophil 62ea645
Trigger test Passed event only when last repetition passed
nikophil 5cc4fae
Create RepeatTestSuite in TestBuilder
nikophil 20aa69c
Split regular RepeatTestSuite and PhptRepeatTestSuite
nikophil e9ff6a6
Add $repeatAttemptNumber property in test event DTOs
nikophil 539fb97
add repeat test with dependency ordered by random
nikophil ae0c716
Cannot retry if depends on test which returns value
nikophil 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,62 @@ | ||
| <?php declare(strict_types=1); | ||
| /* | ||
| * This file is part of PHPUnit. | ||
| * | ||
| * (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
| namespace PHPUnit\Framework; | ||
|
|
||
| use function count; | ||
| use PHPUnit\Event; | ||
| use PHPUnit\Runner\Phpt\TestCase as PhptTestCase; | ||
|
|
||
| /** | ||
| * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit | ||
| * | ||
| * @internal This class is not covered by the backward compatibility promise for PHPUnit | ||
| * | ||
| * @template T of TestCase|PhptTestCase | ||
| */ | ||
| abstract readonly class AbstractRepeatTestSuite implements Reorderable, Test | ||
| { | ||
| /** | ||
| * @var non-empty-list<T> | ||
| */ | ||
| protected array $tests; | ||
|
|
||
| /** | ||
| * @param non-empty-list<T> $tests | ||
| */ | ||
| public function __construct(array $tests) | ||
| { | ||
| $this->tests = $tests; | ||
| } | ||
|
|
||
| final public function count(): int | ||
| { | ||
| return count($this->tests); | ||
| } | ||
|
|
||
| final public function sortId(): string | ||
| { | ||
| return $this->tests[0]->sortId(); | ||
| } | ||
|
|
||
| final public function provides(): array | ||
| { | ||
| return $this->tests[0]->provides(); | ||
| } | ||
|
|
||
| final public function requires(): array | ||
| { | ||
| return $this->tests[0]->requires(); | ||
| } | ||
|
|
||
| final public function valueObjectForEvents(): Event\Code\Phpt|Event\Code\TestMethod | ||
| { | ||
| return $this->tests[0]->valueObjectForEvents(); | ||
| } | ||
| } |
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,66 @@ | ||
| <?php declare(strict_types=1); | ||
| /* | ||
| * This file is part of PHPUnit. | ||
| * | ||
| * (c) Sebastian Bergmann <sebastian@phpunit.de> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
| namespace PHPUnit\Framework; | ||
|
|
||
| use PHPUnit\Metadata\Api\ProvidedData; | ||
|
|
||
| /** | ||
| * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit | ||
| * | ||
| * @internal This class is not covered by the backward compatibility promise for PHPUnit | ||
| * | ||
| * @extends AbstractRepeatTestSuite<TestCase> | ||
| */ | ||
| final readonly class RepeatTestSuite extends AbstractRepeatTestSuite | ||
| { | ||
| public function run(): void | ||
| { | ||
| $defectOccurred = false; | ||
|
|
||
| foreach ($this->tests as $test) { | ||
| if ($defectOccurred) { | ||
| $test->markSkippedForErrorInPreviousRepetition(); | ||
|
|
||
| continue; | ||
| } | ||
|
|
||
| $test->run(); | ||
|
|
||
| if ($test->status()->isFailure() || $test->status()->isError() || $test->status()->isSkipped()) { | ||
| $defectOccurred = true; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public function name(): string | ||
| { | ||
| return $this->tests[0]::class . '::' . $this->tests[0]->nameWithDataSet(); | ||
| } | ||
|
|
||
| /** | ||
| * @param array<ProvidedData> $data | ||
| */ | ||
| public function setData(int|string $dataName, array $data): void | ||
| { | ||
| foreach ($this->tests as $test) { | ||
| $test->setData($dataName, $data); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @param list<ExecutionOrderDependency> $dependencies | ||
| */ | ||
| public function setDependencies(array $dependencies): void | ||
| { | ||
| foreach ($this->tests as $test) { | ||
| $test->setDependencies($dependencies); | ||
| } | ||
| } | ||
| } |
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.
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.
I tried to not change those names for the first attempt, because I don't know if the change in the name should be considered as a BC break