-
-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[New] add
--no-only
flag/NODE_TAPE_NO_ONLY_TEST
- Loading branch information
Showing
7 changed files
with
192 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
'use strict'; | ||
|
||
var tap = require('tap'); | ||
var path = require('path'); | ||
var spawn = require('child_process').spawn; | ||
var concat = require('concat-stream'); | ||
|
||
var stripFullStack = require('./common').stripFullStack; | ||
|
||
var tapeBin = path.join(process.cwd(), 'bin/tape'); | ||
|
||
tap.test( | ||
'Should throw error when --no-only is passed via cli and there is a .only test', | ||
{ todo: process.versions.node.match(/0\.10\.\d+/) ? 'Fails on node 0.10' : false }, | ||
function (tt) { | ||
tt.plan(2); | ||
|
||
var testStderr = function (rows) { | ||
tt.ok((/Error: `only` tests are prohibited\n/).test(stripFullStack(rows.toString('utf8')).join('\n'))); | ||
}; | ||
|
||
var ps = spawn(tapeBin, ['**/*.js', '--no-only' ], { cwd: path.join(__dirname, 'no_only') }); | ||
ps.stderr.pipe(concat(testStderr)); | ||
ps.on('exit', function (code) { | ||
tt.equal(code, 1); | ||
}); | ||
} | ||
); | ||
|
||
tap.test( | ||
'Should throw error when NODE_TAPE_NO_ONLY_TEST is passed via envs and there is an .only test', | ||
{ todo: process.versions.node.match(/0\.10\.\d+/) ? 'Fails on node 0.10' : false }, | ||
function (tt) { | ||
tt.plan(2); | ||
|
||
var testStderr = function (rows) { | ||
tt.ok((/Error: `only` tests are prohibited\n/).test(stripFullStack(rows.toString('utf8')).join('\n'))); | ||
}; | ||
var ps = spawn(tapeBin, ['**/*.js'], { | ||
cwd: path.join(__dirname, 'no_only'), | ||
env: { NODE_TAPE_NO_ONLY_TEST: true } | ||
}); | ||
ps.stderr.pipe(concat(testStderr)); | ||
ps.on('exit', function (code) { | ||
tt.equal(code, 1); | ||
}); | ||
} | ||
); | ||
|
||
tap.test( | ||
'Should override NODE_TAPE_NO_ONLY_TEST env if --no-only is passed from cli', | ||
{ todo: process.versions.node.match(/0\.10\.\d+/) ? 'Fails on node 0.10' : false }, | ||
function (tt) { | ||
tt.plan(2); | ||
|
||
var testStderr = function (rows) { | ||
tt.ok((/Error: `only` tests are prohibited\n/).test(stripFullStack(rows.toString('utf8')).join('\n'))); | ||
}; | ||
|
||
var ps = spawn(tapeBin, ['**/*.js', '--no-only' ], { | ||
cwd: path.join(__dirname, 'no_only'), | ||
env: { NODE_TAPE_NO_ONLY_TEST: false } | ||
}); | ||
ps.stderr.pipe(concat(testStderr)); | ||
ps.on('exit', function (code) { | ||
tt.equal(code, 1); | ||
}); | ||
} | ||
); | ||
|
||
tap.test('Should run successfully if there is no only test', function (tt) { | ||
tt.plan(2); | ||
|
||
var testStdout = function (rows) { | ||
tt.same(stripFullStack(rows.toString('utf8')), [ | ||
'TAP version 13', | ||
'# should pass', | ||
'ok 1 should be truthy', | ||
'', | ||
'1..1', | ||
'# tests 1', | ||
'# pass 1', | ||
'', | ||
'# ok', | ||
'', | ||
'' | ||
]); | ||
}; | ||
|
||
var ps = spawn(tapeBin, ['**/test-a.js', '--no-only'], { cwd: path.join(__dirname, 'no_only') }); | ||
ps.stdout.pipe(concat(testStdout)); | ||
ps.on('exit', function (code) { | ||
tt.equal(code, 0); | ||
}); | ||
}); | ||
|
||
tap.test('Should run successfully if there is an only test and no --no-only flag', function (tt) { | ||
tt.plan(2); | ||
|
||
var testStdout = function (rows) { | ||
tt.same(stripFullStack(rows.toString('utf8')), [ | ||
'TAP version 13', | ||
'# should pass again', | ||
'ok 1 should be truthy', | ||
'', | ||
'1..1', | ||
'# tests 1', | ||
'# pass 1', | ||
'', | ||
'# ok', | ||
'', | ||
'' | ||
]); | ||
}; | ||
|
||
var ps = spawn(tapeBin, ['**/test-b.js'], { cwd: path.join(__dirname, 'no_only') }); | ||
ps.stdout.pipe(concat(testStdout)); | ||
ps.on('exit', function (code) { | ||
tt.equal(code, 0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
var tape = require('../../'); | ||
|
||
tape.test('should pass', function (t) { | ||
t.plan(1); | ||
t.ok(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
var tape = require('../../'); | ||
|
||
tape.test('should pass', function (t) { | ||
t.plan(1); | ||
t.ok(1); | ||
}); | ||
|
||
tape.test.only('should pass again', function (t) { | ||
t.plan(1); | ||
t.ok(1); | ||
}); | ||
|