-
Notifications
You must be signed in to change notification settings - Fork 41
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
Don't use die() but echo to skip tests. #168
Conversation
To unlock PHPUnit side-effect-free in-process --SKIPIF-- evaluation, we use regular echo instead of die(). That way PHPunit can detect whether conditions may be evaluated in the main-process to reduce sub-process creation overhead. see sebastianbergmann/phpunit#5974
Out of curiousity: how does PHPUnit decide whether the test should be skipped or not ? If that's no longer the case, the criteria for how the test skipping is determined in |
in the current stable PHPUnit release a test is skipped, when the executed code of the this works for e.g. the indicator, when a test will be skipped, does not change with my proposed PR. In the PHPUnit PR I am using staabm/side-effects-detector to inspect the code in the SKIPIF section, tokenize it and look for tokens which produce such side-effects. if we don't find any relevant side-effects we can |
the upstream PHPUnit PR was merged and will be part of the next 11.5.x release |
a similar change was merged today into symfony with symfony/symfony#58680 |
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.
LGTM.
While the performance improvement will only be seen on PHPUnit 11.5, this change doesn't seem to negatively impact runs on older PHPUnit versions, so I see no reason not to merge this.
I also think it would be good to document this feature for PHPT tests, but that's a task for the PHPUnit website (which currently doesn't have any documentation on PHPT tests - see sebastianbergmann/phpunit-documentation-english#302 ).
To unlock PHPUnit side-effect-free in-process
--SKIPIF--
evaluation, we use regularecho
instead ofdie()
.That way PHPunit can detect whether conditions may be evaluated in the main-process to reduce sub-process creation overhead.
Depends on the work-inprogress of sebastianbergmann/phpunit#5974
Running phpunit with the side-effect detecting PR vs. the regular master version, yields the following results in this PR on my windows laptop:
-> inline-skip-if evaluation of 7 test-cases - as proposed with this PR - will yield a 7-8% perf improvement.