






















@@ -116,6 +116,70 @@ describe("scripts/lib/openclaw-e2e-instance.sh", () => {
116116}
117117});
118118119+it("falls back to plain timeout when kill-after is unavailable", () => {
120+const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-e2e-instance-plain-timeout-"));
121+try {
122+const timeoutArgsPath = path.join(tempDir, "timeout-args.txt");
123+const npmArgsPath = path.join(tempDir, "npm-args.txt");
124+const logPath = path.join(tempDir, "install.log");
125+const packagePath = path.join(tempDir, "openclaw.tgz");
126+fs.writeFileSync(packagePath, "");
127+fs.writeFileSync(
128+path.join(tempDir, "timeout"),
129+[
130+"#!/usr/bin/env bash",
131+"set -euo pipefail",
132+'if [ "${1:-}" = "--kill-after=1s" ]; then',
133+" exit 1",
134+"fi",
135+'printf "%s\\n" "$*" >"$OPENCLAW_TEST_TIMEOUT_ARGS"',
136+'while [ "$#" -gt 0 ] && [ "$1" != "npm" ]; do shift; done',
137+'exec "$@"',
138+"",
139+].join("\n"),
140+);
141+fs.writeFileSync(
142+path.join(tempDir, "npm"),
143+["#!/bin/sh", "set -eu", 'printf "%s\\n" "$*" >"$OPENCLAW_TEST_NPM_ARGS"', ""].join("\n"),
144+);
145+fs.chmodSync(path.join(tempDir, "timeout"), 0o755);
146+fs.chmodSync(path.join(tempDir, "npm"), 0o755);
147+148+const result = spawnSync(
149+"/bin/bash",
150+[
151+"-c",
152+[
153+"set -euo pipefail",
154+`source ${shellQuote(helperPath)}`,
155+`openclaw_e2e_install_package ${shellQuote(logPath)} ${shellQuote("fixture package")}`,
156+].join("; "),
157+],
158+{
159+encoding: "utf8",
160+env: {
161+ ...process.env,
162+PATH: `${tempDir}:${process.env.PATH ?? ""}`,
163+OPENCLAW_CURRENT_PACKAGE_TGZ: packagePath,
164+OPENCLAW_E2E_NPM_INSTALL_TIMEOUT: "42s",
165+OPENCLAW_TEST_TIMEOUT_ARGS: timeoutArgsPath,
166+OPENCLAW_TEST_NPM_ARGS: npmArgsPath,
167+},
168+},
169+);
170+171+expect(result.status).toBe(0);
172+expect(fs.readFileSync(timeoutArgsPath, "utf8").trim()).toBe(
173+`42s npm install -g ${packagePath} --no-fund --no-audit`,
174+);
175+expect(fs.readFileSync(npmArgsPath, "utf8").trim()).toBe(
176+`install -g ${packagePath} --no-fund --no-audit`,
177+);
178+} finally {
179+fs.rmSync(tempDir, { force: true, recursive: true });
180+}
181+});
182+119183it("runs package installs without a wrapper when timeout is unavailable", () => {
120184const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-e2e-instance-no-timeout-"));
121185try {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。