Skip to content

test: unique artifact filenames to fix a race under paratest - #209

Merged
kbond merged 1 commit into
zenstruck:1.xfrom
Amoifr:fix-flaky-shared-artifact-files
Aug 29, 2026
Merged

kbond merged 1 commit into
zenstruck:1.xfrom
Amoifr:fix-flaky-shared-artifact-files

Conversation

@Amoifr

@Amoifr Amoifr commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

paratest --functional runs test methods concurrently, and the file-saving tests all write to the same var/browser/source paths. catchFileContents() removes the file, runs the callback, then reads it back, so one test can read the file another test just wrote.

Seen on this run (#208's first CI pass): can_save_formatted_json_source failed with the exception dump from can_save_source_when_exception on one job, and the mirror image on another. The two tests come from the KernelBrowserTests trait, so two classes race on the same source.txt even across classes.

Each save now uses a unique filename (random_bytes prefix). With the fix I could no longer reproduce any can_save_* failure across 8 local paratest --functional runs.

paratest --functional runs test methods concurrently, and the tests
saving source files all wrote to the same var/browser/source path:
one test could read the file another test just wrote, failing with
the other test's content. Seen on CI where can_save_formatted_json_source
and can_save_source_when_exception each read the other's output.

Each save now uses a unique filename.
@kbond
kbond force-pushed the fix-flaky-shared-artifact-files branch from ed55ed2 to 72a395e Compare August 29, 2026 15:08

@kbond kbond left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

@kbond
kbond merged commit 7de7e8a into zenstruck:1.x Aug 29, 2026
18 checks passed
kbond added a commit that referenced this pull request Oct 10, 2026
* 1.x:
  test: unique artifact filenames to fix a race under paratest (#209)
  bot: fix cs [skip ci]
  fix: fail when acting on the browser after an expected exception (#207)
  fix: don't mutate the default http options when merging request options (#210)
  changelog: update [skip ci]
  feat(playwright): use the playwright bundle configuration when registered (#206)
  test: support phpunit 11, 12 and 13, and run the suite with paratest (#205)
  chore: drop EOL Symfony 8.0 from the ci matrix
  test: enable and cover the browser extension
  chore: remove stray `attachment.zip` from the project root
  test: run the suite with paratest
  test: support phpunit 11, 12 and 13
  fix: Mink deprecation (#203)
  changelog: update [skip ci]
  docs: document the shared redirect and profiling api
  fix: honor `BROWSER_FOLLOW_REDIRECTS` in the `PlaywrightBrowser`
  feat: Add `PlaywrightBrowser` (#195)
  fix: phpstan doc comment (#178)
  feat: make saved artifact paths clickable (#165)
  fix: detect Symfony 7.4+ exception pages (#197)
  doc: Standardize `README` security policy section (#193)
  chore!: bump minimum PHP version to 8.2 (#196)
  changelog: update [skip ci]
  changelog: update [skip ci]
  fix: mink deprecation
  bot: sync with template [skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants