Skip to content

Commit

Permalink
fail if no plan line present
Browse files Browse the repository at this point in the history
  • Loading branch information
aghassemi committed Dec 14, 2017
1 parent ebe8283 commit 42b8017
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 7 additions & 2 deletions lib/converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function converter(options) {
var testCase;
var noMoreTests = false;
var exitCode = 0;
var planPresent = false;

tapParser.on('comment', function(comment) {
// comment specifies boundaries between testsuites, unless feature disabled.
Expand All @@ -49,6 +50,10 @@ function converter(options) {
testCase = newTest(comment);
});

tapParser.on('plan', function() {
planPresent = true;
});

tapParser.on('assert', function(assert) {
// no test name was given, so all asserts go in a single test
if (!testCase) {
Expand Down Expand Up @@ -99,11 +104,11 @@ function converter(options) {
});
});

if (tapParser.sawValidTap) {
if (tapParser.sawValidTap && planPresent) {
var xmlString = serialize(testSuites);
outStream.push(xmlString + '\n');
} else {
// Fail no valid tap found (normally means no plan line present)
// Fail, no valid tap found (normally means no plan line present)
// Note that is a less strict check than TapParser's strict mode.
exitCode = 1;
}
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": "2.1.0",
"version": "2.2.0",
"description": "TAP to xUnit XML converter.",
"main": "lib/converter.js",
"bin": {
Expand Down
5 changes: 2 additions & 3 deletions test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ function runBadInputTests() {
var BAD_INPUT_DIR = 'test/bad';

var testFiles = fs.readdirSync(BAD_INPUT_DIR);
for (var i = 0; i < testFiles.length; i++) {
var filename = testFiles[i];
testFiles.forEach(function(filename) {
test('parse error: ' + filename, function(assert) {
var badInputFilePath = path.join(BAD_INPUT_DIR, filename);
var inputStream = fs.createReadStream(badInputFilePath, FILE_READ_OPTS);
Expand All @@ -82,5 +81,5 @@ function runBadInputTests() {
assert.end();
});
});
}
});
}

0 comments on commit 42b8017

Please sign in to comment.