Skip to content

Commit

Permalink
WIP TAP_ONLY, --only, {only: true} and warning to stderr if {only: tr…
Browse files Browse the repository at this point in the history
…ue} but tap’s only option is not true
  • Loading branch information
gr2m authored and isaacs committed Jun 25, 2017
1 parent 090a8ee commit 7e42a08
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions bin/run.js
Expand Up @@ -394,6 +394,10 @@ function parseArgs (args, defaults) {
options.bail = false
continue

case '--only':
options.only = true
continue

case '--':
options.files = options.files.concat(args.slice(i + 1))
i = args.length
Expand Down Expand Up @@ -603,6 +607,9 @@ function setupTapEnv (options) {
process.env.TAP_GREP = options.grep.map(function (pattern) {
return pattern.toString()
}).join('\n')

if (options.only)
process.env.TAP_ONLY = '1'
}

function globFiles (files) {
Expand Down
5 changes: 4 additions & 1 deletion lib/base.js
Expand Up @@ -44,6 +44,7 @@ function Base (options) {
this.jobs = +ownOrEnv(options, 'jobs', 'TAP_JOBS') || 0
this.skip = ownOr(options, 'skip', false)
this.todo = ownOr(options, 'todo', false)
this.only = ownOr(options, 'only', false)
this.setupParser(options)
this.finished = false
this.output = ''
Expand Down Expand Up @@ -214,6 +215,7 @@ Base.prototype.inspect = function () {
output: this.output,
skip: this.skip,
todo: this.todo,
only: this.only,
results: this.results,
options: [
'autoend',
Expand All @@ -228,7 +230,8 @@ Base.prototype.inspect = function () {
'timeout',
'at',
'skip',
'todo'
'todo',
'only'
].reduce(function (set, k) {
if (this.options[k] !== undefined)
set[k] = this.options[k]
Expand Down
1 change: 1 addition & 0 deletions lib/clean-yaml-object.js
Expand Up @@ -61,6 +61,7 @@ function yamlFilter (propertyName, isRoot, source, target) {
propertyName === 'bail' ||
propertyName === 'grep' ||
propertyName === 'grepInvert' ||
propertyName === 'only' ||
propertyName === 'diagnostic' ||
propertyName === 'buffered' ||
propertyName === 'parent' ||
Expand Down
2 changes: 2 additions & 0 deletions lib/point.js
Expand Up @@ -31,6 +31,8 @@ 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
4 changes: 4 additions & 0 deletions lib/tap.js
Expand Up @@ -131,6 +131,10 @@ if (process.env.TAP_GREP_INVERT === '1') {
opt.grepInvert = true
}

if (process.env.TAP_ONLY === '1') {
opt.only = true
}

var tap = new TAP(opt)
module.exports = tap
tap.mocha = require('./mocha.js')
Expand Down

0 comments on commit 7e42a08

Please sign in to comment.