Skip to content

Commit

Permalink
Exit with non-zero if there is any parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
aghassemi committed Dec 13, 2017
1 parent e388546 commit 268cbee
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function converter(options) {
r.failures.forEach(function(fail) {
if (fail.tapError) {
var err = new Error('TAP parse error: ' + fail.tapError);
exitCode = 1;
outStream.emit('error', err);
}
});
Expand All @@ -100,8 +101,8 @@ function converter(options) {

var xmlString = serialize(testSuites);
outStream.push(xmlString + '\n');
outStream.emit('end');
result.exitCode = exitCode;
outStream.emit('end');
});

var result = duplexer(tapParser, outStream);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tap-xunit",
"version": "1.7.0",
"version": "2.0.0",
"description": "TAP to xUnit XML converter.",
"main": "lib/converter.js",
"bin": {
Expand Down
9 changes: 9 additions & 0 deletions test/bad/upstream-failure
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Error: beep
at [eval]:1:7
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at Object.runInThisContext (vm.js:139:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:635:30)
at evalScript (bootstrap_node.js:462:27)
at startup (bootstrap_node.js:163:9)
at bootstrap_node.js:608:3
1 change: 1 addition & 0 deletions test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function runBadInputTests() {
});
xUnitStream.on('end', function() {
assert.ok(numParseErrors > 0, 'had ' + numParseErrors + ' parse errors');
assert.equals(tapToxUnitConverter.exitCode, 1, 'exitCode match');
assert.end();
});
});
Expand Down

0 comments on commit 268cbee

Please sign in to comment.