Skip to content

Commit

Permalink
Test: Fix flaky macOS builds by waiting for spawned.on('close')
Browse files Browse the repository at this point in the history
  • Loading branch information
Krinkle committed Oct 22, 2022
1 parent ab8a9b3 commit 49b20d3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/cli/helpers/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ async function execute (command, options = {}, hook) {
});
spawned.on('exit', (exitCode, _signal) => {
result.code = exitCode;
const stderr = normalize(String(result.stderr).trimEnd());
if (exitCode !== 0) {
reject(new Error('Error code ' + exitCode + '\n' + (stderr || result.stdout)));
});
// Wait for 'close' event. https://github.com/nodejs/node/issues/45085
spawned.on('close', () => {
if (result.code !== 0) {
reject(new Error('Exit code ' + result.code));
} else {
resolve();
}
Expand Down

0 comments on commit 49b20d3

Please sign in to comment.