Skip to content

Commit

Permalink
test: do not require flags when executing a file
Browse files Browse the repository at this point in the history
Instead of throwing an error in case a flag is missing, just start
a `child_process` that includes all flags. This improves the situation
for all developers in case they want to just plainly run a test.

Co-authored-by: Rich Trott <rtrott@gmail.com>

PR-URL: #26858
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
BridgeAR committed Mar 29, 2019
1 parent 2506ab5 commit f2dc99c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,18 @@ if (process.argv.length === 2 &&
// If the binary is build without `intl` the inspect option is
// invalid. The test itself should handle this case.
(process.features.inspector || !flag.startsWith('--inspect'))) {
throw new Error(`Test has to be started with the flag: '${flag}'`);
console.log(
'NOTE: The test started as a child_process using these flags:',
util.inspect(flags)
);
const args = [...flags, ...process.execArgv, ...process.argv.slice(1)];
const options = { encoding: 'utf8', stdio: 'inherit' };
const result = spawnSync(process.execPath, args, options);
if (result.signal) {
process.kill(0, result.signal);
} else {
process.exit(result.status);
}
}
}
}
Expand Down

0 comments on commit f2dc99c

Please sign in to comment.