Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report skipped assertions #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function Results () {
this.count = 0;
this.fail = 0;
this.pass = 0;
this.skip = 0;
this._stream = through();
this.tests = [];
this._only = null;
Expand Down Expand Up @@ -103,7 +104,8 @@ Results.prototype._watch = function (t) {
write(encodeResult(res, self.count + 1));
self.count ++;

if (res.ok) self.pass ++
if (res.skip) self.skip ++
else if (res.ok) self.pass ++
else {
self.fail ++;
self.emit('fail');
Expand All @@ -121,6 +123,7 @@ Results.prototype.close = function () {

write('\n1..' + self.count + '\n');
write('# tests ' + self.count + '\n');
if (self.skip) write('# skip ' + self.skip + '\n');
write('# pass ' + self.pass + '\n');
if (self.fail) write('# fail ' + self.fail + '\n')
else write('\n# ok\n')
Expand All @@ -131,11 +134,11 @@ Results.prototype.close = function () {
function encodeResult (res, count) {
var output = '';
output += (res.ok ? 'ok ' : 'not ok ') + count;
output += res.name ? ' ' + res.name.toString().replace(/\s+/g, ' ') : '';

if (res.skip) output += ' # SKIP';
else if (res.todo) output += ' # TODO';

output += res.name ? ' ' + res.name.toString().replace(/\s+/g, ' ') : '';
output += '\n';
if (res.ok) return output;

Expand Down
54 changes: 54 additions & 0 deletions test/skip-output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');

tap.test('skip output test', function (tt) {
tt.plan(1);

var test = tape.createHarness({ exit : false });
test.createStream().pipe(concat(function (body) {
tt.equal(
body.toString('utf8'),
'TAP version 13\n'
+ '# skip assertions\n'
+ 'ok 1 # SKIP not enough pylons\n'
+ '# skip subtests\n'
+ '\n'
+ '1..1\n'
+ '# tests 1\n'
+ '# skip 1\n'
+ '# pass 0\n'
+ '\n'
+ '# ok\n'
);
}));

// doesn't look like test.skip is available with createHarness()
// test.skip('we require more minerals', function (t) {
// t.plan(1);
// t.fail('should not fail test.skip()');
// });

test('we require more vespene gas', { skip: true }, function (t) {
t.plan(1);
t.fail('should not fail test with { skip: true}');
});

test('skip assertions', function (t) {
t.plan(1);
t.skip('not enough pylons');
});

test('skip subtests', function (t) {
// doesn't look like test.skip is available with createHarness()
// test.skip('build more farms', function (t) {
// t.plan(1)
// t.fail('should not run subtest with test.skip()');
// });
test('we require more ziggurats', { skip: true }, function (t) {
t.plan(1)
t.fail('should not run subtest with { skip: true }');
});
t.end();
});
});
15 changes: 15 additions & 0 deletions test/skip.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,33 @@ tap.test('test SKIP comment', function (assert) {
});
});

test('does not skip with { skip: false }', function(t) {
t.equal(ran, 1, 'should have run the previous test');
t.end();
})

test('skip this', { skip: true }, function(t) {
t.fail('this should not even run');
ran++;
t.end();
});

test('does skip with { skip: true }', function(t) {
t.equal(ran, 1, 'should not have run the previous test');
t.end();
})

test.skip('skip this too', function(t) {
t.fail('this should not even run');
ran++;
t.end();
});

test('does skip with test.skip', function(t) {
t.equal(ran, 1, 'should not have run the previous test');
t.end();
})

test('skip subtest', function(t) {
ran++;
t.test('skip this', { skip: true }, function(t) {
Expand Down