Skip to content

Commit 2ef1bd9

Browse files
BridgeARBethGriggs
authored andcommitted
test: do not require flags when executing a file
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> Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
1 parent 5512ecb commit 2ef1bd9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/common/index.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,18 @@ if (process.argv.length === 2 &&
8080
// If the binary is build without `intl` the inspect option is
8181
// invalid. The test itself should handle this case.
8282
(process.features.inspector || !flag.startsWith('--inspect'))) {
83-
throw new Error(`Test has to be started with the flag: '${flag}'`);
83+
console.log(
84+
'NOTE: The test started as a child_process using these flags:',
85+
util.inspect(flags)
86+
);
87+
const args = [...flags, ...process.execArgv, ...process.argv.slice(1)];
88+
const options = { encoding: 'utf8', stdio: 'inherit' };
89+
const result = spawnSync(process.execPath, args, options);
90+
if (result.signal) {
91+
process.kill(0, result.signal);
92+
} else {
93+
process.exit(result.status);
94+
}
8495
}
8596
}
8697
}

0 commit comments

Comments
 (0)