Skip to content

Commit

Permalink
more coverage-related tests for runner
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jan 17, 2016
1 parent 2af06c5 commit ab208e8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ function parseArgs (args) {
options.nycArgs = []
options.timeout = process.env.TAP_TIMEOUT || 30
// coverage tools run slow.
/* istanbul ignore else */
if (global.__coverage__) {
options.timeout = 240
}
Expand Down Expand Up @@ -329,7 +330,7 @@ function parseArgs (args) {
return options
}

/* istanbul ignore function */
/* istanbul ignore next */
function respawnWithCoverage (options) {
// console.error('respawn with coverage')
// Re-spawn with coverage
Expand Down
50 changes: 49 additions & 1 deletion test/runner.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var t = require('../')
var spawn = require('child_process').spawn
var cp = require('child_process')
var spawn = cp.spawn
var execFile = cp.execFile
var node = process.execPath
var run = require.resolve('../bin/run.js')
var ok = require.resolve('./test/ok.js')
Expand Down Expand Up @@ -515,3 +517,49 @@ t.test('non-zero exit is reported as failure', function (t) {
t.end()
})
})

t.test('warns when tring to cover stdin', function (t) {
var args = [run, '-', '--coverage']
var out = ''
var err = ''
var expect = 'Coverage disabled because stdin cannot be instrumented\n'
var child = spawn(node, args)
child.stdout.on('data', function (c) {
out += c
})
child.stderr.on('data', function (c) {
err += c
})
child.on('close', function (code, signal) {
t.equal(err, expect)
t.end()
})
child.stdin.end()
})

t.test('--nyc stuff', function (t) {
t.test('--nyc-version', function (t) {
var expect = require('nyc/package.json').version + '\n'
execFile(node, [run, '--nyc-version'], function (err, stdout, stderr) {
if (err) {
throw err
}
t.equal(stderr, '')
t.equal(stdout, expect)
t.end()
})
})

t.test('--nyc-help', function (t) {
execFile(node, [run, '--nyc-help'], function (err, stdout, stderr) {
if (err) {
throw err
}
t.equal(stderr, '')
t.match(stdout, /check-coverage/)
t.end()
})
})

t.end()
})

0 comments on commit ab208e8

Please sign in to comment.