diff --git a/lib/converter.js b/lib/converter.js index 3a09a2b..a203dde 100644 --- a/lib/converter.js +++ b/lib/converter.js @@ -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. @@ -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) { @@ -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; } diff --git a/package.json b/package.json index 6697fe5..433a392 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/test/runner.js b/test/runner.js index 9bd9dd7..a4afc0c 100644 --- a/test/runner.js +++ b/test/runner.js @@ -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); @@ -82,5 +81,5 @@ function runBadInputTests() { assert.end(); }); }); - } + }); }