tap-parser
Advanced tools
Comparing version 4.1.0 to 4.2.0
76
index.js
@@ -99,2 +99,7 @@ // Transforms a stream of TAP into a stream of result objects | ||
if (/\{$/.test(name)) { | ||
name = name.slice(0, -1).trim() | ||
this.buffered = true | ||
} | ||
if (name) | ||
@@ -169,2 +174,4 @@ this.name = name.trim() | ||
this.emitResult() | ||
if (this.bailedOut) | ||
return | ||
@@ -180,2 +187,3 @@ var res = new Result(testPoint, this.count) | ||
res.tapError = 'id greater than plan end' | ||
res.plan = { start: this.planStart, end: this.planEnd } | ||
this.tapError(res) | ||
@@ -192,2 +200,4 @@ } | ||
this.ok = this.ok && res.ok | ||
// hold onto it, because we might get yamlish diagnostics | ||
@@ -227,3 +237,20 @@ this.current = res | ||
this.emitResult() | ||
if (this.bailedOut) | ||
return | ||
// 1..0 is a special case. Otherwise, end must be >= start | ||
if (end < start && end !== 0 && start !== 1) { | ||
if (this.strict) | ||
this.tapError({ | ||
tapError: 'plan end cannot be less than plan start', | ||
plan: { | ||
start: start, | ||
end: end | ||
} | ||
}) | ||
else | ||
this.nonTap(line) | ||
return | ||
} | ||
this.planStart = start | ||
@@ -254,2 +281,4 @@ this.planEnd = end | ||
this.emitResult() | ||
if (this.bailedOut) | ||
return | ||
this.nonTap(yamlGarbage) | ||
@@ -281,3 +310,16 @@ } | ||
this.current.diag = diags | ||
this.emitResult() | ||
// we still don't emit the result here yet, to support: | ||
// | ||
// ok 1 - child | ||
// --- | ||
// some: diags | ||
// ... | ||
// { | ||
// 1..1 | ||
// ok | ||
// } | ||
// unless it's failure, and we're going to bail anyway. | ||
if (!this.current.ok && this.bail) { | ||
this.emitResult() | ||
} | ||
} | ||
@@ -351,4 +393,4 @@ | ||
this.syntheticPlan = true | ||
this.emit('line', '1..0\n') | ||
this.plan(1, 0, '', '1..0\n') | ||
this.emit('line', '1..0 # no tests found\n') | ||
this.plan(1, 0, 'no tests found', '1..0 # no tests found\n') | ||
skipAll = true | ||
@@ -413,2 +455,4 @@ } else { | ||
this.emitResult() | ||
if (this.bailedOut) | ||
return | ||
// only the 'strict' pragma is currently relevant | ||
@@ -455,2 +499,5 @@ if (key === 'strict') { | ||
Parser.prototype.emitResult = function () { | ||
if (this.bailedOut) | ||
return | ||
this.endChild() | ||
@@ -498,3 +545,3 @@ this.resetYamlish() | ||
Parser.prototype.startChild = function (line) { | ||
var maybeBuffered = this.current && this.current.name && this.current.name.substr(-1) === '{' | ||
var maybeBuffered = this.current && this.current.buffered | ||
var unindentStream = !maybeBuffered && this.maybeChild | ||
@@ -514,2 +561,5 @@ var indentStream = !maybeBuffered && !unindentStream && | ||
if (this.bailedOut) | ||
return | ||
this.child = new Parser({ | ||
@@ -549,4 +599,3 @@ bail: this.bail, | ||
} else if (maybeBuffered) { | ||
var n = this.current.name.trim().replace(/{$/, '').trim() | ||
subtestComment = '# Subtest: ' + n + '\n' | ||
subtestComment = '# Subtest: ' + this.current.name + '\n' | ||
} else { | ||
@@ -609,3 +658,4 @@ subtestComment = this.maybeChild || '# Subtest: (anonymous)\n' | ||
// this is a line we are processing, so emit it | ||
if (this.preserveWhitespace || line.trim() || this.yind) | ||
var validLine = this.preserveWhitespace || line.trim() || this.yind | ||
if (validLine) | ||
this.emit('line', line) | ||
@@ -618,3 +668,2 @@ | ||
if (this.child && this.child.buffered && line === '}\n') { | ||
this.current.name = this.current.name.replace(/{$/, '').trim() | ||
this.emitResult() | ||
@@ -624,2 +673,11 @@ return | ||
// buffered subtest with diagnostics | ||
if (this.current && line === '{\n' && | ||
!this.current.buffered && | ||
!this.child) { | ||
this.current.buffered = true | ||
return | ||
} | ||
// now we know it's not indented, so if it's either valid tap | ||
@@ -756,3 +814,3 @@ // or garbage. Get the type of line. | ||
if (this.maybeChild || | ||
this.current && this.current.name && this.current.name.substr(-1) === '{' || | ||
this.current && this.current.buffered || | ||
lineTypes.subtestIndent.test(line)) { | ||
@@ -759,0 +817,0 @@ this.startChild(line) |
{ | ||
"name": "tap-parser", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "parse the test anything protocol", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39707
846
406