Skip to content

fix(phpunit): support PHPUnit process isolation in the PHPUnit runtime - #2624

Merged
chubes4 merged 1 commit into
mainfrom
fix/issue-2623-wp-codebox
Dec 3, 2026
Merged

chubes4 merged 1 commit into
mainfrom
fix/issue-2623-wp-codebox

Conversation

@chubes4

@chubes4 chubes4 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #2623. wordpress.phpunit runs through Playground 3.1.46’s php-wasm PHP.run() request SAPI. It reports PHP_SAPI=cli but leaves PHP_BINARY empty, so PHPUnit cannot launch a child the way it does under native PHP CLI. The fix routes isolation jobs to fresh sandbox PHP workers that share the parent’s filesystem. Compatibility: Additive.

What changed

  • Give PHPUnit a sandbox PHP executable and stage stdin-fed jobs as temporary scripts. Preserve the working directory, environment, and output pipes without modifying Composer vendor files.
  • Apply post-install mounts to Playground CLI children and share the parent’s filesystem with children of the programmatic runner. Let fresh workers load the project bootstrap without rerunning it in the parent.
  • Report subprocess setup failures as errors on the affected test. For managed PHPUnit 9.6, report an error if global-state preservation cannot serialize the live WordPress database connection, without dropping the preservation setting or aborting the suite.

Verification

All gates passed on 3bde54c. Base main@0d280ab unchanged.

  • HOMEBOY_LINT_BASE=0d280ab7315802ccdd72de3c6862cfe7d0dc5255 homeboy --placement local review lint wp-codebox --path . --…: passed, 68992 ms; retained gate metadata.
  • npm run build: passed, 494 ms; retained gate metadata.
  • npx tsx --test tests/phpunit-discovery-only.test.ts tests/phpunit-project-autoload.test.ts: passed, 1865 ms; retained gate evidence.
  • repro: none (no repro gate was declared, so these gates do not prove the issue).
  • CI: pending

Gate 3 output
✔ wordpress.phpunit discovery-only returns canonical files before execution (1.507564ms)
✔ discovery-only rejects selectors before starting a runtime (0.630243ms)
✔ discovery-only returns its schema-bound result directly (9.273431ms)
✔ relative managed config discovery matches absolute sandbox paths (issue #2601) (50.032473ms)
✔ recipe setup uses canonical boolean parsing and rejects mixed workflows (0.485679ms)
▶ file-only testsuite discovery (issue #2516)
  ✔ case: only <file> declared runs exactly that file, no directory scan (the fix) (20.281595ms)
  ✔ case: <directory> declared stays scoped to it (unchanged) (21.375557ms)
  ✔ case: neither <directory> nor <file> keeps the whole-test-root default (unchanged) (19.735763ms)
✔ file-only testsuite discovery (issue #2516) (62.54252ms)
✔ discovery-only reports an empty test root as an empty result (21.526291ms)
phpunit project autoload ok
✔ tests/phpunit-project-autoload.test.ts (1459.603692ms)
ℹ tests 11
ℹ suites 0
ℹ pass 11
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 1466.541102

Cook run
  • Cook ID: agent-task-1b31b37d-a47c-4cbd-b589-d8cb9588f73b
  • Attempt run ID: agent-task-1b31b37d-a47c-4cbd-b589-d8cb9588f73b-attempt-1-c3408821
  • Gate 1: tree ec2a6c3b0b5085724079348fd12f636db3bd6012
  • Gate 2: tree ec2a6c3b0b5085724079348fd12f636db3bd6012
  • Gate 3: tree ec2a6c3b0b5085724079348fd12f636db3bd6012

Evidence

  • Managed PHPUnit 9.6.34, recipe build phpunit → recipe-run: main finished all three tests but failed the isolated test with “Test was run in child process and ended unexpectedly.” Candidate passed all three, with three assertions and no failures or errors.
  • Project-installed PHPUnit 11.5.58, same recipe workflow: main aborted at the isolated test with “Unable to spawn worker process,” so the last regular test never ran. Candidate passed all three tests, with three assertions and no failures or errors.
  • The passing fixtures verified fresh PHP state, a file shared with the parent, and execution of the final regular test. Project-installed PHPUnit 10 and 12 also passed the three-test recipe. The managed fallback run finished all three tests with two assertions and one isolation error.
  • npm run build and git diff --check passed. All 16 focused checks ran and passed with no skips. Local Homeboy lint did not run because dependency setup could not load the nodejs extension. Changes remain uncommitted; Homeboy owns the deterministic gates and PR creation.

AI disclosure

Tool: Homeboy Cook. Agent: Homeboy (roadie). Model: roadie · route cook-heavy · served gpt-6.2-sol. Cook time: 1h32m.

AI traced the Playground runtime and SAPI, implemented process isolation for WordPress plugin suites, and verified the fix with managed and project-installed PHPUnit, under the direction of the Cook requester. Homeboy reports controller verification separately from this account of the AI's work. A human reviews before merge.

Refs #2623

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.

PHPUnit process isolation (runInSeparateProcess) crashes the whole run: proc_open is unavailable in the PHPUnit runtime

1 participant