From 2ef1bd97c6b384f937d0557fd5fe52a0b40f4843 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Fri, 22 Mar 2019 16:39:39 +0100 Subject: [PATCH] test: do not require flags when executing a file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 PR-URL: https://github.com/nodejs/node/pull/26858 Reviewed-By: James M Snell Reviewed-By: Tobias Nießen Reviewed-By: Michaël Zasso Signed-off-by: Beth Griggs --- test/common/index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/common/index.js b/test/common/index.js index 8076c287de7a99..7a172b3b308f95 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -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); + } } } }