@@ -34,6 +34,7 @@ const { inspect, getCallSite } = require('util');
3434const { isMainThread } = require ( 'worker_threads' ) ;
3535const { isModuleNamespaceObject } = require ( 'util/types' ) ;
3636
37+ const escapePOSIXShell = require ( './escapePOSIXShell' ) ;
3738const tmpdir = require ( './tmpdir' ) ;
3839const bits = [ 'arm64' , 'loong64' , 'mips' , 'mipsel' , 'ppc64' , 'riscv64' , 's390x' , 'x64' ]
3940 . includes ( process . arch ) ? 64 : 32 ;
@@ -249,15 +250,13 @@ const PIPE = (() => {
249250// `$node --abort-on-uncaught-exception $file child`
250251// the process aborts.
251252function childShouldThrowAndAbort ( ) {
252- let testCmd = '' ;
253+ const escapedArgs = escapePOSIXShell `" ${ process . argv [ 0 ] } " --abort-on-uncaught-exception " ${ process . argv [ 1 ] } " child` ;
253254 if ( ! isWindows ) {
254255 // Do not create core files, as it can take a lot of disk space on
255256 // continuous testing and developers' machines
256- testCmd + = 'ulimit -c 0 && ' ;
257+ escapedArgs [ 0 ] = 'ulimit -c 0 && ' + escapedArgs [ 0 ] ;
257258 }
258- testCmd += `"${ process . argv [ 0 ] } " --abort-on-uncaught-exception ` ;
259- testCmd += `"${ process . argv [ 1 ] } " child` ;
260- const child = exec ( testCmd ) ;
259+ const child = exec ( ...escapedArgs ) ;
261260 child . on ( 'exit' , function onExit ( exitCode , signal ) {
262261 const errMsg = 'Test should have aborted ' +
263262 `but instead exited with exit code ${ exitCode } ` +
@@ -951,6 +950,7 @@ const common = {
951950 childShouldThrowAndAbort,
952951 createZeroFilledFile,
953952 defaultAutoSelectFamilyAttemptTimeout,
953+ escapePOSIXShell,
954954 expectsError,
955955 expectRequiredModule,
956956 expectWarning,
0 commit comments