-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
test_runner: make signal handling configurable #59674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
test_runner: make signal handling configurable #59674
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
@@ -593,6 +593,7 @@ function run(options = kEmptyObject) { | |||
argv = [], | |||
cwd = process.cwd(), | |||
rerunFailuresFilePath, | |||
hookSignal = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -297,8 +297,7 @@ function setupProcessState(root, globalOptions) { | |||
process.on('uncaughtException', exceptionHandler); | |||
process.on('unhandledRejection', rejectionHandler); | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (globalOptions.isTestRunner || globalOptions.hookSignal === true) { | |
if (globalOptions.isTestRunner && globalOptions.hookSignal !== false) { |
lib/internal/test_runner/runner.js
Outdated
@@ -593,6 +593,7 @@ function run(options = kEmptyObject) { | |||
argv = [], | |||
cwd = process.cwd(), | |||
rerunFailuresFilePath, | |||
hookSignal = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
--test
CLI 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, aSIGINT
signal would terminate the process abruptly without proper test reporting.Therefore this PR introduces a new
hookSignal
option to the run() function, allowing developers to enable signal handling for these scenarios.I would appreciate your feedback😄
Related Issues