mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-22 10:28:13 +00:00
Summary: - Merged test: add temp directory helper guidance after ClawSweeper review. Automerge notes: - PR branch already contained follow-up commit before automerge: fix(scripts): honor temp report failure mode - PR branch already contained follow-up commit before automerge: fix(scripts): reduce temp report noise - PR branch already contained follow-up commit before automerge: fix(scripts): cover test support temp reports - PR branch already contained follow-up commit before automerge: fix(scripts): report temp use in test helpers - PR branch already contained follow-up commit before automerge: fix(scripts): broaden temp report test surface - PR branch already contained follow-up commit before automerge: fix(scripts): cover nested test temp reports Validation: - ClawSweeper review passed for head132f14a381. - Required merge gates passed before the squash merge. Prepared head SHA:132f14a381Review: https://github.com/openclaw/openclaw/pull/87298#issuecomment-4704338581 Co-authored-by: masonxhuang <masonxhuang@tencent.com> Co-authored-by: Mason Huang <masonxhuang@tencent.com> Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: hxy91819 Co-authored-by: hxy91819 <8814856+hxy91819@users.noreply.github.com>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
import { cleanupTempDirs, createTempDirTracker, makeTempDir } from "./temp-dir.js";
|
|
|
|
const tempDirs = new Set<string>();
|
|
|
|
afterEach(() => {
|
|
cleanupTempDirs(tempDirs);
|
|
});
|
|
|
|
describe("temp-dir test helpers", () => {
|
|
it("keeps a non-executed temp warning fixture for CI proof", () => {
|
|
// openclaw-temp-dir: allow test fixture for the temp warning report
|
|
const warningFixture = 'tmp.dirSync({ prefix: "openclaw-warning-fixture-" })';
|
|
|
|
expect(warningFixture).toContain("tmp.dirSync");
|
|
});
|
|
|
|
it("tracks created temp dirs and removes populated dirs", () => {
|
|
const tracker = createTempDirTracker();
|
|
const dir = tracker.make("openclaw-temp-dir-helper-");
|
|
tempDirs.add(dir);
|
|
fs.writeFileSync(path.join(dir, "artifact.txt"), "artifact\n", "utf8");
|
|
|
|
tracker.cleanup();
|
|
tempDirs.delete(dir);
|
|
|
|
expect(fs.existsSync(dir)).toBe(false);
|
|
expect([...tracker.dirs]).toEqual([]);
|
|
});
|
|
|
|
it("supports existing caller-owned temp dir collections", () => {
|
|
const dir = makeTempDir(tempDirs, "openclaw-temp-dir-existing-");
|
|
fs.mkdirSync(path.join(dir, "nested"), { recursive: true });
|
|
|
|
cleanupTempDirs(tempDirs);
|
|
|
|
expect(fs.existsSync(dir)).toBe(false);
|
|
expect([...tempDirs]).toEqual([]);
|
|
});
|
|
});
|