Skip to content

Commit

Permalink
Further refining --only
Browse files Browse the repository at this point in the history
- Set 'this.runOnly' as the flag on the test object.  Too confusing otherwise.
- Handle the environment variable properly in the test runner.
- Downgrade the stderr warning to a comment.
  • Loading branch information
isaacs committed Jun 25, 2017
1 parent 0d0ac05 commit f60b060
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions bin/run.js
Expand Up @@ -768,6 +768,7 @@ function runTests (options) {
// At this point, we know we need to use the tap root,
// because there are 1 or more files to spawn.
var tap = require('../lib/tap.js')
tap.runOnly = false

// greps are passed to children, but not the runner itself
tap.grep = []
Expand Down
2 changes: 0 additions & 2 deletions lib/point.js
Expand Up @@ -31,8 +31,6 @@ function tpMessage (message, extra) {
message += ' # TODO'
if (typeof extra.todo === 'string')
message += ' ' + extra.todo
} else if (extra.only) {
message += ' # ONLY'
} else if (extra.time)
message += ' # time=' + extra.time + 'ms'

Expand Down
1 change: 1 addition & 0 deletions lib/tap.js
Expand Up @@ -8,6 +8,7 @@ var yaml = require('js-yaml')
util.inherits(TAP, Test)
function TAP (options) {
Test.call(this, options)
this.runOnly = process.env.TAP_ONLY === '1'
this.start = Date.now()
}

Expand Down
8 changes: 8 additions & 0 deletions lib/test.js
Expand Up @@ -122,6 +122,14 @@ Test.prototype.sub = function (Class, extra, caller) {
}
}

if (extra.only && !this.runOnly) {
this.comment('%j has `only` set but all tests run', extra.name)
}

if (this.runOnly && !extra.only) {
extra.skip = true
}

if (extra.todo || extra.skip) {
this.pass(extra.name, extra)
return Promise.resolve(this)
Expand Down

0 comments on commit f60b060

Please sign in to comment.