diff --git a/lib/results.js b/lib/results.js index 56fdc4ba..3f3006f5 100644 --- a/lib/results.js +++ b/lib/results.js @@ -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; @@ -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'); @@ -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') @@ -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; diff --git a/test/skip-output.js b/test/skip-output.js new file mode 100644 index 00000000..186c00c4 --- /dev/null +++ b/test/skip-output.js @@ -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(); + }); +}); diff --git a/test/skip.js b/test/skip.js index c3bf8d9e..225917e3 100644 --- a/test/skip.js +++ b/test/skip.js @@ -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) {