Skip to content

Commit

Permalink
reporter: update to use TAP 13
Browse files Browse the repository at this point in the history
Use yamlish instead of # to match community:
nodejs/node#9262
  • Loading branch information
George Adams committed Nov 21, 2016
1 parent a7346e3 commit e1deaf4
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 6 deletions.
6 changes: 5 additions & 1 deletion lib/reporter/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ function generateTest(mod, count) {
mod.error = mod.error.message;
}
var error = mod.error ? [directive, mod.error].join(' ') : '';
var output = mod.testOutput ? '\n' + util.sanitizeOutput(mod.testOutput, '# ') : '';
if (mod.testOutput && mod.testOutput.length > 0) {
var output = '\n ---\n' + util.sanitizeOutput(mod.testOutput, ' #') + '\n ...';
} else {
output = '';
}
return [result, count + 1, '-', mod.name, 'v' + mod.version + error + output].join(' ');
}

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
"nyc": "^8.4.0",
"opener": "^1.4.1",
"rewire": "^2.4.0",
"tap": "^8.0.0"
"tap": "^8.0.0",
"tap-parser": "^3.0.3",
"into-stream": "^3.0.0"
}
}
19 changes: 19 additions & 0 deletions test/fixtures/tap-parser.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"count": 3
"fail": 1
"failures": [
{
"diag": [null]
"id": 3
"name": "iFail v3.0.1 I dun wurk"
"ok": false
}
]
"ok": false
"pass": 2
"plan": {
"end": 3
"start": 1
}
"skip": 1
}
8 changes: 6 additions & 2 deletions test/fixtures/test-out-tap-failing.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
TAP version 13
ok 1 - iPass v4.2.2
ok 2 - iFlakyFail v3.3.3 # SKIP I dun wurk
# Thanks for testing!
---
# Thanks for testing!
...
not ok 3 - iFail v3.0.1 I dun wurk
# Thanks for testing!
---
# Thanks for testing!
...
1..3
4 changes: 3 additions & 1 deletion test/fixtures/test-out-tap-passing-append.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ This is a test!
TAP version 13
ok 1 - iPass v4.2.2
ok 2 - iFlakyPass v3.0.1
# Thanks for testing!
---
# Thanks for testing!
...
1..2
4 changes: 3 additions & 1 deletion test/fixtures/test-out-tap-passing.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
TAP version 13
ok 1 - iPass v4.2.2
ok 2 - iFlakyPass v3.0.1
# Thanks for testing!
---
# Thanks for testing!
...
1..2
19 changes: 19 additions & 0 deletions test/reporter/test-reporter-tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var os = require('os');
var test = require('tap').test;
var mkdirp = require('mkdirp');
var rimraf = require('rimraf');
var parser = require('tap-parser');
var intoStream = require('into-stream');

var tap = require('../../lib/reporter/tap');
var fixtures = require('../fixtures/reporter-fixtures');
Expand All @@ -24,9 +26,11 @@ var passingInput = [
fixtures.iFlakyPass
];

var tapParser = path.join(fixturesPath, 'tap-parser.txt');
var passingExpectedPath = path.join(fixturesPath, 'test-out-tap-passing.txt');
var passingExpectedPathAppend = path.join(fixturesPath, 'test-out-tap-passing-append.txt');

var tapParserExpected = fs.readFileSync(tapParser, 'utf-8');
var passingExpected = fs.readFileSync(passingExpectedPath, 'utf-8');
var passingExpectedAppend = fs.readFileSync(passingExpectedPathAppend, 'utf-8');

Expand Down Expand Up @@ -70,6 +74,21 @@ test('reporter.tap(): failing', function (t) {
t.end();
});

test('reporter.tap(): parser', function (t) {
var output = '';
function logger(message) {
output += message;
}

tap(logger, failingInput);
var p = parser(function (results) {
var parseResults = results;
t.equals(parseResults, tapParserExpected), 'the tap parser should correctly parse the tap file';
t.end();
});
intoStream(output).pipe(p);
});

test('reporter.tap(): write to disk', function (t) {
tap(outputFile, passingInput);
var expected = fs.readFileSync(outputFile, 'utf8');
Expand Down

0 comments on commit e1deaf4

Please sign in to comment.