Skip to content

Commit d864ce3

Browse files
author
George Adams
committed
reporter: update to use TAP 13
Use yamlish instead of # to match community: nodejs/node#9262
1 parent a7346e3 commit d864ce3

7 files changed

Lines changed: 58 additions & 7 deletions

File tree

lib/reporter/tap.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ function generateTest(mod, count) {
1212
mod.error = mod.error.message;
1313
}
1414
var error = mod.error ? [directive, mod.error].join(' ') : '';
15-
var output = mod.testOutput ? '\n' + util.sanitizeOutput(mod.testOutput, '# ') : '';
15+
if (mod.testOutput && mod.testOutput.length > 0) {
16+
var output = '\n ---\n' + util.sanitizeOutput(mod.testOutput, ' #') + '\n ...';
17+
} else {
18+
output = '';
19+
}
1620
return [result, count + 1, '-', mod.name, 'v' + mod.version + error + output].join(' ');
1721
}
1822

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
"nyc": "^8.4.0",
6565
"opener": "^1.4.1",
6666
"rewire": "^2.4.0",
67-
"tap": "^8.0.0"
67+
"tap": "^8.0.0",
68+
"tap-parser": "^3.0.3",
69+
"into-stream": "^3.0.0"
6870
}
6971
}

test/fixtures/tap-parser.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"count": 3
3+
"fail": 1
4+
"failures": [
5+
{
6+
"diag": [null]
7+
"id": 3
8+
"name": "iFail v3.0.1 I dun wurk"
9+
"ok": false
10+
}
11+
]
12+
"ok": false
13+
"pass": 2
14+
"plan": {
15+
"end": 3
16+
"start": 1
17+
}
18+
"skip": 1
19+
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
TAP version 13
22
ok 1 - iPass v4.2.2
33
ok 2 - iFlakyFail v3.3.3 # SKIP I dun wurk
4-
# Thanks for testing!
4+
---
5+
# Thanks for testing!
6+
...
57
not ok 3 - iFail v3.0.1 I dun wurk
6-
# Thanks for testing!
8+
---
9+
# Thanks for testing!
10+
...
711
1..3

test/fixtures/test-out-tap-passing-append.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ This is a test!
22
TAP version 13
33
ok 1 - iPass v4.2.2
44
ok 2 - iFlakyPass v3.0.1
5-
# Thanks for testing!
5+
---
6+
# Thanks for testing!
7+
...
68
1..2
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
TAP version 13
22
ok 1 - iPass v4.2.2
33
ok 2 - iFlakyPass v3.0.1
4-
# Thanks for testing!
4+
---
5+
# Thanks for testing!
6+
...
57
1..2

test/reporter/test-reporter-tap.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ var os = require('os');
77
var test = require('tap').test;
88
var mkdirp = require('mkdirp');
99
var rimraf = require('rimraf');
10+
var parser = require('tap-parser');
11+
var intoStream = require('into-stream');
1012

1113
var tap = require('../../lib/reporter/tap');
1214
var fixtures = require('../fixtures/reporter-fixtures');
@@ -23,10 +25,11 @@ var passingInput = [
2325
fixtures.iPass,
2426
fixtures.iFlakyPass
2527
];
26-
28+
var tapParser = path.join(fixturesPath, 'tap-parser.txt');
2729
var passingExpectedPath = path.join(fixturesPath, 'test-out-tap-passing.txt');
2830
var passingExpectedPathAppend = path.join(fixturesPath, 'test-out-tap-passing-append.txt');
2931

32+
var tapParserExpected = fs.readFileSync(tapParser, 'utf-8');
3033
var passingExpected = fs.readFileSync(passingExpectedPath, 'utf-8');
3134
var passingExpectedAppend = fs.readFileSync(passingExpectedPathAppend, 'utf-8');
3235

@@ -70,6 +73,21 @@ test('reporter.tap(): failing', function (t) {
7073
t.end();
7174
});
7275

76+
test('reporter.tap(): parser', function (t) {
77+
var output = '';
78+
function logger(message) {
79+
output += message;
80+
}
81+
82+
tap(logger, failingInput);
83+
var p = parser(function (results) {
84+
var parseResults = results;
85+
t.equals(parseResults, tapParserExpected), 'the tap parser should correctly parse the tap file';
86+
t.end();
87+
});
88+
intoStream(output).pipe(p);
89+
});
90+
7391
test('reporter.tap(): write to disk', function (t) {
7492
tap(outputFile, passingInput);
7593
var expected = fs.readFileSync(outputFile, 'utf8');

0 commit comments

Comments
 (0)