Files

Return to Package Diff Home.
Brought to you by Intrinsic.

Package Diff: tap @ 13.1.2 .. 13.1.11

bin/jack.js

@@ -539,7 +539,7 @@
description: 'Enable all Harmony flags in JavaScript tests',
}),
strict: flag({
- alias: '--node-arg=--strict',
+ alias: '--node-arg=--use-strict',
description: `Run JS tests in 'use strict' mode`,
}),

bin/run.js

@@ -23,6 +23,15 @@
const rimraf = require('rimraf').sync
const {Repl} = require('../lib/repl.js')
+/* istanbul ignore next */
+const debug = process.env.TAP_DEBUG === '1'
+ || /\btap\b/.test(process.env.NODE_DEBUG) ? (...args) => {
+ const {format} = require('util')
+ const prefix = `TAP ${process.pid} RUN: `
+ const msg = format(...args).trim()
+ console.error(prefix + msg.split('\n').join(`\n${prefix}`))
+ } : () => {}
+
const filesFromTest = exports.filesFromTest = (index, testFile) => {
const set = index.externalIds[testFile]
return !set ? null
@@ -64,18 +73,23 @@
}
const defaultFiles = options => new Promise((res, rej) => {
+ debug('try to get default files')
const findit = require('findit')
const good = strToRegExp(options['test-regex'])
const bad = strToRegExp(options['test-ignore'])
const fileFilter = f => {
- const parts = f.split(/\\|\//)
- return good.test(f) &&
+ f = f.replace(/\\/g, '/')
+ debug('fileFilter', f)
+ const parts = f.split('/')
+ const include = good.test(f) &&
!bad.test(f) &&
!parts.includes('node_modules') &&
!parts.includes('tap-snapshots') &&
!parts.includes('fixtures') &&
!parts.includes('.git') &&
!parts.includes('.hg')
+ debug('include?', f, include)
+ return include
}
const addFile = files => f => fileFilter(f) && files.push(f)
@@ -83,10 +97,12 @@
// search in any folder that isn't node_modules, .git, or tap-snapshots
// these can get pretty huge, so just walking them at all is costly
fs.readdir(process.cwd(), (er, entries) => {
+ debug('readdir cwd', er, entries)
Promise.all(entries.filter(entry =>
!/^(node_modules|tap-snapshots|.git|.hg|fixtures)$/.test(entry)
).map(entry => new Promise((res, rej) => {
fs.lstat(entry, (er, stat) => {
+ debug('lstat', entry, er, stat)
// It's pretty unusual to have a file in cwd you can't even stat
/* istanbul ignore next */
if (er)
@@ -106,16 +122,20 @@
})
const main = async options => {
+ debug('main', options)
+
if (require.main !== module)
- return
+ return debug('not main module, do not run tests')
const rc = parseRcFile(options.rcfile)
+ debug('rc options', rc)
for (let i in rc) {
if (!options._.explicit.has(i))
options[i] = rc[i]
}
const pj = parsePackageJson()
+ debug('package.json options', pj)
for (let i in pj) {
if (!options._.explicit.has(i))
options[i] = pj[i]
@@ -185,8 +205,10 @@
return runCoverageReportOnly(options)
try {
+ debug('try to get default files?', options._.length === 0, isTTY)
if (options._.length === 0 && isTTY)
options._.push.apply(options._, await defaultFiles(options))
+ debug('added default files', options._)
} /* istanbul ignore next */ catch (er) /* istanbul ignore next */ {
// This gets tested on Mac, but not Linux/travis, and is
// somewhat challenging to do in a cross-platform way.
@@ -195,6 +217,7 @@
}
options.files = globFiles(options._)
+ debug('after globbing', options.files)
if (options.files.length === 0 && !isTTY)
options.files.push('-')
@@ -203,6 +226,7 @@
mkdirp(options['output-dir'])
if (options.files.length === 1 && options.files[0] === '-') {
+ debug('do stdin only')
setupTapEnv(options)
stdinOnly(options)
return
@@ -222,8 +246,10 @@
/* istanbul ignore next */
const nycReporter = options =>
- options['coverage-report'] === 'html' ? 'lcov'
- : (options['coverage-report'] || 'text')
+ options['coverage-report'] === 'html' ? '--reporter=lcov'
+ : options['coverage-report'] === false ? '--silent'
+ : options['coverage-report'] === null ? '--reporter=text'
+ : `--reporter=${options['coverage-report']}`
/* istanbul ignore next */
const runNyc = (cmd, programArgs, options, spawnOpts) => {
@@ -238,7 +264,7 @@
'--functions=' + options.functions,
'--lines=' + options.lines,
'--statements=' + options.statements,
- '--reporter=' + reporter,
+ reporter,
'--extension=.js',
'--extension=.jsx',
'--extension=.mjs',
@@ -261,7 +287,7 @@
]
require(nycBin)
- if (reporter === 'lcov' && options.browser)
+ if (reporter === '--reporter=lcov' && options.browser)
process.on('exit', () => openHtmlCoverageReport(options))
}
@@ -290,6 +316,7 @@
/* istanbul ignore next */
const respawnWithCoverage = options => {
+ debug('respawn with coverage')
// If we have a coverage map, then include nothing by default here.
runNyc(options['coverage-map'] ? [
'--include=',
@@ -506,6 +533,7 @@
}
const runAllFiles = (options, tap) => {
+ debug('run all files')
let doStdin = false
let parallelOk = Object.create(null)
@@ -545,6 +573,7 @@
if (seen.has(file))
continue
+ debug('run file', file)
seen.add(file)
// Pick up stdin after all the other files are handled.
@@ -562,6 +591,7 @@
}
if (st.isDirectory()) {
+ debug('is a directory', file)
const dir = filterFiles(fs.readdirSync(file).map(f =>
file.replace(/[\/\\]+$/, '') + '/' + f), options, parallelOk)
options.files.splice(i, 1, ...dir)
@@ -578,6 +608,7 @@
opt.buffered = isParallelOk(parallelOk, file) !== false
if (file.match(/\.m?js$/)) {
+ debug('js file', file)
const args = [
...(options.esm ? ['-r', esm] : []),
...options['node-arg'],
@@ -586,6 +617,7 @@
]
tap.spawn(node, args, opt, file)
} else if (file.match(/\.tsx?$/)) {
+ debug('ts file', file)
const compilerOpts = JSON.stringify({
...JSON.parse(process.env.TS_NODE_COMPILER_OPTIONS || '{}'),
jsx: 'react'
@@ -602,6 +634,7 @@
]
tap.spawn(node, args, opt, file)
} else if (file.match(/\.jsx$/)) {
+ debug('jsx file', file)
const args = [
...(options['node-arg']),
jsx,
@@ -610,17 +643,23 @@
]
tap.spawn(node, args, opt, file)
} else if (file.match(/\.tap$/)) {
+ debug('tap file', file)
tap.spawn('cat', [file], opt, file)
- } else if (isexe.sync(options.files[i]))
+ } else if (isexe.sync(options.files[i])) {
+ debug('executable', file)
tap.spawn(options.files[i], options['test-arg'], opt, file)
}
}
+ }
if (doStdin)
tap.stdin()
+
+ debug('scheduled all files for execution')
}
const runTests = options => {
+ debug('run tests')
// At this point, we know we need to use the tap root,
// because there are 1 or more files to spawn.
const tap = require('../lib/tap.js')
@@ -666,6 +705,7 @@
}
tap.end()
+ debug('called tap.end()')
}
const parsePackageJson = () => {

lib/base.js

@@ -48,6 +48,8 @@
this.hook = new TapWrap(this)
this.hook.runInAsyncScope(() =>
this.hookDomain = new Domain((er, type) => {
+ if (!er || typeof er !== 'object')
+ er = { error: er }
er.tapCaught = type
this.threw(er)
}))
@@ -111,7 +113,7 @@
: /\btap\b/i.test(process.env.NODE_DEBUG || '')
if (doDebug)
- this.debug = debug
+ this.debug = debug(this.name)
}
passing () {
@@ -142,6 +144,8 @@
threw (er, extra, proxy) {
this.hook.emitDestroy()
this.hookDomain.destroy()
+ if (!er || typeof er !== 'object')
+ er = { error: er }
if (this.name && !proxy)
er.test = this.name
@@ -325,10 +329,10 @@
}
-function debug () {
- const prefix = 'TAP ' + process.pid + ' ' + this.name + ': '
- const msg = util.format.apply(util, arguments).trim()
- console.error(prefix + msg.split('\n').join('\n' + prefix))
+const debug = name => (...args) => {
+ const prefix = `TAP ${process.pid} ${name}: `
+ const msg = util.format(...args).trim()
+ console.error(prefix + msg.split('\n').join(`\n${prefix}`))
}
module.exports = Base

lib/tap.js

@@ -13,6 +13,8 @@
if (!processPatched)
throw er
else {
+ if (!er || typeof er !== 'object')
+ er = { error: er }
er.tapCaught = type
tap.threw(er)
}

lib/test.js

@@ -18,6 +18,7 @@
// block until its output is completed, dumping it all into the parser.
const {format, same, strict, match} = require('tcompare')
+const formatSnapshotDefault = obj => format(obj, { sort: true })
const Base = require('./base.js')
const Spawn = require('./spawn.js')
const Stdin = require('./stdin.js')
@@ -368,6 +369,8 @@
try {
return this.cb(this)
} catch (er) {
+ if (!er || typeof er !== 'object')
+ er = { error: er }
er.tapCaught = 'testFunctionThrow'
this.threw(er)
}
@@ -377,6 +380,8 @@
this.promise = ret
ret.tapAbortPromise = done
ret.then(end, er => {
+ if (!er || typeof er !== 'object')
+ er = { error: er }
er.tapCaught = 'returnedPromiseRejection'
done(er)
})
@@ -504,6 +509,8 @@
const otd = p.onTeardown
p.onTeardown = []
const threw = er => {
+ if (!er || typeof er !== 'object')
+ er = { error: er }
er.tapCaught = 'teardown'
delete p.options.time
p.threw(er)
@@ -516,6 +523,8 @@
p.onTeardown = otd.slice(i + 1)
this.queue.unshift(['emitSubTeardown', p])
return ret.then(() => this.emitSubTeardown(p), er => {
+ if (!er || typeof er !== 'object')
+ er = { error: er }
er.tapCaught = 'teardown'
throw er
})
@@ -823,6 +832,9 @@
return
}
+ if (!er || typeof er !== 'object')
+ er = { error: er }
+
if (this[_expectUncaught].length && er.tapCaught === 'uncaughtException') {
const [wanted, message, extra] = this[_expectUncaught].shift()
const actual = isRegExp(wanted) ? er.message : er
@@ -1221,7 +1233,7 @@
// use notOk because snap doesn't return a truthy value
const m = this.fullname + ' > ' + message
if (typeof found !== 'string')
- found = (this.formatSnapshot || format)(found)
+ found = (this.formatSnapshot || formatSnapshotDefault)(found)
found = this.cleanSnapshot(found)
@@ -1531,7 +1543,7 @@
const er = w.value
// 'name' is a getter.
- if (er.name) {
+ if (er && er.name) {
Object.defineProperty(er, 'name', {
value: er.name + '',
enumerable: true,
@@ -1540,7 +1552,7 @@
})
}
- const actual = isRegExp(wanted) ? er.message : er
+ const actual = isRegExp(wanted) && er ? er.message : er
return wanted ? this.match(actual, wanted, message, extra)
: this.pass(message, extra)
})

package.json

@@ -1,6 +1,6 @@
{
"name": "tap",
- "version": "13.1.2",
+ "version": "13.1.11",
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
"description": "A Test-Anything-Protocol library",
"homepage": "http://node-tap.org/",
@@ -19,17 +19,17 @@
"bind-obj-methods": "^2.0.0",
"browser-process-hrtime": "^1.0.0",
"capture-stack-trace": "^1.0.0",
- "chokidar": "^2.1.5",
+ "chokidar": "^3.0.0",
"color-support": "^1.1.0",
"coveralls": "^3.0.3",
"diff": "^4.0.1",
"domain-browser": "^1.2.0",
- "esm": "^3.2.22",
+ "esm": "^3.2.25",
"findit": "^2.0.0",
"foreground-child": "^1.3.3",
"fs-exists-cached": "^1.0.0",
"function-loop": "^1.0.2",
- "glob": "^7.1.3",
+ "glob": "^7.1.4",
"import-jsx": "^2.0.0",
"isexe": "^2.0.0",
"istanbul-lib-processinfo": "^1.0.0",
@@ -47,14 +47,14 @@
"tap-mocha-reporter": "^4.0.1",
"tap-parser": "^9.3.2",
"tap-yaml": "^1.0.0",
- "tcompare": "^2.2.0",
+ "tcompare": "^2.3.0",
"treport": "^0.3.0",
"trivial-deferred": "^1.0.1",
"ts-node": "^8.1.0",
- "typescript": "^3.4.3",
+ "typescript": "^3.4.5",
"which": "^1.3.1",
"write-file-atomic": "^2.4.2",
- "yaml": "^1.5.0",
+ "yaml": "^1.5.1",
"yapool": "^1.0.0"
},
"keywords": [
@@ -74,7 +74,7 @@
"t": "node bin/run.js test -J -sfails.txt",
"preversion": "npm test",
"postversion": "npm publish",
- "postpublish": "git push origin --all; git push origin --tags"
+ "postpublish": "git push origin --follow-tags"
},
"tap": {
"esm": false,