Repository navigation
Run the test suite in parallel - #225
Merged
Merged
Conversation
Under pest --parallel every worker shared storage/. TestCase::tearDown
deletes storage/framework/async after each test, so it kept deleting the
async spool while a test in another worker was still using it. Held
refreshes then found no payload and quietly never ran, and other tests
lost their draft images or failed in tearDown itself. When tearDown threw
before parent::tearDown(), the open transaction was never rolled back and
every later test in that worker failed with "cannot start a transaction
within a transaction".
Each worker now sets LARAVEL_STORAGE_PATH to
storage/framework/testing/parallel/{token} before the app boots, so the
config built from storage_path() follows it. The directory is emptied
when the worker starts. A serial run still uses storage/.
tearDown also calls parent::tearDown() in a finally block, so one failed
cleanup can't take down the rest of the worker.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each worker now has its own storage directory, so the suite passes in parallel. Locally it takes about 10 seconds instead of 85. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simonhamp
marked this pull request as ready for review
November 26, 2026 23:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
pest --parallelfailed 200 to 300 tests a run, a different set each time. Serially everything passes.Every worker shared
storage/.TestCase::tearDowndeletesstorage/framework/asyncafter each test, so it kept deleting the async spool while a test in another worker was still using it.finishRefreshes()skips a task whose payload has gone, so held refreshes quietly never ran and the test failed on what the screen showed ("Did not see [1 new commit]" and the like). Other tests lost their draft images understorage/app/draft-images, or failed in tearDown itself withFilesystemIterator ... Failed to open directory. When that happened,parent::tearDown()never ran, the test's transaction was left open, and every later test in that worker failed with "cannot start a transaction within a transaction" or "no such table: pending_writes".What changed in
tests/TestCase.php:LARAVEL_STORAGE_PATHtostorage/framework/testing/parallel/{token}before the app boots, so the config built fromstorage_path()(disks, logs, compiled views) follows it. The directory is emptied and its skeleton created when the worker starts. That folder is already gitignored. A serial run has noTEST_TOKENand still usesstorage/.tearDowncallsparent::tearDown()in afinally, so one failed cleanup can't take down the rest of the worker.The storage change alone is enough to make the parallel run pass. With only the
finallychange the transaction errors went away but about 160 tests still failed on the shared spool, so those assertion failures were real races and not just fallout from the open transaction.CI now runs
php artisan test --compact --parallel, one worker per CPU on the runner.Results on this branch:
--parallelpassed three runs in a row (2434 passed, 12 skipped each, about 11s on 14 processes), and the serial run still passes (2434 passed, 12 skipped, about 85s). Before the change, a parallel run on main had 270 failures.For review: tests that call
app()->useStoragePath()themselves (NataNullers, LogRowCache, LogPageFrames, ImageCache) still win over the per-worker path, becauseuseStoragePath()takes precedence overLARAVEL_STORAGE_PATH. The worker path is read from$_SERVER/getenv()and set up with a plainFilesystem, since it runs before the first app exists.Screenshots
🤖 Generated with Claude Code