Skip to content

Commit

Permalink
Add test that non-zero test exit is reported
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Sep 2, 2015
1 parent 4e1db03 commit cdedf0f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/runner.js
Expand Up @@ -474,3 +474,20 @@ t.test('-t or --timeout to set timeout', function (t) {
})
t.end()
})

t.test('non-zero exit is reported as failure', function (t) {
var file = require.resolve('./test/ok-exit-fail.js')
var args = [run, file, '-Rclassic']
var child = spawn(node, args, { env: { TAP: 0 } })
var out = ''
child.stdout.on('data', function (c) {
out += c
})
child.on('close', function (code, signal) {
t.equal(code, 1)
t.equal(signal, null)
t.match(out, ' not ok ' + file)
t.match(out, /\n+\s+exitCode: 1\n/)
t.end()
})
})
5 changes: 5 additions & 0 deletions test/test/ok-exit-fail-bail.tap
@@ -0,0 +1,5 @@
TAP version 13
ok 1 - this passes but the exit code makes it not ok
1..1
___/# time=[0-9.]+(ms)?/~~~

3 changes: 3 additions & 0 deletions test/test/ok-exit-fail.js
@@ -0,0 +1,3 @@
var t = require('../..')
t.pass('this passes but the exit code makes it not ok')
process.exit(1)
5 changes: 5 additions & 0 deletions test/test/ok-exit-fail.tap
@@ -0,0 +1,5 @@
TAP version 13
ok 1 - this passes but the exit code makes it not ok
1..1
___/# time=[0-9.]+(ms)?/~~~

0 comments on commit cdedf0f

Please sign in to comment.