Skip to content
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

Option to use posix exit code upon fatal signal #1

Merged
merged 3 commits into from
May 31, 2023
Merged

Conversation

73rhodes
Copy link

@73rhodes 73rhodes commented May 23, 2023

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • All new code requires tests to ensure against regressions.

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

  • No breaking changes; this is an ehancement (minor release)

@73rhodes 73rhodes force-pushed the posix-exit-codes branch 14 times, most recently from d32f33d to 4a1570a Compare May 29, 2023 13:33
@73rhodes 73rhodes force-pushed the posix-exit-codes branch from 4a1570a to 33d0f0a Compare May 29, 2023 15:55
@73rhodes 73rhodes force-pushed the posix-exit-codes branch from 1f16fa2 to 146082c Compare May 29, 2023 21:48
@73rhodes 73rhodes marked this pull request as ready for review May 30, 2023 17:00
@73rhodes 73rhodes force-pushed the posix-exit-codes branch 3 times, most recently from bf4e602 to a9ec108 Compare May 31, 2023 13:55
@73rhodes 73rhodes force-pushed the posix-exit-codes branch from a9ec108 to ec63a60 Compare May 31, 2023 13:56
@73rhodes 73rhodes merged commit cdee617 into master May 31, 2023
@73rhodes 73rhodes deleted the posix-exit-codes branch July 8, 2024 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants