test: deflake test-common-expect-warning

The subprocess might exit before the data is flushed. Run the assertion
after the `'end'` event is emitted.

PR-URL: https://github.com/nodejs/node/pull/42046
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
Luigi Pinca committed 2022-02-24 21:08:15 +01:00
1 parent 663a669b0b
commit 626367c4e3
1 file changed
+3 -1
+3 -1
View File
@@ -36,9 +36,11 @@ if (process.argv[2] !== 'child') {
child.stderr.on('data', (data) => {
stderr += data;
});
child.stderr.on('end', common.mustCall(() => {
assert.match(stderr, /Unexpected extra warning received/);
}));
child.on('exit', common.mustCall((status) => {
assert.notStrictEqual(status, 0);
assert.match(stderr, /Unexpected extra warning received/);
}));
}
} else {