Commit 8cd236c4 authored by Bastien ROUCARIÈS's avatar Bastien ROUCARIÈS

New upstream version 6.0.1

parent d7828560

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -6,6 +6,14 @@ var util = require('util')
var args = process.argv.slice(2)
var json = null
var bail = false
var preserveWhitespace = true
var omitVersion = false
function version () {
console.log(require('../package.json').version)
process.exit(0)
}
args.forEach(function (arg, i) {
if (arg === '-j') {
......@@ -16,31 +24,55 @@ args.forEach(function (arg, i) {
json = +m[1] || args[i + 1] || 2
}
if (arg === '-t' || arg === '--tap')
if (arg === '-v' || arg === '--version')
version()
else if (arg === '-o' || arg === '--omit-version')
omitVersion = true
else if (arg === '-w' || arg === '--ignore-all-whitespace')
preserveWhitespace = false
else if (arg === '-b' || arg === '--bail')
bail = true
else if (arg === '-t' || arg === '--tap')
json = 'tap'
if (arg === '-h' || arg === '--help')
else if (arg === '-l' || arg === '--lines')
json = 'lines'
else if (arg === '-h' || arg === '--help')
usage()
else
console.error('Unrecognized arg: %j', arg)
if (arg === '-v' || arg === '--version')
console.log(require('../package.json').version)
})
function usage () {
console.log(function () {/*
Usage:
tap-parser [-j [<indent>] | --json[=indent] | -t | --tap]
tap-parser <options>
Parses TAP data from stdin, and outputs the parsed result
in the format specified by the options. Default output is
uses node's `util.format()` method.
Parses TAP data from stdin, and outputs an object representing
the data found in the TAP stream to stdout.
Options:
If there are any failures in the TAP stream, then exits with a
non-zero status code.
-j [<indent>] | --json[=indent]
Output event data as JSON with the specified indentation (default=2)
Data is output by default using node's `util.format()` method, but
JSON can be specified using the `-j` or `--json` flag with a number
of spaces to use as the indent (default=2).
-t | --tap
Output data as reconstituted TAP based on parsed results
If you pass -t or --tap as an argument, then the output will be a
re-imagined synthesized purified idealized manufactured TAP stream,
rather than JSON or util.format.
-l | --lines
Output each parsed line as it is recognized by the parser
-b | --bail
Emit a `Bail out!` at the first failed test point encountered
-w | --ignore-all-whitespace
Skip over blank lines outside of YAML blocks
-o | --omit-version
Ignore the `TAP version 13` line at the start of tests
*/}.toString().split('\n').slice(1, -1).join('\n'))
if (!process.stdin.isTTY)
......@@ -54,7 +86,9 @@ function tapFormat (msg, indent) {
return indent + msg.map(function (item) {
switch (item[0]) {
case 'child':
return tapFormat(item[1], ' ')
var comment = item[1][0]
var child = item[1].slice(1)
return tapFormat([comment], '') + tapFormat(child, ' ')
case 'version':
return 'TAP version ' + item[1] + '\n'
......@@ -75,12 +109,12 @@ function tapFormat (msg, indent) {
case 'assert':
var res = item[1]
return (res.ok ? '' : 'not ') + 'ok ' + res.id +
(res.name ? ' - ' + res.name : '') +
(res.name ? ' - ' + res.name.replace(/ \{$/, '') : '') +
(res.skip ? ' # SKIP' +
(res.skip === true ? '' : ' ' + res.skip) : '') +
(res.todo ? ' # TODO' +
(res.todo === true ? '' : ' ' + res.todo) : '') +
(res.time ? ' # time=' + res.time + 's' : '') +
(res.time ? ' # time=' + res.time + 'ms' : '') +
'\n' +
(res.diag ?
' ---\n ' +
......@@ -104,12 +138,23 @@ function format (msg) {
return util.inspect(events, null, Infinity)
}
var parser = new Parser()
var options = {
bail: bail,
preserveWhitespace: preserveWhitespace,
omitVersion: omitVersion
}
var parser = new Parser(options)
var events = etoa(parser, [ 'pipe', 'unpipe', 'prefinish', 'finish', 'line' ])
process.stdin.pipe(parser)
process.on('exit', function () {
console.log(format(events))
if (!parser.ok)
process.exit(1)
})
if (json === 'lines')
parser.on('line', function (l) {
process.stdout.write(l)
})
else
process.on('exit', function () {
console.log(format(events))
if (!parser.ok)
process.exit(1)
})
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "tap-parser",
"version": "3.0.3",
"version": "6.0.1",
"description": "parse the test anything protocol",
"main": "index.js",
"bin": {
......@@ -8,15 +8,19 @@
},
"dependencies": {
"events-to-array": "^1.0.1",
"js-yaml": "^3.2.7"
"js-yaml": "^3.2.7",
"minipass": "^2.2.0"
},
"devDependencies": {
"glob": "^7.0.5",
"tap": "^7.0.0"
"tap": "^10.3.3"
},
"scripts": {
"test": "tap test/*.js --100",
"regen-fixtures": "node scripts/generate-test.js test/fixtures/*.tap"
"test": "tap test/*.js --100 -J",
"regen-fixtures": "node scripts/generate-test.js test/fixtures/*.tap",
"preversion": "npm test",
"postversion": "npm publish",
"postpublish": "git push origin --all; git push origin --tags"
},
"testling": {
"files": "test/*.js",
......@@ -46,9 +50,7 @@
"url": "http://substack.net"
},
"license": "MIT",
"optionalDependencies": {
"readable-stream": "^2"
},
"optionalDependencies": {},
"files": [
"index.js",
"bin/cmd.js",
......
......@@ -11,8 +11,8 @@ parse the [test anything protocol](http://testanything.org/)
# example
``` js
var parser = require('tap-parser');
var p = parser(function (results) {
var Parser = require('tap-parser');
var p = new Parser(function (results) {
console.dir(results);
});
......@@ -51,26 +51,40 @@ This package also has a `tap-parser` command.
```
Usage:
tap-parser [-j [<indent>] | --json[=indent]]
tap-parser <options>
Parses TAP data from stdin, and outputs an object representing
the data found in the TAP stream to stdout.
Parses TAP data from stdin, and outputs the parsed result
in the format specified by the options. Default output is
uses node's `util.format()` method.
If there are any failures in the TAP stream, then exits with a
non-zero status code.
Options:
Data is output by default using node's `util.format()` method, but
JSON can be specified using the `-j` or `--json` flag with a number
of spaces to use as the indent (default=2).
-j [<indent>] | --json[=indent]
Output event data as JSON with the specified indentation (default=2)
-t | --tap
Output data as reconstituted TAP based on parsed results
-l | --lines
Output each parsed line as it is recognized by the parser
-b | --bail
Emit a `Bail out!` at the first failed test point encountered