Description
openedon Nov 8, 2018
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 success1
for failure (e.g., internal error, if any tests fail, no tests were run)2
for failure due to invalid command line usage126
if "bin/_mocha" not executable (handled by shell)128+n
wheren
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)