test(scripts): simplify worktree lock setup

This commit is contained in:
Ayaan Zaidi
2026-05-13 13:24:02 +05:30
parent 94aae40c28
commit 25cda2b24c

View File

@@ -1,4 +1,4 @@
import { spawnSync } from "node:child_process";
import { execFileSync } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
@@ -35,17 +35,6 @@ function makeEnv(overrides: Record<string, string | undefined> = {}) {
return env;
}
function runGit(cwd: string, args: string[]) {
const result = spawnSync("git", args, {
cwd,
encoding: "utf8",
stdio: ["ignore", "pipe", "pipe"],
});
if (result.status !== 0) {
throw new Error(`git ${args.join(" ")} failed: ${result.stderr || result.stdout}`);
}
}
describe("local-heavy-check-runtime", () => {
it("reenables local heavy-check policy for local wrapper entrypoints", () => {
expect(resolveLocalHeavyCheckEnv({ OPENCLAW_LOCAL_CHECK: "0", PATH: "/usr/bin" })).toEqual({
@@ -376,7 +365,7 @@ describe("local-heavy-check-runtime", () => {
it("uses a worktree-local heavy-check lock when explicitly requested", () => {
const repoRoot = createTempDir("openclaw-local-heavy-check-worktree-");
runGit(repoRoot, ["init"]);
execFileSync("git", ["init"], { cwd: repoRoot, stdio: "ignore" });
const cwd = path.join(repoRoot, "nested", "tooling");
fs.mkdirSync(cwd, { recursive: true });
const commonLockDir = path.join(repoRoot, ".git", "openclaw-local-checks", "heavy-check.lock");