Skip to content

Commit 78b717a

Browse files
committed
fix(plugins): resolve taskkill in bundled runtime smoke
1 parent 7b00fd6 commit 78b717a

2 files changed

Lines changed: 41 additions & 14 deletions

File tree

‎scripts/e2e/lib/bundled-plugin-install-uninstall/runtime-smoke.mjs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import path from "node:path";
66
import process from "node:process";
77
import { setTimeout as delay } from "node:timers/promises";
88
import { fileURLToPath } from "node:url";
9+
import { resolveWindowsTaskkillPath } from "../../../lib/windows-taskkill.mjs";
910
import { readBoundedResponseText } from "../bounded-response-text.mjs";
1011

1112
const TOKEN = "bundled-plugin-runtime-smoke-token";
@@ -664,12 +665,13 @@ export function signalChildProcessTree(
664665
if (signal === "SIGKILL") {
665666
args.push("/F");
666667
}
667-
const result = runTaskkill("taskkill", args, { stdio: "ignore" });
668+
const taskkillPath = resolveWindowsTaskkillPath();
669+
const result = runTaskkill(taskkillPath, args, { stdio: "ignore" });
668670
if (!result?.error && result?.status === 0) {
669671
return;
670672
}
671673
if (signal !== "SIGKILL") {
672-
const forceResult = runTaskkill("taskkill", [...args, "/F"], { stdio: "ignore" });
674+
const forceResult = runTaskkill(taskkillPath, [...args, "/F"], { stdio: "ignore" });
673675
if (!forceResult?.error && forceResult?.status === 0) {
674676
return;
675677
}

‎test/scripts/bundled-plugin-install-uninstall-probe.test.ts‎

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import os from "node:os";
77
import path from "node:path";
88
import { pathToFileURL } from "node:url";
99
import { afterEach, describe, expect, it, vi } from "vitest";
10+
import { resolveWindowsTaskkillPath } from "../../scripts/lib/windows-taskkill.mjs";
1011
import { withEnvAsync } from "../../src/test-utils/env.js";
1112

1213
const tempDirs: string[] = [];
@@ -16,6 +17,10 @@ const runtimeSmokePath = path.resolve(
1617
);
1718
const sweepPath = path.resolve("scripts/e2e/lib/bundled-plugin-install-uninstall/sweep.sh");
1819

20+
function expectedTaskkillPath(): string {
21+
return resolveWindowsTaskkillPath();
22+
}
23+
1924
type PluginListEntry = {
2025
id: string;
2126
origin: string;
@@ -452,17 +457,27 @@ describe("bundled plugin install/uninstall probe", () => {
452457
platform: "win32",
453458
runTaskkill,
454459
});
455-
expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], {
456-
stdio: "ignore",
457-
});
460+
expect(runTaskkill).toHaveBeenNthCalledWith(
461+
1,
462+
expectedTaskkillPath(),
463+
["/PID", "12345", "/T"],
464+
{
465+
stdio: "ignore",
466+
},
467+
);
458468

459469
runtimeSmoke.signalChildProcessTree(child, "SIGKILL", {
460470
platform: "win32",
461471
runTaskkill,
462472
});
463-
expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], {
464-
stdio: "ignore",
465-
});
473+
expect(runTaskkill).toHaveBeenNthCalledWith(
474+
2,
475+
expectedTaskkillPath(),
476+
["/PID", "12345", "/T", "/F"],
477+
{
478+
stdio: "ignore",
479+
},
480+
);
466481
expect(child.kill).not.toHaveBeenCalled();
467482
});
468483

@@ -482,12 +497,22 @@ describe("bundled plugin install/uninstall probe", () => {
482497
runTaskkill,
483498
});
484499

485-
expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], {
486-
stdio: "ignore",
487-
});
488-
expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], {
489-
stdio: "ignore",
490-
});
500+
expect(runTaskkill).toHaveBeenNthCalledWith(
501+
1,
502+
expectedTaskkillPath(),
503+
["/PID", "12345", "/T"],
504+
{
505+
stdio: "ignore",
506+
},
507+
);
508+
expect(runTaskkill).toHaveBeenNthCalledWith(
509+
2,
510+
expectedTaskkillPath(),
511+
["/PID", "12345", "/T", "/F"],
512+
{
513+
stdio: "ignore",
514+
},
515+
);
491516
expect(child.kill).not.toHaveBeenCalled();
492517
});
493518

0 commit comments

Comments
 (0)