Automattic / Automattic/wp-codebox
PHPUnit process isolation (@runInSeparateProcess) silently dies in the managed WordPress sandbox — child exits with no stderr and no result file
- Vorherrschende Sprache
- TypeScript
- Sterne
- 16
- Forks
- 4
- Ø Merge
- 59 Min.
- Gemergte PRs (30 T.)
- 131
Beschreibung
## Symptom
Every `@runInSeparateProcess` / `@runTestsInSeparateProcesses` test in Extra-Chill/extrachill-users fails in CI (managed sandbox, `wp_codebox_phpunit_bootstrap_mode: managed`) with:
```
Test was run in child process and ended unexpectedly
```
Reproduced with a minimal probe — a noop isolated test dies identically:
```php
class Test_Isolation_Probe extends WP_UnitTestCase {
/** @runInSeparateProcess @preserveGlobalState disabled */
public function test_noop_in_separate_process(): void { $this->assertTrue( true ); }
}
```
Evidence: Extra-Chill/extrachill-users#391 (19 tests across 5 classes), probe at branch `fix-391-test-baseline` (commit 5d389b5), GitHub run 34170973133.
## Diagnosis
Per PHPUnit 9's `AbstractPhpProcess::processChildResult()` (`vendor/phpunit/phpunit/src/Util/PHP/AbstractPhpProcess.php:276-309`), this failure means BOTH:
- child **stderr was empty** — no PHP fatal occurred (the child template sets `display_errors=stderr` before autoload, so any fatal would surface), and
- the **child result file was never written** — the child exited or was killed before `file_put_contents(processResultFile)` at the end of `__phpunit_run_isolated_test()`.
The child runs `php` with the template job on STDIN (`DefaultPhpProcess::runProcess` → `proc_open`), bare ini, then requires the composer autoload plus `$GLOBALS['__PHPUNIT_BOOTSTRAP']` (the managed bootstrap) before running the test. A silent death with no output points at an `exit()` in the child bootstrap path or a process kill — not a PHP error.
## What it breaks
- 19 tests in extrachill-users cannot run in CI at all.
- Any future test using process isolation in any repo on this harness hits the same wall.
## Ask
Investigate the child-process path in the sandbox: whether `proc_open`/STDIN execution of the PHPUnit template is permitted, whether the managed bootstrap exits early when re-run in a child context, and whether the result temp file (parent `sys_get_temp_dir()`) is writable from the child's mount namespace.
Repro: push a noop `@runInSeparateProcess` test on any repo configured with `wp_codebox_phpunit_bootstrap_mode: managed`.
Filed from Extra-Chill/extrachill-users#391 / PR Extra-Chill/extrachill-users#393.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne mit vendor/phpunit/phpunit/src/Util/PHP/AbstractPhpProcess.php:276-309 und DefaultPhpProcess::runProcess und reproduziere anschließend den isolierten noop-Test in einem Repository, das wp_codebox_phpunit_bootstrap_mode: managed verwendet. Verfolge den verwalteten Bootstrap, die proc_open/STDIN-Ausführung und den von sys_get_temp_dir() im übergeordneten Prozess gelieferten Ergebnispfad. Fertig ist es, wenn die Probe eine Ergebnisdatei erzeugt und in der verwalteten Sandbox ohne stilles Beenden des Kindprozesses besteht.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php
- Bereich
- infrastructure, testing-qa
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100