Skip to content

Commit 457ceeb

Browse files
committedDec 25, 2017
test: fix unreliable async-hooks/test-signalwrap
Use an interval to keep the event loop open so the test does not exit before receiving all signals fom asynchronous `exec()` calls. PR-URL: #17827 Fixes: #14070 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
1 parent 81c2b59 commit 457ceeb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎test/async-hooks/test-signalwrap.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
22
const common = require('../common');
33

4-
if (common.isWindows) return common.skip('no signals in Windows');
4+
if (common.isWindows)
5+
common.skip('no signals in Windows');
56

67
const assert = require('assert');
78
const initHooks = require('./init-hooks');
@@ -11,6 +12,10 @@ const exec = require('child_process').exec;
1112
const hooks = initHooks();
1213

1314
hooks.enable();
15+
16+
// Keep the event loop open so process doesn't exit before receiving signals.
17+
const interval = setInterval(() => {}, 9999);
18+
1419
process.on('SIGUSR2', common.mustCall(onsigusr2, 2));
1520

1621
const as = hooks.activitiesOfTypes('SIGNALWRAP');
@@ -66,6 +71,7 @@ function onsigusr2() {
6671
}
6772

6873
function onsigusr2Again() {
74+
clearInterval(interval);
6975
setImmediate(() => {
7076
checkInvocations(
7177
signal1, { init: 1, before: 2, after: 2, destroy: 1 },

0 commit comments

Comments
 (0)
Please sign in to comment.