mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
c70aee247e
* refactor(scripts): migrate JavaScript tools to TypeScript * fix(ci): keep changed-scope preflight zero-install * fix(ci): preserve zero-install script owners * fix(ci): complete script migration follow-through * fix(release): keep stable closeout zero-install * fix(scripts): preserve standalone execution boundaries * fix(scripts): repair standalone loader boundaries * fix(scripts): normalize gateway observation ids * fix(scripts): keep Docker packager standalone * test(scripts): preserve rebase cleanup helpers * test(sessions): use tracked temp directory
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
// Test Hotspots tests cover hotspot report evidence validation.
|
|
import { spawnSync } from "node:child_process";
|
|
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
|
|
const tempRoots: string[] = [];
|
|
|
|
function mkTempRoot() {
|
|
const root = mkdtempSync(join(tmpdir(), "openclaw-test-hotspots-"));
|
|
tempRoots.push(root);
|
|
return root;
|
|
}
|
|
|
|
function runTestHotspots(args: string[]) {
|
|
return spawnSync(process.execPath, ["--import", "tsx", "scripts/test-hotspots.mts", ...args], {
|
|
cwd: process.cwd(),
|
|
encoding: "utf8",
|
|
});
|
|
}
|
|
|
|
afterEach(() => {
|
|
for (const root of tempRoots.splice(0)) {
|
|
rmSync(root, { force: true, recursive: true });
|
|
}
|
|
});
|
|
|
|
describe("test-hotspots script", () => {
|
|
it("rejects Vitest reports without timed file results", () => {
|
|
const reportPath = join(mkTempRoot(), "empty-report.json");
|
|
writeFileSync(reportPath, `${JSON.stringify({ testResults: [] })}\n`, "utf8");
|
|
|
|
const result = runTestHotspots(["--report", reportPath]);
|
|
|
|
expect(result.status).toBe(1);
|
|
expect(result.stdout).toBe("");
|
|
expect(result.stderr).toContain("Vitest JSON report contained no timed file results.");
|
|
});
|
|
});
|