-
-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add -o --output-file option to store raw TAP
Fix #352 Needed to refactor the process hijacking stuff a little bit, otherwise the pipe to the output file would conflict with piping to the stdout reporter (or just stdout directly).
- Loading branch information
Showing
5 changed files
with
73 additions
and
9 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,43 @@ | ||
var t = require('../') | ||
var spawn = require('child_process').spawn | ||
var run = require.resolve('../bin/run.js') | ||
var fs = require('fs') | ||
var node = process.execPath | ||
var ok = require.resolve('./test/ok.js') | ||
|
||
var args = [ | ||
'-ofile.txt', | ||
'-Co file.txt', | ||
'-bCco=file.txt', | ||
'-o=file.txt', | ||
'--output-file=file.txt', | ||
'--output-file file.txt' | ||
] | ||
|
||
args.forEach(function (arg) { | ||
t.test(arg, function (t) { | ||
try { fs.unlinkSync('file.txt') } catch (er) {} | ||
arg = arg.split(' ') | ||
var child = spawn(node, [run, '-c', ok].concat(arg)) | ||
var gotStdout = false | ||
child.stdout.on('data', function (c) { | ||
gotStdout = true | ||
}) | ||
child.stderr.on('data', function (c) { | ||
throw new Error('should not write to stderr') | ||
}) | ||
child.on('close', function (code, sig) { | ||
t.equal(code, 0) | ||
t.equal(sig, null) | ||
t.ok(gotStdout, 'got standard output') | ||
t.match(fs.readFileSync('file.txt', 'utf8'), /^TAP version 13\n/) | ||
t.end() | ||
}) | ||
}) | ||
}) | ||
|
||
t.test('cleanup', function (t) { | ||
try { fs.unlinkSync('file.txt') } catch (er) {} | ||
t.done() | ||
}) | ||
|