I am using parallel testing addon for phpunit, paratest, with a Laravel application to speed up the execution of our testsuite. This works most of the time but occasionally I get the following failure.
League\Flysystem\Exception: Impossible to create the root directory "/codebuild/output/src0123456/src/github.com/org/repo/storage/framework/testing/disks/local". file_get_contents(/codebuild/output/src0123456/src/github.com/org/repo/.env): failed to open stream: No such file or directory
/codebuild/output/src0123456/src/github.com/org/repo/vendor/league/flysystem/src/Adapter/Local.php:112
/codebuild/output/src0123456/src/github.com/org/repo/vendor/league/flysystem/src/Adapter/Local.php:78
/codebuild/output/src0123456/src/github.com/org/repo/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php:167
/codebuild/output/src0123456/src/github.com/org/repo/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:261
/codebuild/output/src0123456/src/github.com/org/repo/vendor/laravel/framework/src/Illuminate/Support/Facades/Storage.php:70
/codebuild/output/src0123456/src/github.com/org/repo/tests/TestCase.php:42
The failure on line 42 relates to this line which is creating the local storage folder for testing.
Storage::persistentFake();
I think the second half of the error that mentions the .env file is unrelated as the exception picks the last logged error rather than the error related to the failure.
This only happens every now and again so it must be a sequence of operation or timing issue.
The tests are running and failing inside an AWS codebuild environment against php 7.3 and 7.4.
Anyone have any ideas?
Incase anyone else comes across this, it was resolved by creating the test storage directory before executing the tests.
mkdir -p storage/framework/testing/disks/local
vendor/bin/paratest
It's a little brittle but so far has worked perfectly for us.
From my experience this is usually not an issue with the file system. Most of the times I had a test not cleaning up correctly.
Depending on the file system and Paratest your tests are executed in a different order and then this errors happens.
There are a few things you can do to track this down:
--debug
mode when executing the tests on your build environment and check all the test that were executed before.--order-by=random
locally to execute your tests in a different order then they appear when reading from the file system. Execute it a few times, maybe you can then simulate this locally.Testcase::setUp()
) and cleans it when shut down (TestCase::teatDown()
), otherwise one test can have an influence on another.Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Laravel is a free open source PHP framework that came out in 2011. Since then, it has been able to become the framework of choice for web developers. One of the main reasons for this is that Laravel makes it easier, faster, and safer to develop complex web applications than any other framework.
https://laravel.com/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.