From fd3e639bf50f5ddba0ee4aae105a204d5c12a244 Mon Sep 17 00:00:00 2001 From: Nad Alaba <37968805+nadalaba@users.noreply.github.com> Date: Mon, 4 May 2026 20:10:23 +0300 Subject: [PATCH] test: fix cp.exec-any-shells test on windows with wsl WSL bash files (from WindowsApps and System32) either cannot be symlinked or don't work as expected from symlinks. This change detects WSL bash and: - Skips testing it if no WSL distro is installed. - Skips symlink tests for all WSL bash executables. Signed-off-by: Nad Alaba <37968805+nadalaba@users.noreply.github.com> --- ...t-child-process-exec-any-shells-windows.js | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-child-process-exec-any-shells-windows.js b/test/parallel/test-child-process-exec-any-shells-windows.js index 5c34bc77308c..11db34c26cc7 100644 --- a/test/parallel/test-child-process-exec-any-shells-windows.js +++ b/test/parallel/test-child-process-exec-any-shells-windows.js @@ -59,9 +59,23 @@ cp.exec('where bash', common.mustCall((error, stdout) => { return; } const lines = stdout.trim().split(/[\r\n]+/g); - for (let i = 0; i < lines.length; ++i) { - const bashPath = lines[i].trim(); - test(bashPath); - testCopy(`bash_${i}.exe`, bashPath); - } + + cp.exec('wsl.exe -l -q', (err, out) => { + const hasWSLDistro = !err && out.trim().length > 0; + + for (let i = 0; i < lines.length; ++i) { + const bashPath = lines[i].trim().replace(/^"+|"+$/g, ''); + const bashPathLower = bashPath.toLowerCase(); + + const isWSLBash = + bashPathLower.includes('windowsapps') || + bashPathLower.includes('\\system32\\bash.exe'); + + // Skip WSL bash tests if no WSL distro is installed + if (!isWSLBash || hasWSLDistro) test(bashPath); + + // Skip symlink tests for WSL bash always + if (!isWSLBash) testCopy(`bash_${i}.exe`, bashPath); + } + }); }));