Skip to content

🚀 Feature: Add option to exit with standard exit codes #3559

Open
zendesk/sunco-mocha
#2

Description

Description

Mocha's exit code is the number of failed tests (up to 255).
This is nonstandard and should be more like Unix/POSIX programs.

process.exitCode should be one of:

  • 0 for success
  • 1 for failure (e.g., internal error, if any tests fail, no tests were run)
  • 2 for failure due to invalid command line usage
  • 126 if "bin/_mocha" not executable (handled by shell)
  • 128+n where n is signal# (e.g., SIGINT=2, so rc=130)

where:

  • 0 is EXIT_SUCCESS (POSIX)
  • 1 is EXIT_FAILURE (POSIX)
  • rest are shell scripting maxims (e.g., sh, ksh, bash) (UNIX)

This should be explicitly added to the documentation.

Notes

Exit codes have a range from 0-255.
An exit value greater than 255 returns an exit code modulo 256.

The 126 exit code can only happen on UNIX and would be provided by the shell itself.

Mocha's current scheme leads to ambiguous error codes.
For example, there is no means to distinguish between 130 test failures and interrupt by <Ctrl>-C.

It was mentioned that this would certain CI systems relied on this exit code abuse.
I fail to see how this could affect them; a test failure from above would still return 1, just not a count.

Related

#2445
#2438 (same problem, but fix only addressed clamping #failures)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    area: integrationsrelated to working with 3rd party software (e.g., babel, typescript)area: node.jscommand-line-or-Node.js-specificsemver-minorimplementation requires increase of "minor" version number; "features"status: accepting prsMocha can use your help with this one!type: featureenhancement proposal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions