summaryrefslogtreecommitdiff
path: root/test/async-hooks
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2017-12-22 10:21:39 -0800
committerRich Trott <rtrott@gmail.com>2017-12-25 12:16:45 -0800
commit457ceebabf9f3b82e45bba7c76be595e4d69fe4b (patch)
tree29ab9e53ab3e21788a1759126f5113a387195d38 /test/async-hooks
parent81c2b59609b5a354219acc5cc0f376be5be86cc4 (diff)
downloadandroid-node-v8-457ceebabf9f3b82e45bba7c76be595e4d69fe4b.tar.gz
android-node-v8-457ceebabf9f3b82e45bba7c76be595e4d69fe4b.tar.bz2
android-node-v8-457ceebabf9f3b82e45bba7c76be595e4d69fe4b.zip
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: https://github.com/nodejs/node/pull/17827 Fixes: https://github.com/nodejs/node/issues/14070 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Diffstat (limited to 'test/async-hooks')
-rw-r--r--test/async-hooks/test-signalwrap.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/async-hooks/test-signalwrap.js b/test/async-hooks/test-signalwrap.js
index fa975ff017..ae4f41c6a4 100644
--- a/test/async-hooks/test-signalwrap.js
+++ b/test/async-hooks/test-signalwrap.js
@@ -1,7 +1,8 @@
'use strict';
const common = require('../common');
-if (common.isWindows) return common.skip('no signals in Windows');
+if (common.isWindows)
+ common.skip('no signals in Windows');
const assert = require('assert');
const initHooks = require('./init-hooks');
@@ -11,6 +12,10 @@ const exec = require('child_process').exec;
const hooks = initHooks();
hooks.enable();
+
+// Keep the event loop open so process doesn't exit before receiving signals.
+const interval = setInterval(() => {}, 9999);
+
process.on('SIGUSR2', common.mustCall(onsigusr2, 2));
const as = hooks.activitiesOfTypes('SIGNALWRAP');
@@ -66,6 +71,7 @@ function onsigusr2() {
}
function onsigusr2Again() {
+ clearInterval(interval);
setImmediate(() => {
checkInvocations(
signal1, { init: 1, before: 2, after: 2, destroy: 1 },