Skip to content

test(runtime): isolate process-global fixtures from parallel tests - #9767

Closed
proggeramlug wants to merge 2 commits into
PerryTS:mainfrom
proggeramlug:fix/9197-isolate-runtime-test-fixtures
Closed

test(runtime): isolate process-global fixtures from parallel tests#9767
proggeramlug wants to merge 2 commits into
PerryTS:mainfrom
proggeramlug:fix/9197-isolate-runtime-test-fixtures

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

The three tests in #9197 inspect process-global state while sibling tests can change it. The Linux loader race is concrete: rejects_an_unreadable_loaded_shared_object unlinks a loaded library while the discovery test enumerates loaded images; box allocation counters and the composed symbol-cache epoch are also shared.

Run the three reported fixtures and the loader’s destructive sibling in separate test processes. The helper selects the current libtest name and requires successful completion of the original body, so stale filters, child panics, or early exits cannot silently pass. All original behavior assertions remain; the box fixture now requires the exact allocation count and one turn’s residue bound instead of allowing slack for neighboring tests.

Validation:

  • Full runtime suite: macOS 3,137 passed / 4 ignored; Linux x86_64 3,125 passed / 4 ignored.
  • Focused concurrency: macOS 20 rounds × 2 isolated cases with two parent test threads. Linux 20 rounds × 4 isolated cases with four parent test threads.
  • Standalone helper fault checks: normal completion succeeds; child panic, early exit, and zero matching tests each fail as expected.
  • pre-tag-check.sh --quick and diff checks pass.
  • Canonical affected-crate runner: runtime passes; compiler CLI 1,083 passed and one existing PERRY_CONCAT_SITE_CACHE cache-registry failure (fixed separately in fix(cache): register concat switch and explain codegen inputs #9748). The runner stops at that unrelated failure.

The full runtime suite still uses its existing single-threaded policy; this change isolates these specific fixtures. Linux validation includes the existing pthread-attribute prerequisite from #9752, which is not part of this diff.

Test-only change; no version bump.

Closes #9197.

Summary by CodeRabbit

  • Bug Fixes
    • Improved runtime test isolation to prevent shared process state from affecting neighboring tests.
    • Tightened validation around resource reuse and cleanup behavior.
    • Improved reliability of tests involving dynamically loaded libraries and symbol metadata.
  • Tests
    • Added safeguards to ensure isolated test fixtures complete successfully and do not leave behind state that could influence other test runs.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: cf8d22c2-7510-46b4-9442-f4c59ef063cf

📥 Commits

Reviewing files that changed from the base of the PR and between 12efed1 and aa26128.

📒 Files selected for processing (5)
  • changelog.d/9767-isolated-runtime-fixtures.md
  • crates/perry-runtime/src/box/release_tests.rs
  • crates/perry-runtime/src/gc/roots/stack_maps_decode_tests.rs
  • crates/perry-runtime/src/symbol/get.rs
  • crates/perry-runtime/src/test_support.rs

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Runtime test fixtures that inspect process-global state now run in isolated child processes. The box reuse test uses exact allocation accounting and a tighter residue bound. A changelog entry documents the fix.

Changes

Runtime Fixture Isolation

Layer / File(s) Summary
Child-process isolation helper
crates/perry-runtime/src/test_support.rs
Adds isolated_test, which re-runs a libtest case in a child process and verifies its completion marker and exit status.
Process-global fixture updates
crates/perry-runtime/src/box/release_tests.rs, crates/perry-runtime/src/gc/roots/stack_maps_decode_tests.rs, crates/perry-runtime/src/symbol/get.rs, changelog.d/9767-isolated-runtime-fixtures.md
Routes the affected fixtures through isolated_test. Tightens the box allocation and residue assertions. Documents the fix.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to aa261

This change isolates process-global runtime fixtures in child processes and tightens their assertions, reducing parallel-test flakiness without changing runtime product behavior. No current merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant TestRunner
  participant isolated_test
  participant ChildTestProcess
  TestRunner->>isolated_test: invoke process-global fixture
  isolated_test->>ChildTestProcess: launch exact test with isolation marker
  ChildTestProcess->>ChildTestProcess: run isolated fixture body
  ChildTestProcess-->>isolated_test: print completion marker and exit
  isolated_test-->>TestRunner: verify successful completion
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: isolating process-global runtime test fixtures from parallel tests.
Description check ✅ Passed The description provides the summary, changed behavior, related issue, detailed validation results, and test-only scope. It does not use the template headings or include the checklist, but the require…
Linked Issues check ✅ Passed The changes address issue #9197 by isolating the three identified flaky fixtures and the destructive loaded-library fixture. The helper verifies child-test selection and successful completion, and the…
Out of Scope Changes check ✅ Passed The changes are limited to test isolation support, the affected runtime tests, related assertions, and a changelog entry. No unrelated production behavior or version metadata changes are present.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 4 files. (1 skipped: 1 …
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proggeramlug

Copy link
Copy Markdown
Contributor Author

Landed on main via merge train #9798 (rebase-merged, so your commits keep their authorship). Thanks!

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.

Three perry-runtime tests flake under parallel test runs (reproduce on unmodified main)

1 participant