
























@@ -62,6 +62,10 @@ const CENTRALIZED_BUILD_SCRIPTS = [
6262"scripts/test-live-build-docker.sh",
6363] as const;
646465+function shellQuote(value: string): string {
66+return `'${value.replace(/'/gu, `'\\''`)}'`;
67+}
68+6569describe("docker build helper", () => {
6670it("forces BuildKit for centralized Docker builds", () => {
6771const helper = readFileSync(HELPER_PATH, "utf8");
@@ -109,6 +113,148 @@ describe("docker build helper", () => {
109113);
110114});
111115116+it("removes functional Docker build package inputs after the build", () => {
117+const workDir = mkdtempSync(join(tmpdir(), "openclaw-docker-build-cleanup-"));
118+119+try {
120+const rootDir = process.cwd();
121+const script = `
122+set -euo pipefail
123+ROOT_DIR=${shellQuote(rootDir)}
124+TMPDIR=${shellQuote(workDir)}
125+export ROOT_DIR TMPDIR
126+127+node() {
128+ local script="$1"
129+ shift
130+ if [[ "$script" != "$ROOT_DIR/scripts/package-openclaw-for-docker.mjs" ]]; then
131+ command node "$script" "$@"
132+ return
133+ fi
134+135+ local output_dir=""
136+ local output_name=""
137+ while [[ $# -gt 0 ]]; do
138+ case "$1" in
139+ --output-dir)
140+ output_dir="$2"
141+ shift 2
142+ ;;
143+ --output-name)
144+ output_name="$2"
145+ shift 2
146+ ;;
147+ *)
148+ shift
149+ ;;
150+ esac
151+ done
152+153+ mkdir -p "$output_dir"
154+ printf fixture >"$output_dir/$output_name"
155+ printf "%s\\n" "$output_dir/$output_name"
156+}
157+export -f node
158+159+source "$ROOT_DIR/scripts/lib/docker-e2e-image.sh"
160+161+docker_build_run() {
162+ local build_context=""
163+ local arg
164+ for arg in "$@"; do
165+ case "$arg" in
166+ openclaw_package=*)
167+ build_context="\${arg#openclaw_package=}"
168+ ;;
169+ esac
170+ done
171+172+ test -n "$build_context"
173+ test -f "$build_context/openclaw-current.tgz"
174+ printf "%s\\n" "$build_context" >"$TMPDIR/build-context-seen"
175+}
176+177+docker_e2e_build_or_reuse \\
178+ openclaw-test-image \\
179+ cleanup-proof \\
180+ "$ROOT_DIR/scripts/e2e/Dockerfile" \\
181+ "$ROOT_DIR" \\
182+ functional
183+184+test -f "$TMPDIR/build-context-seen"
185+leftovers="$(find "$TMPDIR" -maxdepth 1 \\( \\
186+ -name 'openclaw-docker-e2e-pack.*' \\
187+ -o -name 'openclaw-docker-e2e-package-context.*' \\
188+\\) -print)"
189+if [[ -n "$leftovers" ]]; then
190+ printf 'leftover functional build inputs:\\n%s\\n' "$leftovers" >&2
191+ exit 1
192+fi
193+`;
194+195+execFileSync("bash", ["-lc", script], { encoding: "utf8" });
196+} finally {
197+rmSync(workDir, { recursive: true, force: true });
198+}
199+});
200+201+it("keeps caller-provided functional Docker build packages", () => {
202+const workDir = mkdtempSync(join(tmpdir(), "openclaw-docker-build-external-package-"));
203+204+try {
205+const rootDir = process.cwd();
206+const script = `
207+set -euo pipefail
208+ROOT_DIR=${shellQuote(rootDir)}
209+TMPDIR=${shellQuote(workDir)}
210+export ROOT_DIR TMPDIR
211+212+external_dir="$TMPDIR/external-package"
213+mkdir -p "$external_dir"
214+printf fixture >"$external_dir/openclaw-current.tgz"
215+OPENCLAW_CURRENT_PACKAGE_TGZ="$external_dir/openclaw-current.tgz"
216+export OPENCLAW_CURRENT_PACKAGE_TGZ
217+218+source "$ROOT_DIR/scripts/lib/docker-e2e-image.sh"
219+220+docker_build_run() {
221+ local build_context=""
222+ local arg
223+ for arg in "$@"; do
224+ case "$arg" in
225+ openclaw_package=*)
226+ build_context="\${arg#openclaw_package=}"
227+ ;;
228+ esac
229+ done
230+231+ test -n "$build_context"
232+ test -f "$build_context/openclaw-current.tgz"
233+ printf "%s\\n" "$build_context" >"$TMPDIR/build-context-seen"
234+}
235+236+docker_e2e_build_or_reuse \\
237+ openclaw-test-image \\
238+ external-package-proof \\
239+ "$ROOT_DIR/scripts/e2e/Dockerfile" \\
240+ "$ROOT_DIR" \\
241+ functional
242+243+test -f "$TMPDIR/build-context-seen"
244+test -f "$OPENCLAW_CURRENT_PACKAGE_TGZ"
245+leftovers="$(find "$TMPDIR" -maxdepth 1 -name 'openclaw-docker-e2e-package-context.*' -print)"
246+if [[ -n "$leftovers" ]]; then
247+ printf 'leftover functional build context:\\n%s\\n' "$leftovers" >&2
248+ exit 1
249+fi
250+`;
251+252+execFileSync("bash", ["-lc", script], { encoding: "utf8" });
253+} finally {
254+rmSync(workDir, { recursive: true, force: true });
255+}
256+});
257+112258it("includes procps in the shared Docker E2E image for process watchdogs", () => {
113259const dockerfile = readFileSync("scripts/e2e/Dockerfile", "utf8");
114260此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。