This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Upgrade to tap v1

node-tap v1.0.0 introduces a bunch of consistency and functionality
upgrades in the test experience, along with a suite of pretty reporters
ported from Mocha's default set.

The semantic change that most dramatically affects npm's use (and will
likely cause a bit of wailing and gnashing of teeth among other tap
users) is that 't.test(...)' is now executed immediately, as long as
there is not another test currently in progress.  Indeed, everything
that the Test class does, it does right away at the moment of calling
the function, never using nextTick to defer anything.

This means that, for example, a 'console.log' in the middle of a bunch
of tests will print its output in the context of the associated test
output, instead of having the console.log happen first, and then all of
the TAP data deferred until later.

For new node-tap users, this has been a significant stumbling block.
However, it is a breaking change, and requires that test fixture objects
have to be set up in advance of being used by a test, since it's no
longer a guarantee that everything at the top (module) level will be
executed before any test blocks.

Also, the statSync in config-meta was changed to an lstatSync, since I
have been developing with tap link-installed, and the directory crawling
was sending my system into a tailspin otherwise.  It seems like this
would happen any time one of the npm deps was link-installed, so it's
probably a good idea anyway.
  • Loading branch information...
isaacs authored and othiym23 committed May 3, 2015
1 parent 8b9469a commit e40e8095d2bc9fa4eb8f01aa22067e0068fa8a54
View
@@ -178,7 +178,7 @@
"npm-registry-mock": "~1.0.0",
"require-inject": "~1.2.0",
"sprintf-js": "~1.0.2",
"tap": "~0.7.1"
"tap": "^1.0.0-beta.3"
},
"scripts": {
"test-legacy": "node ./test/run.js",
@@ -16,6 +16,20 @@ var daemon
var daemonPID
var git
var pjParent = JSON.stringify({
name: 'parent',
version: '1.2.3',
dependencies: {
child: 'git://localhost:1233/child.git'
}
}, null, 2) + '\n'
var pjChild = JSON.stringify({
name: 'child',
version: '1.0.3'
}, null, 2) + '\n'
test('setup', function (t) {
bootstrap()
setup(function (er, r) {
@@ -53,19 +67,6 @@ test('clean', function (t) {
process.kill(daemonPID)
})
var pjParent = JSON.stringify({
name: 'parent',
version: '1.2.3',
dependencies: {
child: 'git://localhost:1233/child.git'
}
}, null, 2) + '\n'
var pjChild = JSON.stringify({
name: 'child',
version: '1.0.3'
}, null, 2) + '\n'
function bootstrap () {
rimraf.sync(pkg)
mkdirp.sync(pkg)
@@ -16,6 +16,11 @@ var repo = resolve(__dirname, 'add-remote-git-file-repo')
var git
var cloneURL = 'git+file://' + resolve(pkg, 'child.git')
var pjChild = JSON.stringify({
name: 'child',
version: '1.0.3'
}, null, 2) + '\n'
test('setup', function (t) {
bootstrap()
setup(function (er, r) {
@@ -45,11 +50,6 @@ test('clean', function (t) {
t.end()
})
var pjChild = JSON.stringify({
name: 'child',
version: '1.0.3'
}, null, 2) + '\n'
function bootstrap () {
cleanup()
mkdirp.sync(pkg)
@@ -16,6 +16,19 @@ var daemon
var daemonPID
var git
var pjParent = JSON.stringify({
name: 'parent',
version: '1.2.3',
dependencies: {
'child': 'git://localhost:1235/child.git#master'
}
}, null, 2) + '\n'
var pjChild = JSON.stringify({
name: 'child',
version: '1.0.3'
}, null, 2) + '\n'
test('setup', function (t) {
bootstrap()
setup(function (er, r) {
@@ -88,19 +101,6 @@ test('clean', function (t) {
process.kill(daemonPID)
})
var pjParent = JSON.stringify({
name: 'parent',
version: '1.2.3',
dependencies: {
'child': 'git://localhost:1235/child.git#master'
}
}, null, 2) + '\n'
var pjChild = JSON.stringify({
name: 'child',
version: '1.0.3'
}, null, 2) + '\n'
function bootstrap () {
mkdirp.sync(pkg)
fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
View
@@ -16,6 +16,19 @@ var daemon
var daemonPID
var git
var pjParent = JSON.stringify({
name: 'parent',
version: '1.2.3',
dependencies: {
child: 'git://localhost:1234/child.git'
}
}, null, 2) + '\n'
var pjChild = JSON.stringify({
name: 'child',
version: '1.0.3'
}, null, 2) + '\n'
test('setup', function (t) {
bootstrap()
setup(function (er, r) {
@@ -47,19 +60,6 @@ test('clean', function (t) {
process.kill(daemonPID)
})
var pjParent = JSON.stringify({
name: 'parent',
version: '1.2.3',
dependencies: {
child: 'git://localhost:1234/child.git'
}
}, null, 2) + '\n'
var pjChild = JSON.stringify({
name: 'child',
version: '1.0.3'
}, null, 2) + '\n'
function bootstrap () {
mkdirp.sync(pkg)
fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
View
@@ -3,7 +3,7 @@ var test = require("tap").test
var common = require("../common-tap.js")
var opts = { cwd: __dirname }
var binDir = "../../node_modules/.bin"
var fixture = path.resolve(binDir)
var fixture = path.resolve(__dirname, binDir)
test('npm bin', function (t) {
common.npm(["bin"], opts, function (err, code, stdout, stderr) {
@@ -13,6 +13,22 @@ var dir = path.resolve(__dirname, 'bundleddependencies')
var pkg = path.resolve(dir, 'pkg-with-bundled')
var dep = path.resolve(dir, 'a-bundled-dep')
var pj = JSON.stringify({
name: 'pkg-with-bundled',
version: '1.0.0',
dependencies: {
'a-bundled-dep': 'file:../a-bundled-dep'
},
bundledDependencies: {
'a-bundled-dep': 'file:../a-bundled-dep'
}
}, null, 2) + '\n'
var pjDep = JSON.stringify({
name: 'a-bundled-dep',
version: '2.0.0'
}, null, 2) + '\n'
test('setup', function (t) {
bootstrap()
t.end()
@@ -45,22 +61,6 @@ test('cleanup', function (t) {
t.end()
})
var pj = JSON.stringify({
name: 'pkg-with-bundled',
version: '1.0.0',
dependencies: {
'a-bundled-dep': 'file:../a-bundled-dep'
},
bundledDependencies: {
'a-bundled-dep': 'file:../a-bundled-dep'
}
}, null, 2) + '\n'
var pjDep = JSON.stringify({
name: 'a-bundled-dep',
version: '2.0.0'
}, null, 2) + '\n'
function bootstrap () {
mkdirp.sync(dir)
View
@@ -37,7 +37,7 @@ test("get files", function (t) {
})
files.forEach(function (f) {
try {
var s = fs.statSync(f)
var s = fs.lstatSync(f)
} catch (er) {
return
}
View
@@ -11,40 +11,6 @@ var modules = join(pkg, 'node_modules')
var EXEC_OPTS = { cwd: pkg }
test('setup', function (t) {
setup()
t.end()
})
// we like the cars
function ltrimm (l) { return l.trim() }
test('dedupe finds the common scoped modules and moves it up one level', function (t) {
common.npm(
[
'find-dupes' // I actually found a use for this command!
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
t.ifError(err, 'successful dry run against fake install')
t.notOk(code, 'npm ran without issue')
t.notOk(stderr, 'npm printed no errors')
t.same(
stdout.trim().split('\n').map(ltrimm),
[prolog].concat(body).map(ltrimm),
'got expected output'
)
t.end()
}
)
})
test('cleanup', function (t) {
cleanup()
t.end()
})
var prolog = 'dedupe@0.0.0 ' + pkg
var body = function () {/*
├─┬ first@1.0.0
@@ -95,6 +61,41 @@ var secondUnique = {
'version': '1.2.0'
}
test('setup', function (t) {
setup()
t.end()
})
// we like the cars
function ltrimm (l) { return l.trim() }
test('dedupe finds the common scoped modules and moves it up one level', function (t) {
common.npm(
[
'find-dupes' // I actually found a use for this command!
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
t.ifError(err, 'successful dry run against fake install')
t.notOk(code, 'npm ran without issue')
t.notOk(stderr, 'npm printed no errors')
t.same(
stdout.trim().split('\n').map(ltrimm),
[prolog].concat(body).map(ltrimm),
'got expected output'
)
t.end()
}
)
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup (cb) {
cleanup()
@@ -13,6 +13,14 @@ var EXEC_OPTS = {
cwd : pkg
}
var fixture = {
name: "@test/whoops",
version: "1.0.0",
scripts: {
postinstall: "echo \"nope\" && exit 1"
}
}
test("setup", function (t) {
cleanup()
setup()
@@ -40,14 +48,6 @@ test("cleanup", function (t) {
})
var fixture = {
name: "@test/whoops",
version: "1.0.0",
scripts: {
postinstall: "echo \"nope\" && exit 1"
}
}
function cleanup () {
rimraf.sync(pkg)
rimraf.sync(dep)
@@ -15,6 +15,17 @@ var EXEC_OPTS = {
cwd : pkg
}
var index = "module.exports = function () { console.log('whoop whoop') }"
var fixture = {
name: "@test/linked",
version: "1.0.0",
bin: {
linked: "./index.js"
}
}
test("setup", function (t) {
cleanup()
setup()
@@ -72,17 +83,6 @@ test("cleanup", function (t) {
t.end()
})
var index = "module.exports = function () { console.log('whoop whoop') }"
var fixture = {
name: "@test/linked",
version: "1.0.0",
bin: {
linked: "./index.js"
}
}
function verify (t, stdout) {
var binPath = resolve(lnk, "bin", "linked")
var pkgPath = resolve(lnk, "lib", "node_modules", "@test", "linked")
Oops, something went wrong.

0 comments on commit e40e809

Please sign in to comment.