-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: fix timing issue in signal test
Change sequential/test-signal-unregister so it doesn't use fixed timeouts for sending the signal and expecting the child to quit. Fixes: #1223 PR-URL: #1227 Reviewed-By: Johan Bergström <[email protected]>
- Loading branch information
1 parent
cf081a4
commit 10a9c00
Showing
2 changed files
with
8 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,12 @@ | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
var spawn = require('child_process').spawn; | ||
|
||
var childKilled = false, done = false, | ||
spawn = require('child_process').spawn, | ||
util = require('util'), | ||
child; | ||
|
||
var join = require('path').join; | ||
|
||
child = spawn(process.argv[0], [join(common.fixturesDir, 'should_exit.js')]); | ||
child.on('exit', function() { | ||
if (!done) childKilled = true; | ||
}); | ||
|
||
setTimeout(function() { | ||
console.log('Sending SIGINT'); | ||
var child = spawn(process.argv[0], [common.fixturesDir + '/should_exit.js']); | ||
child.stdout.once('data', function() { | ||
child.kill('SIGINT'); | ||
setTimeout(function() { | ||
console.log('Chance has been given to die'); | ||
done = true; | ||
if (!childKilled) { | ||
// Cleanup | ||
console.log('Child did not die on SIGINT, sending SIGTERM'); | ||
child.kill('SIGTERM'); | ||
} | ||
}, 200); | ||
}, 200); | ||
|
||
process.on('exit', function() { | ||
assert.ok(childKilled); | ||
}); | ||
child.on('exit', common.mustCall(function(exitCode, signalCode) { | ||
assert.equal(exitCode, null); | ||
assert.equal(signalCode, 'SIGINT'); | ||
})); |