Skip to content

Commit

Permalink
Make tests pass on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jul 6, 2017
1 parent bb4142d commit 2921d64
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ t.test('exec execPath', function (t) {

t.test('basic', function (t) {
var opt = isWindows ? null : { shell: '/bin/bash' }
var child = cp.exec(process.execPath + ' ' + fixture + ' xyz', opt)
var child = cp.exec('"' + process.execPath + '" "' + fixture + '" xyz', opt)

var out = ''
child.stdout.on('data', function (c) {
Expand Down
22 changes: 5 additions & 17 deletions test/exec-flag.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,28 @@ var nodes = [ 'node', process.execPath ]

sw([__filename, 'wrapper'])

t.test('wrap a -e invocation', function (t) {
t.test('try to wrap a -e invocation but it isnt wrapped', function (t) {
nodes.forEach(function (node) {
t.test(node, function (t) {
var script = [
"process.on('SIGTERM', function() { console.log('ignore!') })",
"setInterval(function() {",
" console.log('wtf')",
"}, 40)"
].join('\n')
var script = "console.log('hello')\n"
var child = spawn(node, ['-e', script])
var out = ''
child.stdout.on('data', function (c) { out += c })
child.stderr.on('data', function (c) { process.stderr.write(c) })
child.on('close', function (code, signal) {
clearTimeout(timer)
var actual = {
out: out,
code: code,
signal: signal
}
var expect = {
out: /^(wtf\n)*ignore!\n(wtf\n)*$/,
code: null,
signal: 'SIGKILL'
out: 'hello\n',
code: 0,
signal: null
}
t.match(actual, expect)
t.end()
})
var timer= setTimeout(function () {
child.kill('SIGTERM')
timer = setTimeout(function () {
child.kill('SIGKILL')
}, 150)
}, 150)
})
})
t.end()
Expand Down

0 comments on commit 2921d64

Please sign in to comment.