Skip to content

Commit 99e0d0d

Browse files
authoredSep 29, 2024
test: add escapePOSIXShell util
PR-URL: #55125 Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
1 parent 858bce5 commit 99e0d0d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+274
-344
lines changed
 

‎test/abort/test-abort-fatal-error.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,17 @@ if (common.isWindows)
2727
const assert = require('assert');
2828
const exec = require('child_process').exec;
2929

30-
let cmdline = `ulimit -c 0; ${process.execPath}`;
31-
cmdline += ' --max-old-space-size=16 --max-semi-space-size=4';
32-
cmdline += ' -e "a = []; for (i = 0; i < 1e9; i++) { a.push({}) }"';
30+
const cmdline =
31+
common.escapePOSIXShell`ulimit -c 0; "${
32+
process.execPath
33+
}" --max-old-space-size=16 --max-semi-space-size=4 -e "a = []; for (i = 0; i < 1e9; i++) { a.push({}) }"`;
3334

34-
exec(cmdline, function(err, stdout, stderr) {
35+
exec(...cmdline, common.mustCall((err, stdout, stderr) => {
3536
if (!err) {
3637
console.log(stdout);
3738
console.log(stderr);
3839
assert(false, 'this test should fail');
3940
}
4041

4142
assert(common.nodeProcessAborted(err.code, err.signal));
42-
});
43+
}));

‎test/async-hooks/test-callback-error.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@ assert.ok(!arg);
6262
let program = process.execPath;
6363
let args = [
6464
'--abort-on-uncaught-exception', __filename, 'test_callback_abort' ];
65-
const options = { encoding: 'utf8' };
65+
let options = {};
6666
if (!common.isWindows) {
67-
program = `ulimit -c 0 && exec ${program} ${args.join(' ')}`;
67+
[program, options] = common.escapePOSIXShell`ulimit -c 0 && exec "${program}" ${args[0]} "${args[1]}" ${args[2]}`;
6868
args = [];
6969
options.shell = true;
7070
}
71+
72+
options.encoding = 'utf8';
7173
const child = spawnSync(program, args, options);
7274
if (common.isWindows) {
7375
assert.strictEqual(child.status, 134);

0 commit comments

Comments
 (0)