mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix(e2e): clean clawhub install temp home
This commit is contained in:
@@ -57,6 +57,7 @@ Docs: https://docs.openclaw.ai
|
||||
- Release/CI/E2E: stop RPC RTT gateway process groups so pnpm wrapper children cannot survive measurement cleanup.
|
||||
- Release/CI/E2E: fail the kitchen-sink RPC walk when command RSS sampling captures no process samples.
|
||||
- Release/CI/E2E: force-stop memory/fd repro gateway children that survive listener cleanup.
|
||||
- Release/CI/E2E: remove fallback ClawHub skill-install home directories when proof runs fail.
|
||||
- Scripts/UI: stop descendant processes from wrapped non-interactive commands when `run-with-env` receives shutdown signals.
|
||||
- Release/CI/E2E: write multi-node update Docker artifacts to unique per-run directories by default so parallel runs cannot overwrite evidence.
|
||||
- Release/CI/E2E: write package Telegram Docker artifacts to unique per-run directories by default so parallel live/RTT runs cannot overwrite evidence.
|
||||
|
||||
@@ -8,10 +8,19 @@ cd "$ROOT_DIR"
|
||||
source "$ROOT_DIR/scripts/lib/openclaw-e2e-instance.sh"
|
||||
|
||||
OPENCLAW_TEST_STATE_SCRIPT_B64="${OPENCLAW_TEST_STATE_SCRIPT_B64:-}"
|
||||
openclaw_skill_install_owns_home=0
|
||||
cleanup_clawhub_skill_install_home() {
|
||||
if [ "$openclaw_skill_install_owns_home" = "1" ] && [ -n "${HOME:-}" ]; then
|
||||
rm -rf "$HOME"
|
||||
fi
|
||||
}
|
||||
trap cleanup_clawhub_skill_install_home EXIT
|
||||
|
||||
if [ -n "$OPENCLAW_TEST_STATE_SCRIPT_B64" ]; then
|
||||
openclaw_e2e_eval_test_state_from_b64 "$OPENCLAW_TEST_STATE_SCRIPT_B64"
|
||||
else
|
||||
export HOME="$(mktemp -d "${TMPDIR:-/tmp}/openclaw-skill-install-home.XXXXXX")"
|
||||
openclaw_skill_install_owns_home=1
|
||||
export USERPROFILE="$HOME"
|
||||
export OPENCLAW_HOME="$HOME"
|
||||
export OPENCLAW_STATE_DIR="$HOME/.openclaw"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdtemp, readdir, readFile, rm, writeFile } from "node:fs/promises";
|
||||
import { mkdir, mkdtemp, readdir, readFile, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
@@ -132,4 +132,41 @@ test ! -e "$ONBOARD_TMP_DIR"
|
||||
await rm(tempRoot, { force: true, recursive: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("removes fallback ClawHub skill install HOME on failure", async () => {
|
||||
const tempRoot = await mkdtemp(path.join(tmpdir(), "openclaw-clawhub-home-test-"));
|
||||
const fakeBin = path.join(tempRoot, "bin");
|
||||
const scratchRoot = path.join(tempRoot, "scratch");
|
||||
await mkdir(fakeBin, { recursive: true });
|
||||
await mkdir(scratchRoot, { recursive: true });
|
||||
await writeFile(
|
||||
path.join(fakeBin, "pnpm"),
|
||||
`#!/usr/bin/env bash
|
||||
exit 42
|
||||
`,
|
||||
{ mode: 0o755 },
|
||||
);
|
||||
|
||||
try {
|
||||
const result = spawnSync("bash", ["scripts/e2e/lib/skills/clawhub-install-proof.sh"], {
|
||||
cwd: process.cwd(),
|
||||
encoding: "utf8",
|
||||
env: {
|
||||
...process.env,
|
||||
OPENCLAW_CURRENT_PACKAGE_TGZ: "",
|
||||
OPENCLAW_TEST_STATE_SCRIPT_B64: "",
|
||||
PATH: `${fakeBin}:${process.env.PATH ?? ""}`,
|
||||
TMPDIR: scratchRoot,
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.status, `${result.stdout}\n${result.stderr}`).toBe(42);
|
||||
const scratchEntries = await readdir(scratchRoot);
|
||||
expect(scratchEntries.filter((entry) => entry.startsWith("openclaw-skill-install-home."))).toEqual(
|
||||
[],
|
||||
);
|
||||
} finally {
|
||||
await rm(tempRoot, { force: true, recursive: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user