From e016f0b4963d4e112ab003155cc95a301bfec386 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 21 Jun 2026 09:34:00 +0200 Subject: [PATCH] fix(scripts): resolve taskkill in test group report --- scripts/test-group-report.mjs | 6 ++-- test/scripts/test-group-report.test.ts | 49 +++++++++++++++++++------- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/scripts/test-group-report.mjs b/scripts/test-group-report.mjs index 29627b71cec4..81baed79d53b 100644 --- a/scripts/test-group-report.mjs +++ b/scripts/test-group-report.mjs @@ -14,6 +14,7 @@ import { renderGroupedTestReport, } from "./lib/test-group-report.mjs"; import { formatMs } from "./lib/vitest-report-cli-utils.mjs"; +import { resolveWindowsTaskkillPath } from "./lib/windows-taskkill.mjs"; import { resolveVitestNodeArgs } from "./run-vitest.mjs"; import { applyParallelVitestCachePaths, @@ -259,12 +260,13 @@ export function signalTestGroupReportChild( if (signal === "SIGKILL") { args.push("/F"); } - const result = runTaskkill("taskkill", args, { stdio: "ignore" }); + const taskkillPath = resolveWindowsTaskkillPath(); + const result = runTaskkill(taskkillPath, args, { stdio: "ignore" }); if (!result?.error && result?.status === 0) { return; } if (signal !== "SIGKILL") { - const forceResult = runTaskkill("taskkill", [...args, "/F"], { stdio: "ignore" }); + const forceResult = runTaskkill(taskkillPath, [...args, "/F"], { stdio: "ignore" }); if (!forceResult?.error && forceResult?.status === 0) { return; } diff --git a/test/scripts/test-group-report.test.ts b/test/scripts/test-group-report.test.ts index 6ae52f04801a..0065c69ce79b 100644 --- a/test/scripts/test-group-report.test.ts +++ b/test/scripts/test-group-report.test.ts @@ -12,6 +12,7 @@ import { resolveGroupKey, resolveTestArea, } from "../../scripts/lib/test-group-report.mjs"; +import { resolveWindowsTaskkillPath } from "../../scripts/lib/windows-taskkill.mjs"; import { parseTestGroupReportArgs, resolveFullSuiteVitestEnv, @@ -65,6 +66,10 @@ async function waitForDead(pid: number, timeoutMs: number): Promise { throw new Error(`timed out waiting for pid ${pid} to exit`); } +function expectedTaskkillPath(): string { + return resolveWindowsTaskkillPath(); +} + function waitForChildClose( child: ReturnType, timeoutMs = 5_000, @@ -622,17 +627,27 @@ describe("scripts/test-group-report child process guard", () => { platform: "win32", runTaskkill, }); - expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], { - stdio: "ignore", - }); + expect(runTaskkill).toHaveBeenNthCalledWith( + 1, + expectedTaskkillPath(), + ["/PID", "12345", "/T"], + { + stdio: "ignore", + }, + ); signalTestGroupReportChild(child, "SIGKILL", { platform: "win32", runTaskkill, }); - expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], { - stdio: "ignore", - }); + expect(runTaskkill).toHaveBeenNthCalledWith( + 2, + expectedTaskkillPath(), + ["/PID", "12345", "/T", "/F"], + { + stdio: "ignore", + }, + ); expect(child.kill).not.toHaveBeenCalled(); }); @@ -651,12 +666,22 @@ describe("scripts/test-group-report child process guard", () => { runTaskkill, }); - expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], { - stdio: "ignore", - }); - expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], { - stdio: "ignore", - }); + expect(runTaskkill).toHaveBeenNthCalledWith( + 1, + expectedTaskkillPath(), + ["/PID", "12345", "/T"], + { + stdio: "ignore", + }, + ); + expect(runTaskkill).toHaveBeenNthCalledWith( + 2, + expectedTaskkillPath(), + ["/PID", "12345", "/T", "/F"], + { + stdio: "ignore", + }, + ); expect(child.kill).not.toHaveBeenCalled(); });