Skip to content

Ambiguous cli exit status

Closed
Closed

Description

Mocha exits with an exit status equal to the amount of errors in the test run. This is a potentially huge problem causing ambiguous exit codes.

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

This means a test with 256 errors will exit with code 0. Run this example as a proof:

for (var i = 0; i < 256; i += 1) {
    it('test ' + i, function () {
        throw new Error('waat');
    });
}

then echo $?

Further more, certain exit codes have special meaning which can cause tools further down a unix pipe to misbehave. See http://tldp.org/LDP/abs/html/exitcodes.html

Mocha cli should always exit with code 1 if there are tests failing and code 0 if there are no tests failing

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

Metadata

Assignees

No one assigned

    Labels

    type: buga defect, confirmed by a maintainera defect, confirmed by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions