
























@@ -15,6 +15,7 @@ import {
1515pruneUntrackedGeneratedSourceDeclarations,
1616resolveTsdownBuildInvocation,
1717runTsdownBuildInvocation,
18+signalTsdownBuildProcessTree,
1819} from "../../scripts/tsdown-build.mjs";
1920import { createScriptTestHarness } from "./test-helpers.js";
2021@@ -662,6 +663,49 @@ describe("runTsdownBuildInvocation", () => {
662663expect(output.chunks.join("")).toContain("timeout after 50ms");
663664});
664665666+it("signals Windows tsdown process trees with taskkill", () => {
667+const childKill = vi.fn(() => true);
668+const runTaskkill = vi.fn(() => ({ error: undefined, status: 0 }));
669+670+signalTsdownBuildProcessTree({ pid: 123, kill: childKill }, "SIGTERM", {
671+platform: "win32",
672+ runTaskkill,
673+});
674+expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "123", "/T"], {
675+stdio: "ignore",
676+});
677+678+signalTsdownBuildProcessTree({ pid: 123, kill: childKill }, "SIGKILL", {
679+platform: "win32",
680+ runTaskkill,
681+});
682+expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "123", "/T", "/F"], {
683+stdio: "ignore",
684+});
685+expect(childKill).not.toHaveBeenCalled();
686+});
687+688+it("force-kills Windows tsdown process trees when graceful taskkill fails", () => {
689+const childKill = vi.fn(() => true);
690+const runTaskkill = vi
691+.fn()
692+.mockReturnValueOnce({ error: undefined, status: 1 })
693+.mockReturnValueOnce({ error: undefined, status: 0 });
694+695+signalTsdownBuildProcessTree({ pid: 123, kill: childKill }, "SIGTERM", {
696+platform: "win32",
697+ runTaskkill,
698+});
699+700+expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "123", "/T"], {
701+stdio: "ignore",
702+});
703+expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "123", "/T", "/F"], {
704+stdio: "ignore",
705+});
706+expect(childKill).not.toHaveBeenCalled();
707+});
708+665709it.skipIf(process.platform === "win32")(
666710"kills timed-out tsdown process groups when the wrapper exits first",
667711async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。