Automattic / Automattic/wp-codebox

PHPUnit process isolation (@runInSeparateProcess) silently dies in the managed WordPress sandbox — child exits with no stderr and no result file

Open
#2,485 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
16
Forks
4
Avg merge
59m
Merged PRs (30d)
131

Description

## 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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with vendor/phpunit/phpunit/src/Util/PHP/AbstractPhpProcess.php:276-309 and DefaultPhpProcess::runProcess, then reproduce the noop isolated test in a repository using wp_codebox_phpunit_bootstrap_mode: managed. Trace the managed bootstrap, proc_open/STDIN execution, and the parent sys_get_temp_dir() result path. Done means the probe produces a result file and passes in the managed sandbox without silent child termination.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
infrastructure, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.