(REF) FileTest - Prevent test-interactions from testIsDirWithOpenBasedir #24476
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.
Overview
This addresses a test-leakage issue involving
testIsDirWithOpenBasedir
. This is a follow-up/replacement for #24307. The previous mitigation allowed PR tests to continue, but we still execute the test in the matrix - so the matrix is still vulnerable to the test-leakage (eg https://test.civicrm.org/job/CiviCRM-Core-Matrix/11473/BKPROF=min,CIVIVER=5.53,SUITES=phpunit-crm,label=bknix-tmp/console).This makes the test safer.
ping @demeritcowboy @seamuslee001
Steps to Reproduce
To see the test-leakage issue, you need to run
CRM_Utils_FileTest::testIsDirWithOpenBasedir
in combination with some other failing test. To try it out, I've coerced a facsimile of the 11473 failure:And then run these together:
The output from PHPUnit should not be affected by
open_basedir
issues.Before
When
testIsDirWithOpenBasedir
runs, it changes theopen_basedir
, which cannot be switched back. Butphpunit
may still need to do work (like writing JUnit files) -- andopen_basedir
interferes with PHPUnit.After
When
testIsDirWithOpenBasedir
runs, it starts a subprocess and changesopen_basedir
-- but only in the subprocess. The mainphpunit
process retains its original file-access privileges.Technical Details
How do we know this refactoring still leaves a useful test? Well, based on the comments in
testIsDirWithOpenBasedir()
, you would expectis_dir()
to behave badly -- andCRM_Utils_File::isDir()
to behave nicely. So I edited the test to switch the focus of the test, egThe updated test still discerns between these two (ie
is_dir()
fails the test, andCRM_Utils_File::isDir()
passes the test).Comments
I targeted this PR at
5.53
(5.53.beta) because the issue hinders the readability of matrix results on 5.53. After merging this, we'll need to undo the@group ornery
that was applied tomaster
(5.54.alpha).This is not pretty. I'm sure there could be other/prettier approaches. For now I just need some way to get a reliable matrix.