Files
adolf/test/scripts/test-skip-inventory.test.ts
alvis bedb527145
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Vendor OpenClaw source as Adolf fork baseline
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11),
free to diverge. Tree copied sans upstream .git; upstream remote added for
future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19.
Preserves docs/ARCHITECTURE.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
2026-07-05 09:36:54 +00:00

289 lines
7.9 KiB
TypeScript

// Test Skip Inventory tests cover skipped, conditional, todo, and focused test reporting.
import { spawnSync } from "node:child_process";
import fs from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
import {
collectTestSkipInventoryReport,
renderTestSkipInventoryReport,
type TestSkipInventoryReport,
} from "../../scripts/test-skip-inventory.js";
import { createScriptTestHarness } from "./test-helpers.js";
const { createTempDir } = createScriptTestHarness();
function writeRepoFile(repoRoot: string, relativePath: string, value: string): void {
const filePath = path.join(repoRoot, relativePath);
fs.mkdirSync(path.dirname(filePath), { recursive: true });
fs.writeFileSync(filePath, value, "utf8");
}
function makeSkipInventoryFixture(): string {
const repoRoot = createTempDir("openclaw-test-skip-inventory-");
writeRepoFile(
repoRoot,
"src/runtime.ts",
`
describe.skip("ignored because this is not a test file", () => {});
`,
);
writeRepoFile(
repoRoot,
"src/example.test.ts",
`
describe.skip("temporarily disabled suite", () => {});
it.skipIf(process.platform === "win32")("uses POSIX shell", () => {});
test.todo("covers migration edge");
it.only("focused during local debugging", () => {});
const posixIt = process.platform === "win32" ? it.skip : it;
(process.platform === "win32" ? it.skip : it)("uses terminal fixtures", () => {});
it.runIf(process.platform !== "win32")("runs only on POSIX", () => {});
it.runIf(process.platform !== "win32").each(["SIGTERM"] as const)("handles %s", () => {});
const runIfPowerShell = powershell ? it : it.skip;
it.concurrent.only("focused concurrent test", () => {});
test.sequential.skip("skipped sequential test", () => {});
const fixture = 'describe.skip("not code", () => {})';
`,
);
writeRepoFile(
repoRoot,
"test/e2e/qa-lab/runtime/qa-otel-smoke-runtime.ts",
`
reader.skip(wire);
`,
);
writeRepoFile(
repoRoot,
"test/scripts/test-live.test.ts",
`
const posixIt = process.platform === "win32" ? it.skip : it;
`,
);
writeRepoFile(
repoRoot,
"extensions/provider/live.test.ts",
`
const LIVE = process.env.OPENCLAW_LIVE_TEST === "1";
const describeLive = LIVE ? describe : describe.skip;
describeLive("provider live", () => {});
`,
);
writeRepoFile(
repoRoot,
"ui/src/e2e/chat-flow.e2e.test.ts",
`
const describeControlUiE2e = chromiumAvailable || !allowMissingChromium ? describe : describe.skip;
describeControlUiE2e("control UI", () => {});
`,
);
return repoRoot;
}
describe("collectTestSkipInventoryReport", () => {
it("reports skipped, conditional, todo, and focused test inventory", () => {
const report = collectTestSkipInventoryReport({ repoRoot: makeSkipInventoryFixture() });
expect(
report.findings.map((finding) => ({
file: finding.file,
kind: finding.kind,
method: finding.method,
reason: finding.reason,
target: finding.target,
})),
).toEqual([
{
file: "extensions/provider/live.test.ts",
kind: "alias",
method: "skip",
reason: "live-gate",
target: "describe",
},
{
file: "src/example.test.ts",
kind: "call",
method: "skip",
reason: "explicit-skip",
target: "describe",
},
{
file: "src/example.test.ts",
kind: "call",
method: "skipIf",
reason: "platform-gate",
target: "it",
},
{
file: "src/example.test.ts",
kind: "call",
method: "todo",
reason: "todo",
target: "test",
},
{
file: "src/example.test.ts",
kind: "call",
method: "only",
reason: "focused-only",
target: "it",
},
{
file: "src/example.test.ts",
kind: "alias",
method: "skip",
reason: "platform-gate",
target: "it",
},
{
file: "src/example.test.ts",
kind: "call",
method: "skip",
reason: "platform-gate",
target: "it",
},
{
file: "src/example.test.ts",
kind: "call",
method: "runIf",
reason: "platform-gate",
target: "it",
},
{
file: "src/example.test.ts",
kind: "call",
method: "runIf",
reason: "platform-gate",
target: "it",
},
{
file: "src/example.test.ts",
kind: "alias",
method: "skip",
reason: "conditional-skip",
target: "it",
},
{
file: "src/example.test.ts",
kind: "call",
method: "only",
reason: "focused-only",
target: "it",
},
{
file: "src/example.test.ts",
kind: "call",
method: "skip",
reason: "explicit-skip",
target: "test",
},
{
file: "test/scripts/test-live.test.ts",
kind: "alias",
method: "skip",
reason: "platform-gate",
target: "it",
},
{
file: "ui/src/e2e/chat-flow.e2e.test.ts",
kind: "alias",
method: "skip",
reason: "optional-dependency",
target: "describe",
},
]);
expect(report.summary).toMatchObject({
findingCount: 14,
reasonCounts: {
"conditional-skip": 1,
"explicit-skip": 2,
"focused-only": 2,
"live-gate": 1,
"optional-dependency": 1,
"platform-gate": 6,
todo: 1,
},
touchedFileCount: 4,
});
});
it("renders a compact non-blocking text report", () => {
const report = collectTestSkipInventoryReport({ repoRoot: makeSkipInventoryFixture() });
const rendered = renderTestSkipInventoryReport(report, { limit: 4 });
expect(rendered).toContain("OpenClaw test skip inventory");
expect(rendered).toContain("Findings: 14 in 4 file(s)");
expect(rendered).toContain("platform-gate: 6");
expect(rendered).toContain("- src/example.test.ts (11)");
expect(rendered).toContain("L2 describe.skip explicit-skip");
expect(rendered).toContain("... 10 more finding(s) not shown");
});
it("prints JSON from the CLI and exits successfully", () => {
const repoRoot = makeSkipInventoryFixture();
const result = spawnSync(
process.execPath,
[
"--import",
"tsx",
path.join(process.cwd(), "scripts/test-skip-inventory.ts"),
"--",
"--repo-root",
repoRoot,
"--json",
],
{
encoding: "utf8",
},
);
expect(result.status).toBe(0);
const report = JSON.parse(result.stdout) as TestSkipInventoryReport;
expect(report.summary.findingCount).toBe(14);
expect(report.summary.reasonCounts["focused-only"]).toBe(2);
});
it("prints CLI help without scanning the repository", () => {
const result = spawnSync(
process.execPath,
["--import", "tsx", path.join(process.cwd(), "scripts/test-skip-inventory.ts"), "--help"],
{
encoding: "utf8",
},
);
expect(result.status).toBe(0);
expect(result.stdout).toContain("Usage:");
expect(result.stdout).toContain("pnpm test:skip-inventory:report");
expect(result.stdout).not.toContain("Scanned files:");
expect(result.stderr).toBe("");
});
it("rejects missing CLI repo roots and loose limits before scanning", () => {
for (const args of [
["--repo-root", "--json"],
["--limit", "1e3", "--repo-root", createTempDir("openclaw-skip-limit-")],
]) {
const result = spawnSync(
process.execPath,
[
"--import",
"tsx",
path.join(process.cwd(), "scripts/test-skip-inventory.ts"),
"--",
...args,
],
{
encoding: "utf8",
},
);
expect(result.status).toBe(1);
expect(result.stderr).toMatch(
/--repo-root expects a path|--limit expects a non-negative integer/u,
);
expect(result.stdout).not.toContain("Scanned files:");
}
});
});