@@ -115,7 +115,42 @@ describe("scripts/ci-docker-pull-retry.sh", () => {
|
115 | 115 | ); |
116 | 116 | }); |
117 | 117 | |
118 | | -it("fails fast when timeout is unavailable", () => { |
| 118 | +it("uses gtimeout when timeout is unavailable", () => { |
| 119 | +const binDir = makeTempBin("openclaw-ci-docker-pull-gtimeout-"); |
| 120 | +const timeoutArgsPath = path.join(binDir, "gtimeout-args.txt"); |
| 121 | +const dockerArgsPath = path.join(binDir, "docker-args.txt"); |
| 122 | + |
| 123 | +writeExecutable( |
| 124 | +path.join(binDir, "gtimeout"), |
| 125 | +[ |
| 126 | +"#!/bin/bash", |
| 127 | +"set -euo pipefail", |
| 128 | +'if [ "${1:-}" = "--kill-after=1s" ]; then exit 0; fi', |
| 129 | +`printf "%s\\n" "gtimeout:$*" >${JSON.stringify(timeoutArgsPath)}`, |
| 130 | +'while [ "$#" -gt 0 ] && [ "$1" != "docker" ]; do shift; done', |
| 131 | +'exec "$@"', |
| 132 | +"", |
| 133 | +].join("\n"), |
| 134 | +); |
| 135 | +writeExecutable( |
| 136 | +path.join(binDir, "docker"), |
| 137 | +["#!/bin/sh", "set -eu", `printf "%s\\n" "$*" >${JSON.stringify(dockerArgsPath)}`, ""].join( |
| 138 | +"\n", |
| 139 | +), |
| 140 | +); |
| 141 | + |
| 142 | +const result = runPullHelper(binDir); |
| 143 | + |
| 144 | +expect(result.status).toBe(0); |
| 145 | +expect(execFileSync("cat", [timeoutArgsPath], { encoding: "utf8" }).trim()).toBe( |
| 146 | +"gtimeout:--kill-after=30s 42s docker pull registry.example/openclaw:test", |
| 147 | +); |
| 148 | +expect(execFileSync("cat", [dockerArgsPath], { encoding: "utf8" }).trim()).toBe( |
| 149 | +"pull registry.example/openclaw:test", |
| 150 | +); |
| 151 | +}); |
| 152 | + |
| 153 | +it("fails fast when timeout and gtimeout are unavailable", () => { |
119 | 154 | const binDir = makeTempBin("openclaw-ci-docker-pull-no-timeout-"); |
120 | 155 | const dockerArgsPath = path.join(binDir, "docker-args.txt"); |
121 | 156 | |
@@ -130,7 +165,7 @@ describe("scripts/ci-docker-pull-retry.sh", () => {
|
130 | 165 | |
131 | 166 | expect(result.status).toBe(127); |
132 | 167 | expect(result.stderr).toContain( |
133 | | -"timeout command not found; cannot bound Docker pull after 42s", |
| 168 | +"timeout or gtimeout command not found; cannot bound Docker pull after 42s", |
134 | 169 | ); |
135 | 170 | expect(existsSync(dockerArgsPath)).toBe(false); |
136 | 171 | }); |
|