-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
posixExitCodes.spec.js
65 lines (58 loc) · 2 KB
/
posixExitCodes.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
'use strict';
var helpers = require('../helpers');
var runMocha = helpers.runMocha;
var os = require('os');
const EXIT_SUCCESS = 0;
const EXIT_FAILURE = 1;
const SIGNAL_OFFSET = 128;
describe('--posix-exit-codes', function () {
if (os.platform() !== 'win32') { // SIGTERM is not supported on Windows
describe('when enabled, and with node options', function () {
var args = ['--no-warnings', '--posix-exit-codes'];
it('should exit with correct POSIX shell code on SIGABRT', function (done) {
var fixture = 'signals-sigabrt.fixture.js';
runMocha(fixture, args, function postmortem(err, res) {
if (err) {
return done(err);
}
expect(res.code, 'to be', SIGNAL_OFFSET + os.constants.signals.SIGABRT);
done();
});
});
it('should exit with correct POSIX shell code on SIGTERM', function (done) {
var fixture = 'signals-sigterm.fixture.js';
runMocha(fixture, args, function postmortem(err, res) {
if (err) {
return done(err);
}
expect(res.code, 'to be', SIGNAL_OFFSET + os.constants.signals.SIGTERM);
done();
});
});
it('should exit with code 1 if there are test failures', function (done) {
var fixture = 'failing.fixture.js';
runMocha(fixture, args, function postmortem(err, res) {
if (err) {
return done(err);
}
expect(res.code, 'to be', EXIT_FAILURE);
done();
});
});
});
}
describe('when not enabled, and with node options', function () {
it('should exit with the number of failed tests', function (done) {
var fixture = 'failing.fixture.js'; // contains three failing tests
var numFailures = 3;
var args = ['--no-warnings'];
runMocha(fixture, args, function postmortem(err, res) {
if (err) {
return done(err);
}
expect(res.code, 'to be', numFailures);
done();
});
});
});
});