Repository navigation
Expand file tree
/
Copy pathexit-code.js
More file actions
69 lines (62 loc) · 1.84 KB
/
Copy pathexit-code.js
File metadata and controls
69 lines (62 loc) · 1.84 KB
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
66
67
68
69
var spawn = require('child_process').spawn
var node = process.execPath
var bin = require.resolve('../bin/tap.js')
var test = require('../').test
var path = require('path')
var fixtures = path.resolve(__dirname, 'fixtures')
test('exit code 1 when tap results show failure', function (t) {
t.plan(3)
t.test('test exits 0, has failures', function (t) {
t.plan(2)
var file = path.resolve(fixtures, 'fail-zero-exit.js')
spawn(node, [bin, file]).on('exit', function (code) {
t.equal(code, 1)
})
spawn(node, [file]).on('exit', function (code) {
t.equal(code, 0)
})
})
t.test('test exits 1, has failures', function (t) {
t.plan(2)
var file = path.resolve(fixtures, 'fail-correct-exit.js')
spawn(node, [bin, file]).on('exit', function (code) {
t.equal(code, 1)
})
spawn(node, [file]).on('exit', function (code) {
t.equal(code, 1)
})
})
t.test('test exits 1, has no failures', function (t) {
t.plan(2)
var file = path.resolve(fixtures, 'fail-exit.js')
spawn(node, [bin, file]).on('exit', function (code) {
t.equal(code, 1)
})
spawn(node, [file]).on('exit', function (code) {
t.equal(code, 1)
})
})
})
test('successes exit 0', function (t) {
t.plan(2)
t.test('test that does nothing, but exits 0', function (t) {
t.plan(2)
var file = path.resolve(fixtures, 'trivial-success.js')
spawn(node, [bin, file]).on('exit', function (code) {
t.equal(code, 0)
})
spawn(node, [file]).on('exit', function (code) {
t.equal(code, 0)
})
})
t.test('test that succeeds, and exits 0', function (t) {
t.plan(2)
var file = path.resolve(fixtures, 'success.js')
spawn(node, [bin, file]).on('exit', function (code) {
t.equal(code, 0)
})
spawn(node, [file]).on('exit', function (code) {
t.equal(code, 0)
})
})
})