From 16f976c7d6d4607d834248e4228a0983e7e44f2b Mon Sep 17 00:00:00 2001 From: ri7116 Date: Thu, 14 Aug 2025 19:55:26 +0900 Subject: [PATCH] benchmark: make child_process tests windows-compatible The spawn-echo and exec-stdout benchmarks fail on Windows due to use of Unix-specific commands. Replace Unix-specific 'echo' command with 'cmd.exe /c echo' on Windows to ensure cross-platform compatibility. --- benchmark/child_process/spawn-echo.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/benchmark/child_process/spawn-echo.js b/benchmark/child_process/spawn-echo.js index 9b5a32d01ca8b3..bec33992ce38ad 100644 --- a/benchmark/child_process/spawn-echo.js +++ b/benchmark/child_process/spawn-echo.js @@ -5,6 +5,8 @@ const bench = common.createBenchmark(main, { }); const spawn = require('child_process').spawn; +const isWindows = process.platform === 'win32'; + function main({ n }) { bench.start(); go(n, n); @@ -14,7 +16,9 @@ function go(n, left) { if (--left === 0) return bench.end(n); - const child = spawn('echo', ['hello']); + const child = isWindows ? + spawn('cmd.exe', ['/c', 'echo', 'hello']) : + spawn('echo', ['hello']); child.on('exit', (code) => { if (code) process.exit(code);