You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a test suite where I create a directory with vfsStream, which is meant to simulate a write-blocked directory for my SUT. In my code the logic checks both is_dir() and is_writable() for a directory to give granural errors to the user.
Now, in my test case I have to use __construct() as the directory is fetched in the test case via data providers, which are run before setUp. The constructor creates the directory as follows:
And the code inside Thingy which I am testing looks as follows:
publicfunction__construct(?string$tmp_dir = null)
{
if ($tmp_dir === null) {
$tmp_dir = \sys_get_temp_dir();
}
/** @var string $tmp_dir */if (\is_dir($tmp_dir) === false) { // <-- this here randomly fails for existing directorythrownew \InvalidArgumentException('Invalid tempdir: missing');
}
if (\is_writable($tmp_dir) === false) {
thrownew \InvalidArgumentException('Invalid tempdir: unwritable');
}
$this->tmpdir = $tmp_dir;
}
Now, the is_dir() call is randomly failing, even with the assert() in my test case constructor passing all runs properly. It seems like I get 50% success rate, where I can either get no exception from the SUT constructor, or then I land into the "unwritable error branch" as mandated by a test case.
PHP version is 7.4. PHPUnit version is 9.3.8, and vfsStream is at 1.6.8.
The text was updated successfully, but these errors were encountered:
This problem seemingly went away after a co-worker removed the data provider and split the target test method into two separate test methods. Will be monitoring whether this permanently fixes the issue or not.
I have a test suite where I create a directory with vfsStream, which is meant to simulate a write-blocked directory for my SUT. In my code the logic checks both
is_dir()
andis_writable()
for a directory to give granural errors to the user.Now, in my test case I have to use
__construct()
as the directory is fetched in the test case via data providers, which are run beforesetUp
. The constructor creates the directory as follows:Here is the test case code I'm running:
And the code inside
Thingy
which I am testing looks as follows:Now, the
is_dir()
call is randomly failing, even with theassert()
in my test case constructor passing all runs properly. It seems like I get 50% success rate, where I can either get no exception from the SUT constructor, or then I land into the "unwritable error branch" as mandated by a test case.PHP version is 7.4. PHPUnit version is 9.3.8, and vfsStream is at 1.6.8.
The text was updated successfully, but these errors were encountered: