Skip to content

Commit

Permalink
remove output tests for bail cases that don't bail
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jul 2, 2017
1 parent c417424 commit 087912f
Show file tree
Hide file tree
Showing 76 changed files with 45 additions and 2,040 deletions.
55 changes: 31 additions & 24 deletions scripts/generate-test-test.js
Expand Up @@ -47,39 +47,46 @@ function generate (file, bail, buffer) {
c.stdout.on('data', function (d) {
output += d
})
c.on('close', function () {
var timep = '# time=[0-9.]+(ms)?'
var timere = new RegExp(timep, 'g')
output = output.replace(timere, '___/' + timep + '/~~~')

// raw stack traces vary in depth between node versions, and always
// cause problems. Replace them with an obvious failure.
output = output.replace(
/^ at .*?:[0-9]+:[0-9]+\)?$/mg,
'ERROR: stacks will cause problems, please fix this in the test')
c.on('close', function (code, signal) {
if (bail && code === 0 && signal === null) {
// no point testing bailouts if no bailout happens
try { fs.unlinkSync(outfile) } catch (er) {}
} else {

var timep = '# time=[0-9.]+(ms)?'
var timere = new RegExp(timep, 'g')
output = output.replace(timere, '___/' + timep + '/~~~')

output = output.split(file).join('___/.*/~~~' + path.basename(file))
output = output.split(f).join('___/.*/~~~' + path.basename(f))
// raw stack traces vary in depth between node versions, and always
// cause problems. Replace them with an obvious failure.
output = output.replace(
/^ at .*?:[0-9]+:[0-9]+\)?$/mg,
'ERROR: stacks will cause problems, please fix this in the test')

var dir = path.dirname(file)
output = output.split(dir + '/').join('___/.*/~~~')
output = output.split(dir).join('___/.*/~~~' + path.basename(dir))
output = output.split(file).join('___/.*/~~~' + path.basename(file))
output = output.split(f).join('___/.*/~~~' + path.basename(f))

output = output.split(cwd + '/').join('___/.*/~~~')
output = output.split(cwd).join('___/.*/~~~')
var dir = path.dirname(file)
output = output.split(dir + '/').join('___/.*/~~~')
output = output.split(dir).join('___/.*/~~~' + path.basename(dir))

output = output.split(node + ' ___/').join('\0N1\0')
output = output.split(path.basename(node) + ' ___/').join('\0N1\0')
output = output.split(cwd + '/').join('___/.*/~~~')
output = output.split(cwd).join('___/.*/~~~')

output = output.split(node).join('\0N2\0')
output = output.split(path.basename(node)).join('\0N2\0')
output = output.split(node + ' ___/').join('\0N1\0')
output = output.split(path.basename(node) + ' ___/').join('\0N1\0')

output = output.split('\0N1\0').join('___/.*(node|iojs)(\.exe)?')
output = output.split('\0N2\0').join('___/.*(node|iojs)(\.exe)?/~~~')
output = output.split(node).join('\0N2\0')
output = output.split(path.basename(node)).join('\0N2\0')

output = yamlishToJson(output)
output = output.split('\0N1\0').join('___/.*(node|iojs)(\.exe)?')
output = output.split('\0N2\0').join('___/.*(node|iojs)(\.exe)?/~~~')

fs.writeFileSync(outfile, output)
output = yamlishToJson(output)

fs.writeFileSync(outfile, output)
}

running = false
if (queue.length) {
Expand Down
18 changes: 14 additions & 4 deletions test/test.js
Expand Up @@ -92,10 +92,20 @@ function runTests (file, bail, buffer) {

function runTest (t, bail, buffer, file) {
var resfile = file.replace(/\.js$/,
(bail ? '--bail' : '') +
(buffer ? '--buffer' : '') +
'.tap')
var want = fs.readFileSync(resfile, 'utf8').split(/\r?\n/)
(bail ? '--bail' : '') +
(buffer ? '--buffer' : '') +
'.tap')

var want
try {
want = fs.readFileSync(resfile, 'utf8').split(/\r?\n/)
} catch (er) {
// there isn't an output file for bail tests that pass.
if (bail)
return t.end()
else
throw er
}

var child = spawn(node, [file], {
stdio: [ 0, 'pipe', 'pipe' ],
Expand Down
26 changes: 0 additions & 26 deletions test/test/assert-todo-skip--bail--buffer.tap

This file was deleted.

26 changes: 0 additions & 26 deletions test/test/assert-todo-skip--bail.tap

This file was deleted.

14 changes: 0 additions & 14 deletions test/test/async--bail--buffer.tap

This file was deleted.

14 changes: 0 additions & 14 deletions test/test/async--bail.tap

This file was deleted.

24 changes: 0 additions & 24 deletions test/test/bailout--bail--buffer.tap

This file was deleted.

25 changes: 0 additions & 25 deletions test/test/bailout--bail.tap

This file was deleted.

38 changes: 0 additions & 38 deletions test/test/before-after-each--bail--buffer.tap

This file was deleted.

38 changes: 0 additions & 38 deletions test/test/before-after-each--bail.tap

This file was deleted.

28 changes: 0 additions & 28 deletions test/test/before-after-each-async--bail--buffer.tap

This file was deleted.

28 changes: 0 additions & 28 deletions test/test/before-after-each-async--bail.tap

This file was deleted.

26 changes: 0 additions & 26 deletions test/test/before-after-each-plan--bail--buffer.tap

This file was deleted.

0 comments on commit 087912f

Please sign in to comment.