-
Notifications
You must be signed in to change notification settings - Fork 24.6k
[6.x] Delete cached config file before running tests #5091
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
Conversation
|
Is that server variable always going to be set? If it's not we will get an error there. |
|
I've included @timacdonald's suggestion on how to delete the files. Now we can be sure none of the cached files can give us any trouble. I've also refactored the bootstrap file as a PHPunit extension, this has the following benefits:
|
|
I think this should probably be 2 PRs so discussion can happen independently for the two different changes, i.e.
array_map('unlink', glob('bootstrap/cache/*.phpunit.php'));
But while it is here - a couple of thoughts on this approach:
This isn't really an issue. The files are .gitignored and before the introduction of this feature, running your test suite would already generate We will also have to check how this plays with parallel test runners, i.e. that it only runs the extension hooks once per run and not once per thread. |
|
So, is this ready to merge? |
|
I think this PR can be merged. I'm pretty sure it works just like the old code, and it solves the problem described in this issue. Like @timacdonald said, i don't know if these hooks work with parallel test runners. But since these hooks are normal phpunit features, i'm not sure if this is something we should worry about. |
|
Looks like ParaTest is hitting some issues due to its multi threaded-ness, but I have a solution that I think can just go in the docs. Will send a follow up PR to the docs about it. p.s. @SjorsO I dig the extension over the plain bootstrap file. Nice being able to have a specific before and after hooks. |
I ran into the problem that the bootstrapping of the unit tests crashed because the cached config file (
bootstrap/cache/phpunit.config.php) contained a reference to a class that didn't exist anymore.This problem happened to me when I removed a package that I had manually registered in my
config/app.php. I think this can also happen when you rename classes.Steps to reproduce:
config/app.phpcomposer require clarification/sparkpost-laravel-driverClarification\MailDrivers\Sparkpost\SparkpostServiceProvider::classbootstrap/cache/phpunit.config.phpnow contains the FQCN of the packageconfig/app.phpand remove the package (composer remove clarification/sparkpost-laravel-driver)You should see the following error:
I'm not very happy with this solution, but it works. Maybe someone has a better solution to this problem.
Also, this same bug might also exist with the other cached files.