-
-
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
base: main
Are you sure you want to change the base?
Conversation
bbb8f4e to
c6ec4c0
Compare
086266b to
1773e58
Compare
|
while re-reading your comment, I'm thinking I have misunderstood what you meant by saying:
I've actually duplicated the tests resulting in this output: but I'm wondering if you were meaning that it would result in only one test execution, even if the test is run 10 times: The only "visual" difference with a run without the If this is what you meant, I can fix the PR: I've already got something working with this other approach, just tell me |
ee92b8a to
aab92a5
Compare
|
Thank you for working on this, Nicolas! I won't be able to look at this for the next week or two, but I promise I'll look into it as soon as I can. In the meantime, did you know that I did some work on this about six months ago on the |
nope, I didn't! I'll have a check |
aab92a5 to
8f80b58
Compare
8f80b58 to
32e3acb
Compare
|
after checking your branch, I can see that regarding this comment, I did understood well your intent, and as notable differences, I can see that:
Regarding my implementation, I don't know how we should impact events:
Because of those questions about events, I did not create some functional tests which uses |
e484176 to
49434c0
Compare
If the test method is not declared to not return a value then it may return a value. Values returned by a test method are stored as other tests may depend on them using the |
Yes, to ensure we have a fresh instance for each test execution. I prioritise isolation over speed, so using |
As I mentioned earlier, I don't really have the time to look into this right now. It's a complex topic, and it's been months since I last looked at it closely. However, I see that you are actively working on it and asking questions. I do not want to leave you hanging and will try my best to help you as quickly as I can. I'm afraid that answering quickly might not yield the best answers, so take what I write with a pinch of salt. For now, I don't think we should implement |
That's very nice, thank you, but I can wait 😊 |
49434c0 to
1bd85e8
Compare
1bd85e8 to
a34f966
Compare
| Test Passed (RepeatTest::test2) | ||
| Test Finished (RepeatTest::test2) |
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'm wondering if we should trigger those events once per test, or once per test repeat attempt
currently Passed is triggered once per test, and Finished once per test repeat attempt but I don't think it is satisfying
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.
another solution would be to introduce new events: Repeat Attempt Started / Repeat Attempt Passed / Repeat Attempt Finished
I wont work further on the events until we discuss about them
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.
another solution would be to introduce new events: Repeat Attempt Started / Repeat Attempt Passed / Repeat Attempt Finished
This sounds good to me. I don't have much experience with events though.
Lets wait for Sebastian on this one
| if ($this->repeatAttemptNumber !== 1) { | ||
| $name .= " (repeat attempt #{$this->repeatAttemptNumber})"; | ||
| } |
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
OK I wasn't aware of this behavior!
I guess we have the choice between those solutions:
I think me preference goes to the last proposition. Because all the other solutions sound arbitrary. Moreover, we're facing a really niche problem |
IMO this sounds good. I would additionally emit a PHPUnit warning in such case. |
|
@staabm thanks for your input, that's exactly what I had in mind do you have any thoughts about what to do with events? |
|
@nikophil I have not yet had time to look into this, so I cannot answer your question about the events yet. Please bear with me for a little while longer, hopefully only a little! |
yes no problem, I really didn't wanted to urge you, just wanted to have @staabm opinion |
| if ($this->repeatTimes > 1 && $returnValue !== null) { | ||
| $this->markSkippedForRepeatAndReturningDependency($dependency); | ||
|
|
||
| return false; | ||
| } |
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.
regarding to tests which depends on a test returning a value, I've opted for a very simple solution: if the last retry attempt of the depending test returns something different than null, then we skip the test and emit a PHPUnit warning.
This is a naive approach, but it prevents something much more complex for handling something which is a very niche problem.
Another simple solution would also to skip + trigger warning when $passedTests->hasReturnValue($dependencyTarget) returns true
fixes #5718
Here is an attempt to bring back
--repeatCLI option.The implementation follows what's proposed in #5718 (comment) and #5718 (comment)
if there are two tests
AandB, they run in this order:AABB, whereas in PHPUnit 9 the order wasABABI know that there had been some frictions around this feature, so I'd understand if this PR is refused. Nevertheless, the issue has been quiete for a long time, and many people have responded positively to the proposed solution.
I believe I’ve covered most of the cases, but please let me know if I’ve missed anything.
Regarding the implementation: at first, I wanted to use an
ExecutionOrderDependencyto link repetitions, but that led to much more complex code. I think using a dedicatedRepeatTestSuiteobject for these repetitions is cleaner.