skip_explanation.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. 'use strict';
  2. var tap = require('tap');
  3. var test = require('../');
  4. var concat = require('concat-stream');
  5. var stripFullStack = require('./common').stripFullStack;
  6. tap.test('test skip explanations', function (assert) {
  7. assert.plan(1);
  8. var verify = function (output) {
  9. assert.same(stripFullStack(output.toString('utf8')), [
  10. 'TAP version 13',
  11. '# SKIP (this skips)',
  12. '# some tests might skip',
  13. 'ok 1 this runs',
  14. 'ok 2 failing assert is skipped # SKIP',
  15. 'ok 3 this runs',
  16. '# incomplete test',
  17. 'ok 4 run sh',
  18. 'ok 5 run openssl # SKIP',
  19. '# incomplete test with explanation',
  20. 'ok 6 run sh (conditional skip) # SKIP',
  21. 'ok 7 run openssl # SKIP can\'t run on windows platforms',
  22. 'ok 8 this runs',
  23. '# too much explanation',
  24. 'ok 9 run openssl # SKIP Installer cannot work on windows and fails to add to PATH Err: (2401) denied',
  25. '',
  26. '1..9',
  27. '# tests 9',
  28. '# pass 9',
  29. '',
  30. '# ok',
  31. ''
  32. ]);
  33. };
  34. var tapeTest = test.createHarness();
  35. tapeTest.createStream().pipe(concat(verify));
  36. tapeTest('(this skips)', { skip: true }, function (t) {
  37. t.fail('doesn\'t run');
  38. t.fail('this doesn\'t run too', { skip: false });
  39. t.end();
  40. });
  41. tapeTest('some tests might skip', function (t) {
  42. t.pass('this runs');
  43. t.fail('failing assert is skipped', { skip: true });
  44. t.pass('this runs');
  45. t.end();
  46. });
  47. tapeTest('incomplete test', function (t) {
  48. // var platform = process.platform; something like this needed
  49. var platform = 'win32';
  50. t.pass('run sh', { skip: platform !== 'win32' });
  51. t.pass('run openssl', { skip: platform === 'win32' });
  52. t.end();
  53. });
  54. tapeTest('incomplete test with explanation', function (t) {
  55. // var platform = process.platform; something like this needed
  56. var platform = 'win32';
  57. t.fail('run sh (conditional skip)', { skip: platform === 'win32' });
  58. t.fail('run openssl', { skip: platform === 'win32' && 'can\'t run on windows platforms' });
  59. t.pass('this runs');
  60. t.end();
  61. });
  62. tapeTest('too much explanation', function (t) {
  63. // var platform = process.platform; something like this needed
  64. var platform = 'win32';
  65. t.fail(
  66. 'run openssl',
  67. { skip: platform === 'win32' && 'Installer cannot work on windows\nand fails to add to PATH\n\n Err: (2401) denied' }
  68. );
  69. t.end();
  70. });
  71. });
  72. // vim: set softtabstop=4 shiftwidth=4: