test_runner: make signal handling configurable#59674
test_runner: make signal handling configurable#59674mete0rfish wants to merge 7 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #59674 +/- ##
==========================================
+ Coverage 89.91% 89.93% +0.02%
==========================================
Files 667 667
Lines 196600 196793 +193
Branches 38594 38421 -173
==========================================
+ Hits 176766 176981 +215
+ Misses 12270 12211 -59
- Partials 7564 7601 +37
🚀 New features to boost your workflow:
|
|
Hey @mete0rfish, thanks for the contribution! I'll take a look ASAP. In the meantime, I noticed that the commit validation is failing...could you please take a look at it? 😁 |
lib/internal/test_runner/runner.js
Outdated
| argv = [], | ||
| cwd = process.cwd(), | ||
| rerunFailuresFilePath, | ||
| hookSignal = false, |
There was a problem hiding this comment.
If we decide to add a new property to the run method, we also need to update the documentation:
https://github.com/nodejs/node/blob/fb614c43240158fa6c5b988571746fadff8e22d7/doc/api/test.md?#runoptions
lib/internal/test_runner/harness.js
Outdated
| process.on('beforeExit', exitHandler); | ||
| // TODO(MoLow): Make it configurable to hook when isTestRunner === false. | ||
| if (globalOptions.isTestRunner) { | ||
| if (globalOptions.isTestRunner || globalOptions.hookSignal === true) { |
There was a problem hiding this comment.
| if (globalOptions.isTestRunner || globalOptions.hookSignal === true) { | |
| if (globalOptions.isTestRunner && globalOptions.hookSignal !== false) { |
lib/internal/test_runner/runner.js
Outdated
| argv = [], | ||
| cwd = process.cwd(), | ||
| rerunFailuresFilePath, | ||
| hookSignal = false, |
There was a problem hiding this comment.
| hookSignal = false, | |
| hookSignal = true, |
please preserve the current behavior as the default behavior
1e772a1 to
54a6e25
Compare
This PR resolves a TODO in the test runner to allow signal handling to be enabled.
Purpose
The test runner's signal handlers are only attached when it is invoked via the
--testCLI flag (isTestRunner === true). Thisprevents users from opting into the same behavior in scenarios where
isTestRunner === false, such as when calling the run() API from a JS file. In these cases, aSIGINTsignal would terminate the process abruptly without proper test reporting.Therefore this PR introduces a new
hookSignaloption to the run() function, allowing developers to enable signal handling for these scenarios.I would appreciate your feedback😄
Related Issues