#51432: fix: don't let tests hang for an hour
Merged
Description of Change
Fix two spec runner bugs that could cause tests to hang forever.
-
Add a
spawnAndWait()spec helper that ensures that spawned processes are cleaned up. When a caller-provided timeout is reached, the helper terminates the child process and escalates toSIGKILLif the process doesn't exit cleanly. -
In the "rerun failed tests" phase of
script/spec-runner.js, enforce a timeout based on MOCHA_TIMEOUT.
Sample error CI log from here:
Rerunning failed test: esm renderer process nodeIntegration without context isolation should use import.meta callback handling from Node.js for Node.js modules (esm-spec.ts)
========================================
Running: /Users/runner/work/electron/electron/src/out/Default/Electron.app/Contents/MacOS/Electron electron/spec --enableRerun=3 --trace-uncaught true --enable-logging true --files /Users/runner/work/electron/electron/src/electron/spec/esm-spec.ts -g esm renderer process nodeIntegration without context isolation should use import\.meta callback handling from Node\.js for Node\.js modules
2071
Error: The action 'Run Electron Tests' has timed out after 60 minutes.
Complements #51441. This PR is "try to fix the runner to not hang on a failed test", 514441 is "try to fix the test."
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
-
npm testpasses - tests are changed or added
- PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense.
Release Notes
Notes: none.
Backports
Semver Impact
Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron