Skip to content

test(e2e): isolate build/ rstest spawns to per-fixture cwd#1247

Merged
fi3ework merged 3 commits into
mainfrom
fix/build-e2e-default-output-race
May 12, 2026
Merged

test(e2e): isolate build/ rstest spawns to per-fixture cwd#1247
fi3ework merged 3 commits into
mainfrom
fix/build-e2e-default-output-race

Conversation

@fi3ework

Copy link
Copy Markdown
Member

Summary

Background

e2e/build/buildCache.test.ts and e2e/build/index.test.ts both spawned rstest subprocesses with cwd: __dirname. When any sibling test triggered disk writes — performance.buildCache (enabled by the three buildCache fixtures), DEBUG=rstest, etc. — they raced on the shared default output path e2e/build/dist/.rstest-temp/, intermittently flipping the should write output to customized distPath.root assertion in build/index.test.ts. CI hid this via retry: 2 + low CPU concurrency; locally it failed ~85% of the time.

Implementation

  • Move every runRstestCli spawn under e2e/build/ into the fixture's own subdirectory as cwd, so each invocation owns its dist/.rstest-temp/ tree.
  • Drop include/buildDependencies entries from buildCache and happyDomBuildCache fixture configs that anchored to the outer cwd; rstest auto-discovers the fixture's index.test.ts once cwd is the fixture itself.
  • Document the convention in .agents/skills/testing/SKILL.md so future tests don't reintroduce the pattern.

User Impact

None — internal e2e test refactor.

Related Links

N/A

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Validation

  • `pnpm format` — clean
  • `pnpm run lint` — pass
  • `pnpm run typecheck` — fails on `watch/fixtures-test-build-fail-module/index.test.ts` (pre-existing on main, unrelated to this PR)
  • `pnpm run build` — pass
  • `pnpm run test` — pass
  • `cd e2e && pnpm test` — 205/205 testFiles pass
  • Stress: `pnpm exec rstest run build` 30/30 pass (baseline on main: 3/20 pass)

Sibling test files in e2e/build/ used to spawn rstest with cwd=__dirname,
sharing the default output path. When any of them triggered disk writes
(buildCache fixtures, DEBUG=rstest), they raced against assertions in
build/index.test.ts on dist/.rstest-temp/. Move every spawn to its own
fixture subdirectory so each invocation owns its dist tree. Drop now-
redundant include/buildDependencies entries that anchored to the parent
cwd, and document the convention in the testing skill.
@github-actions

github-actions Bot commented May 12, 2026

Copy link
Copy Markdown

Rsdoctor Bundle Diff Analysis

Found 12 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
adapter-rsbuild 3.6 KB 0
adapter-rslib 24.6 KB 0
adapter-rspack 7.7 KB 0
browser 2.0 MB 0
browser-react 3.7 KB 0
browser-ui 803.5 KB 0
coverage-istanbul 9.6 KB 0
core/browser 970.0 KB 0
core/loaders 869.0 B 0
core/main 1.6 MB 0
vscode/extension 58.9 MB 0
vscode/worker 14.4 KB 0

Generated by Rsdoctor GitHub Action

fi3ework added 2 commits May 12, 2026 22:12
The previous wording read as an absolute "never share cwd: __dirname",
but in practice the race only manifests when something forces disk
writes (buildCache, coverage, DEBUG=rstest, writeToDisk). Most e2e
tests share cwd: __dirname for pure in-memory runs and that's fine.
Reframe the section so the rule only applies to the disk-writing case
and the in-memory shared-cwd pattern is acknowledged as the norm.
The previous wording listed any disk write (buildCache, writeToDisk,
DEBUG, coverage) as a trigger, but coverage and blob reporters write
to different paths (coverage/, .rstest-reports/) and aren't on the
dist/.rstest-temp/ race surface. Narrow the rule to the actual
trigger — fixtures that persist the built bundle via buildCache or
writeToDisk — so existing coverage e2e patterns no longer read as
violations.
@fi3ework fi3ework enabled auto-merge (squash) May 12, 2026 14:23
@fi3ework fi3ework merged commit 34bbcd8 into main May 12, 2026
18 checks passed
@fi3ework fi3ework deleted the fix/build-e2e-default-output-race branch May 12, 2026 14:37
@9aoy 9aoy mentioned this pull request May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant