Option to use posix exit code upon fatal signal #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements
Description of the Change
This PR introduces a
--posix-exit-codes
boolean command-line option. If this option is specified, a fatal signal (eg.SIGABRT
, et al) will cause the process to exit with a standard posix exit code (128 + the numeric ID of the signal). Making this optional supports existing consumers that depend on the original exit codes, while solving issues for toolchains that expect standard posix behavior. Specifically, this option addresses a problem where out-of-memory crashes go undetected because the mocha exit codes are non-standard.Alternate Designs
The alternatives considered are not in the scope of the mocha project.
Why should this be in core?
This option is implemented in the core repository where signal handling occurs.
Benefits
This PR provides a solution for mochajs#3559 and various downstream issues reported by mocha consumers; it preserves non-zero exit codes when mocha is spawned as a child process via various CI/CD or reporting tools and prevents silently swallowing out-of-memory errors.
Possible Drawbacks
Introduces another option; requires docs; permits known non-standard exit code behavior to remain as the default.
Applicable issues
mochajs#3559
mochajs#3893
mochajs#2445
mochajs#2438
istanbuljs/nyc#798
cypress-io/cypress#24695