-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Allow processing of SKIPIF output after a nocache tag #8076
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: PHP-8.1
Are you sure you want to change the base?
Conversation
If we're targeting PHP-8.1 because this is considered a bug in the way |
I'm slightly concerned about this if we actually target PHP-8.1. |
Previously, a nocache tag would result in the entire SKIPIF output being ignored. This allows the remaining SKIPIF output to still be processed by run_test().
This avoids a potential BC break for existing tests that may print "nocache" multiple times.
30a028f
to
3237f95
Compare
$cacheResult = false; | ||
} | ||
|
||
if ($cacheResult) { |
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 slightly concerned about this if we actually target PHP-8.1.
@cmb69: This change should address your previous concern. One or more "nocache" tags will now be consumed exhaustively, which will avoid leaving behind a "nocache" that might otherwise cause the SKIPIF processing in run_test()
to BORK.
This also preserves the a ability to "skip a test and disable caching" by emitting "nocache" at the beginning of SKIPIF output, which I mentioned in the PR OP.
@cmb69: If you have time to review, I'd be curious to know if the most recent update makes this suitable for PHP-8.1 and feasible to merge upwards ahead of the 8.2.0 release (easier to rely on it that way instead of an arbitrary 8.1.x patch). |
Previously, a nocache tag would result in the entire SKIPIF output being ignored. This allows the remaining SKIPIF output to still be processed by run_test(). This also changes the "nocache" check to use
strncasecmp
instead ofstrpos
, which is consistent with how other SKIPIF tags are checked (e.g.info
,warn
).For context, "nocache" was originally implemented in 4d43cbe, 0074a1d, and 9fc6be2.
I can't speak for other extensions, but in php-src there are only a few uses of
nocache
. It is manually printed at the end of some SKIPIF blocks in mysqli tests (see: 4d43cbe).In the MongoDB extension, we recently added
nocache
to a SKIPIF helper function responsible for dropping a database collection. After this function successfully drops the collection under test, it printed "nocache". I recently discovered that some tests were running when they should have been skipped. This was due to some tests where other helpers were called after this drop function. They were printing "skip" output but it was being ignored byrun-tests.php
consuming the earlier "nocache" string. PHPC-2064 goes into more detail, but to summarize I came up with three options:run-tests.php
to no longer clear SKIPIF output, which is the purpose of this PR.nocache
tag would be ignored (as the result was cleared). With this PR, the second "nocache" will BORK the test due to unexpected SKIPIF output.Some additional thoughts
The last bullet highlights a potential BC break: a test printing "nocache" twice will now BORK instead of executing. If that's a concern I can rework this PR to instead consume all leading "nocache" tags (e.g. a
while
loop).Going back to the old internals thread on SKIPIF caching, there was an open question about whether it should have been possible to skip a test and disable caching (not possible with the original implementation, since SKIPIF output was discarded after a
nocache
tag was consumed). I suppose that is now possible with this PR, provided "nocache" appears first in SKIPIF output.