@@ -28,24 +28,31 @@ async function main() {
2828 if (fileIndexArg == null) {
2929 const { spawnSync } = require("child_process");
3030 let failed = false;
31- for (const [i, _] of filePaths.entries ()) {
31+ for (const i of filePaths.keys ()) {
3232 if (i > 0) {
3333 console.log("");
3434 }
35- const result = spawnSync(process.execPath, [__filename, String(i)], {
36- stdio: "inherit",
37- });
35+ const args = [...process.execArgv, __filename, String(i)];
36+ const result = spawnSync(process.execPath, args, { stdio: "inherit" });
37+ if (result.error != null) {
38+ console.error(result.error);
39+ }
3840 if (result.status !== 0) {
3941 failed = true;
4042 }
4143 }
4244 if (failed) {
43- process.exit(1) ;
45+ process.exitCode = 1 ;
4446 }
4547 return;
4648 }
4749
4850 const filePath = filePaths[Number(fileIndexArg)];
51+ if (filePath == null) {
52+ console.error("Unknown test file index: " + fileIndexArg);
53+ process.exitCode = 1;
54+ return;
55+ }
4956
5057 const scriptPath = "./script/" + filePath;
5158 console.log("Running tests in " + pc.underline(scriptPath) + "...\\n");
@@ -92,24 +99,31 @@ async function main() {
9299 if (fileIndexArg == null) {
93100 const { spawnSync } = require("child_process");
94101 let failed = false;
95- for (const [i, _] of filePaths.entries ()) {
102+ for (const i of filePaths.keys ()) {
96103 if (i > 0) {
97104 console.log("");
98105 }
99- const result = spawnSync(process.execPath, [__filename, String(i)], {
100- stdio: "inherit",
101- });
106+ const args = [...process.execArgv, __filename, String(i)];
107+ const result = spawnSync(process.execPath, args, { stdio: "inherit" });
108+ if (result.error != null) {
109+ console.error(result.error);
110+ }
102111 if (result.status !== 0) {
103112 failed = true;
104113 }
105114 }
106115 if (failed) {
107- process.exit(1) ;
116+ process.exitCode = 1 ;
108117 }
109118 return;
110119 }
111120
112121 const filePath = filePaths[Number(fileIndexArg)];
122+ if (filePath == null) {
123+ console.error("Unknown test file index: " + fileIndexArg);
124+ process.exitCode = 1;
125+ return;
126+ }
113127
114128 const testContext = {
115129 process,
@@ -322,24 +336,31 @@ async function main() {
322336 if (fileIndexArg == null) {
323337 const { spawnSync } = require("child_process");
324338 let failed = false;
325- for (const [i, _] of filePaths.entries ()) {
339+ for (const i of filePaths.keys ()) {
326340 if (i > 0) {
327341 console.log("");
328342 }
329- const result = spawnSync(process.execPath, [__filename, String(i)], {
330- stdio: "inherit",
331- });
343+ const args = [...process.execArgv, __filename, String(i)];
344+ const result = spawnSync(process.execPath, args, { stdio: "inherit" });
345+ if (result.error != null) {
346+ console.error(result.error);
347+ }
332348 if (result.status !== 0) {
333349 failed = true;
334350 }
335351 }
336352 if (failed) {
337- process.exit(1) ;
353+ process.exitCode = 1 ;
338354 }
339355 return;
340356 }
341357
342358 const filePath = filePaths[Number(fileIndexArg)];
359+ if (filePath == null) {
360+ console.error("Unknown test file index: " + fileIndexArg);
361+ process.exitCode = 1;
362+ return;
363+ }
343364
344365 process.chdir(__dirname + "/script");
345366 try {
@@ -394,24 +415,31 @@ async function main() {
394415 if (fileIndexArg == null) {
395416 const { spawnSync } = require("child_process");
396417 let failed = false;
397- for (const [i, _] of filePaths.entries ()) {
418+ for (const i of filePaths.keys ()) {
398419 if (i > 0) {
399420 console.log("");
400421 }
401- const result = spawnSync(process.execPath, [__filename, String(i)], {
402- stdio: "inherit",
403- });
422+ const args = [...process.execArgv, __filename, String(i)];
423+ const result = spawnSync(process.execPath, args, { stdio: "inherit" });
424+ if (result.error != null) {
425+ console.error(result.error);
426+ }
404427 if (result.status !== 0) {
405428 failed = true;
406429 }
407430 }
408431 if (failed) {
409- process.exit(1) ;
432+ process.exitCode = 1 ;
410433 }
411434 return;
412435 }
413436
414437 const filePath = filePaths[Number(fileIndexArg)];
438+ if (filePath == null) {
439+ console.error("Unknown test file index: " + fileIndexArg);
440+ process.exitCode = 1;
441+ return;
442+ }
415443
416444 process.chdir(__dirname + "/esm");
417445 await import("./esm/test_preload.js");
@@ -449,24 +477,31 @@ async function main() {
449477 if (fileIndexArg == null) {
450478 const { spawnSync } = require("child_process");
451479 let failed = false;
452- for (const [i, _] of filePaths.entries ()) {
480+ for (const i of filePaths.keys ()) {
453481 if (i > 0) {
454482 console.log("");
455483 }
456- const result = spawnSync(process.execPath, [__filename, String(i)], {
457- stdio: "inherit",
458- });
484+ const args = [...process.execArgv, __filename, String(i)];
485+ const result = spawnSync(process.execPath, args, { stdio: "inherit" });
486+ if (result.error != null) {
487+ console.error(result.error);
488+ }
459489 if (result.status !== 0) {
460490 failed = true;
461491 }
462492 }
463493 if (failed) {
464- process.exit(1) ;
494+ process.exitCode = 1 ;
465495 }
466496 return;
467497 }
468498
469499 const filePath = filePaths[Number(fileIndexArg)];
500+ if (filePath == null) {
501+ console.error("Unknown test file index: " + fileIndexArg);
502+ process.exitCode = 1;
503+ return;
504+ }
470505
471506 process.chdir(__dirname + "/script");
472507 try {
@@ -532,24 +567,31 @@ async function main() {
532567 if (fileIndexArg == null) {
533568 const { spawnSync } = require("child_process");
534569 let failed = false;
535- for (const [i, _] of filePaths.entries ()) {
570+ for (const i of filePaths.keys ()) {
536571 if (i > 0) {
537572 console.log("");
538573 }
539- const result = spawnSync(process.execPath, [__filename, String(i)], {
540- stdio: "inherit",
541- });
574+ const args = [...process.execArgv, __filename, String(i)];
575+ const result = spawnSync(process.execPath, args, { stdio: "inherit" });
576+ if (result.error != null) {
577+ console.error(result.error);
578+ }
542579 if (result.status !== 0) {
543580 failed = true;
544581 }
545582 }
546583 if (failed) {
547- process.exit(1) ;
584+ process.exitCode = 1 ;
548585 }
549586 return;
550587 }
551588
552589 const filePath = filePaths[Number(fileIndexArg)];
590+ if (filePath == null) {
591+ console.error("Unknown test file index: " + fileIndexArg);
592+ process.exitCode = 1;
593+ return;
594+ }
553595
554596 const esmPath = "./esm/" + filePath;
555597 console.log("\\nRunning tests in " + pc.underline(esmPath) + "...\\n");
@@ -583,24 +625,31 @@ async function main() {
583625 if (fileIndexArg == null) {
584626 const { spawnSync } = require("child_process");
585627 let failed = false;
586- for (const [i, _] of filePaths.entries ()) {
628+ for (const i of filePaths.keys ()) {
587629 if (i > 0) {
588630 console.log("");
589631 }
590- const result = spawnSync(process.execPath, [__filename, String(i)], {
591- stdio: "inherit",
592- });
632+ const args = [...process.execArgv, __filename, String(i)];
633+ const result = spawnSync(process.execPath, args, { stdio: "inherit" });
634+ if (result.error != null) {
635+ console.error(result.error);
636+ }
593637 if (result.status !== 0) {
594638 failed = true;
595639 }
596640 }
597641 if (failed) {
598- process.exit(1) ;
642+ process.exitCode = 1 ;
599643 }
600644 return;
601645 }
602646
603647 const filePath = filePaths[Number(fileIndexArg)];
648+ if (filePath == null) {
649+ console.error("Unknown test file index: " + fileIndexArg);
650+ process.exitCode = 1;
651+ return;
652+ }
604653
605654 const scriptPath = "./script/" + filePath;
606655 console.log("Running tests in " + pc.underline(scriptPath) + "...\\n");
0 commit comments