From e9e42d5db4db1f3dc9e8510041774f04e52176d2 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 21 Jun 2026 09:48:59 +0200 Subject: [PATCH] fix(secret-provider): resolve taskkill in e2e cleanup --- scripts/e2e/secret-provider-integrations.mjs | 3 +- .../secret-provider-integrations.test.ts | 71 ++++++++++++++----- 2 files changed, 55 insertions(+), 19 deletions(-) diff --git a/scripts/e2e/secret-provider-integrations.mjs b/scripts/e2e/secret-provider-integrations.mjs index 6d07418c3a62..96588ead96a9 100644 --- a/scripts/e2e/secret-provider-integrations.mjs +++ b/scripts/e2e/secret-provider-integrations.mjs @@ -8,6 +8,7 @@ import path from "node:path"; import process from "node:process"; import { setTimeout as delay } from "node:timers/promises"; import { pathToFileURL } from "node:url"; +import { resolveWindowsTaskkillPath } from "../lib/windows-taskkill.mjs"; const PLUGIN_ID = "secret-provider-proof"; const INTEGRATION_ID = "vault"; @@ -1034,7 +1035,7 @@ function signalWindowsProcessTree(pid, signal, runTaskkill = childProcess.spawnS args.push("/F"); } try { - const result = runTaskkill("taskkill", args, { stdio: "ignore" }); + const result = runTaskkill(resolveWindowsTaskkillPath(), args, { stdio: "ignore" }); return !result?.error && result?.status === 0; } catch { return false; diff --git a/test/scripts/secret-provider-integrations.test.ts b/test/scripts/secret-provider-integrations.test.ts index 561150d1a6ea..4e0518d0cd9c 100644 --- a/test/scripts/secret-provider-integrations.test.ts +++ b/test/scripts/secret-provider-integrations.test.ts @@ -5,11 +5,16 @@ import os from "node:os"; import path from "node:path"; import { pathToFileURL } from "node:url"; import { afterEach, describe, expect, it, vi } from "vitest"; +import { resolveWindowsTaskkillPath } from "../../scripts/lib/windows-taskkill.mjs"; const tempDirs: string[] = []; const harnessPath = path.resolve("test/scripts/fixtures/secret-provider-integrations-harness.mjs"); const proofScriptPath = path.resolve("scripts/e2e/secret-provider-integrations.mjs"); +function expectedTaskkillPath(): string { + return resolveWindowsTaskkillPath(); +} + function makeTempDir(): string { const root = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-secret-provider-proof-")); tempDirs.push(root); @@ -585,17 +590,27 @@ describe("secret provider integration proof harness", () => { platform: "win32", runTaskkill, }); - expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], { - stdio: "ignore", - }); + expect(runTaskkill).toHaveBeenNthCalledWith( + 1, + expectedTaskkillPath(), + ["/PID", "12345", "/T"], + { + stdio: "ignore", + }, + ); proof.terminateProcessTree(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(); }); @@ -617,12 +632,22 @@ describe("secret provider integration proof harness", () => { 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(); }); @@ -640,17 +665,27 @@ describe("secret provider integration proof harness", () => { platform: "win32", runTaskkill, }); - expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], { - stdio: "ignore", - }); + expect(runTaskkill).toHaveBeenNthCalledWith( + 1, + expectedTaskkillPath(), + ["/PID", "12345", "/T"], + { + stdio: "ignore", + }, + ); proof.signalPtyProcessTree(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(); });