






















11// Test Install Sh Docker tests cover test install sh docker script behavior.
22import { spawnSync } from "node:child_process";
3-import { readFileSync } from "node:fs";
3+import { existsSync, readFileSync } from "node:fs";
4+import path from "node:path";
45import { runInNewContext } from "node:vm";
5-import { describe, expect, it } from "vitest";
6+import { afterEach, describe, expect, it } from "vitest";
7+import { createTempDirTracker } from "../helpers/temp-dir.js";
6879const SCRIPT_PATH = "scripts/test-install-sh-docker.sh";
810const INSTALL_E2E_DOCKER_PATH = "scripts/test-install-sh-e2e-docker.sh";
@@ -17,6 +19,11 @@ const BUN_GLOBAL_ASSERTIONS_PATH = "scripts/e2e/lib/bun-global-install/assertion
1719const INSTALL_SMOKE_WORKFLOW_PATH = ".github/workflows/install-smoke.yml";
1820const RELEASE_CHECKS_WORKFLOW_PATH = ".github/workflows/openclaw-release-checks.yml";
1921const LIVE_E2E_WORKFLOW_PATH = ".github/workflows/openclaw-live-and-e2e-checks-reusable.yml";
22+const tempDirs = createTempDirTracker();
23+24+afterEach(() => {
25+tempDirs.cleanup();
26+});
20272128class ScriptExit extends Error {
2229constructor(readonly status: number) {
@@ -757,6 +764,54 @@ describe("bun global install smoke", () => {
757764}
758765});
759766767+it.runIf(process.platform !== "win32" && existsSync("/usr/bin/time"))(
768+"preserves Bun global timeout kill grace after the leader exits",
769+() => {
770+const tempDir = tempDirs.make("openclaw-bun-global-timeout-grace-");
771+const readyPath = path.join(tempDir, "ready");
772+const drainedPath = path.join(tempDir, "drained");
773+const childScript = [
774+"const fs = require('node:fs');",
775+"process.on('SIGTERM', () => {",
776+" setTimeout(() => {",
777+" fs.writeFileSync(process.argv[2], 'drained');",
778+" process.exit(0);",
779+" }, 50);",
780+"});",
781+"fs.writeFileSync(process.argv[1], 'ready');",
782+"setInterval(() => {}, 1000);",
783+].join("\n");
784+785+const result = spawnSync(
786+process.execPath,
787+[
788+BUN_GLOBAL_ASSERTIONS_PATH,
789+"run-with-timeout",
790+"500",
791+"/usr/bin/time",
792+process.execPath,
793+"-e",
794+childScript,
795+readyPath,
796+drainedPath,
797+],
798+{
799+encoding: "utf8",
800+env: {
801+ ...process.env,
802+OPENCLAW_BUN_GLOBAL_SMOKE_TIMEOUT_KILL_GRACE_MS: "1000",
803+},
804+timeout: 5_000,
805+},
806+);
807+808+expect(result.status).toBe(1);
809+expect(result.stderr).toContain("command timed out after 500ms: /usr/bin/time");
810+expect(readFileSync(readyPath, "utf8")).toBe("ready");
811+expect(readFileSync(drainedPath, "utf8")).toBe("drained");
812+},
813+);
814+760815it("gates workflow Bun install smoke to scheduled and release-check runs", () => {
761816const workflow = readFileSync(INSTALL_SMOKE_WORKFLOW_PATH, "utf8");
762817const releaseChecks = readFileSync(RELEASE_CHECKS_WORKFLOW_PATH, "utf8");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。