Skip to content

Make native-php E2E tests pass on Windows#3343

Merged
fredrikekelund merged 18 commits intotrunkfrom
rsm-2326-make-e2e-tests-pass-on-windows
May 7, 2026
Merged

Make native-php E2E tests pass on Windows#3343
fredrikekelund merged 18 commits intotrunkfrom
rsm-2326-make-e2e-tests-pass-on-windows

Conversation

@fredrikekelund
Copy link
Copy Markdown
Contributor

@fredrikekelund fredrikekelund commented May 5, 2026

Related issues

  • Fixes RSM-2326

How AI was used in this PR

Codex was used to help diagnose race condition issues in collectDirectoryMetadata and to fix an issue in blueprints.phar given error logs from a local Windows VM. I also used it to add the native-php E2E testing config for Buildkite. Claude was used to debug the persistently failing E2E tests and came up with the OPcache directory fix.

Proposed Changes

  • Fix an OPcache configuration issue that was causing some E2E tests to fail on Windows.
  • Kill the PHP child processes spawned by php-server-child.ts on Windows, too.
  • Temporarily include a precompiled blueprints.phar with a bugfix needed to make blueprints.test.ts pass. This can be removed when Close ProcessOutputStream in Runtime::eval_php_code_in_subprocess WordPress/php-toolkit#265 has landed and there's a new php-toolkit release. I advise landing this PR first and reverting this change later.
  • Make collectDirectoryMetadata more robust against race conditions.

Testing Instructions

E2E tests should pass on both platforms.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented May 5, 2026

📊 Performance Test Results

Comparing 17938f9 vs trunk

app-size

Metric trunk 17938f9 Diff Change
App Size (Mac) 1409.87 MB 1410.38 MB +0.51 MB ⚪ 0.0%

site-editor

Metric trunk 17938f9 Diff Change
load 1510 ms 1515 ms +5 ms ⚪ 0.0%

site-startup

Metric trunk 17938f9 Diff Change
siteCreation 8087 ms 8078 ms 9 ms ⚪ 0.0%
siteStartup 4955 ms 4940 ms 15 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

payload: {},
};
case 'kill-daemon':
await this.beginShutdownByKillingChildren( 'kill-daemon' );
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splitting the shutdown method into beginShutdownByKillingChildren and finalizeShutdownByClosingSocketServersAndExiting isn't necessary for the core purpose of this PR: getting E2E tests to pass on Windows. It does help with correctness, though, because it makes the site stop --all command complete after the child processes are closed instead of before.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should eventually revert this change, but I'm personally open to landing this PR as is and reverting this once WordPress/php-toolkit#265 has landed and we have a new php-toolkit release.

private async finalizeShutdownByClosingSocketServersAndExiting(): Promise< void > {
await this.controlServer.close();
await this.eventsServer.close();
process.exit( 0 );
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no indication that the process manager daemon didn't die after executing site stop --all, but some defensiveness here doesn't hurt.

@fredrikekelund
Copy link
Copy Markdown
Contributor Author

fredrikekelund commented May 7, 2026

The ~250MB increase in installer size must be some kind of fluke… Let's see what CI reports now that I've merged trunk again.

EDIT: Confirmed that this was the case.

@fredrikekelund fredrikekelund changed the title [WIP] Make native-php E2E tests pass on Windows Make native-php E2E tests pass on Windows May 7, 2026
Copy link
Copy Markdown
Contributor

@bcotrim bcotrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

// maps to TerminateProcess of a single PID, so neither cleanup nor tree-walk runs.
// Closing the IPC channel triggers the wrapper's 'disconnect' handler instead, which
// kills the PHP child and exits cleanly. Force escalation falls back to taskkill /T.
if ( managedProcess.child.connected ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a disconnect handler to playground child as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always call child.kill() anyway, so there's no need for Playground child processes to handle the disconnect event (the only logical way for them to handle it would be to exit, as I see it). With native PHP, this approach is necessary for the child process to "forward" the kill signal to the PHP process.

@fredrikekelund fredrikekelund enabled auto-merge (squash) May 7, 2026 12:48
@fredrikekelund fredrikekelund merged commit 97c6f10 into trunk May 7, 2026
10 checks passed
@fredrikekelund fredrikekelund deleted the rsm-2326-make-e2e-tests-pass-on-windows branch May 7, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants