test(scripts): route extensionless helper scripts

This commit is contained in:
Vincent Koc
2026-06-21 04:52:47 +02:00
parent 2f38b5aa2e
commit b2d78abe94
3 changed files with 33 additions and 0 deletions

View File

@@ -1059,6 +1059,8 @@ const TOOLING_SOURCE_TEST_TARGETS = new Map([
["scripts/run-oxlint-shards.mjs", ["test/scripts/run-oxlint.test.ts"]],
["scripts/run-with-env.mjs", ["test/scripts/run-with-env.test.ts"]],
["scripts/run-node.mjs", ["src/infra/run-node.test.ts"]],
["scripts/committer", ["test/scripts/committer.test.ts"]],
["scripts/gh-read", ["test/scripts/gh-read.test.ts"]],
["scripts/setup-auth-system.sh", ["test/scripts/test-projects.test.ts"]],
["scripts/ci-run-timings.mjs", ["test/scripts/ci-run-timings.test.ts"]],
["scripts/docker-e2e.mjs", ["test/scripts/docker-e2e-helper-cli.test.ts"]],

View File

@@ -1,4 +1,5 @@
// Gh Read tests cover gh read script behavior.
import { execFileSync } from "node:child_process";
import { afterEach, describe, expect, it, vi } from "vitest";
import {
buildReadPermissions,
@@ -16,6 +17,22 @@ describe("gh-read helpers", () => {
vi.useRealTimers();
});
it("prints wrapper usage before reading auth env", () => {
let stderr = "";
try {
execFileSync("bash", ["scripts/gh-read"], {
cwd: process.cwd(),
encoding: "utf8",
stdio: ["ignore", "pipe", "pipe"],
});
} catch (error) {
stderr = String((error as { stderr?: unknown }).stderr ?? error);
}
expect(stderr).toContain("usage: scripts/gh-read <gh args...>");
expect(stderr).toContain("OPENCLAW_GH_READ_APP_ID");
});
it("finds repo from gh args", () => {
expect(parseRepoArg(["pr", "view", "42", "-R", "openclaw/openclaw"])).toBe("openclaw/openclaw");
expect(parseRepoArg(["run", "list", "--repo=openclaw/docs"])).toBe("openclaw/docs");

View File

@@ -1348,6 +1348,20 @@ describe("scripts/test-projects changed-target routing", () => {
});
});
it("keeps extensionless helper script edits on owner tests", () => {
const expectedTargets = new Map([
["scripts/committer", ["test/scripts/committer.test.ts"]],
["scripts/gh-read", ["test/scripts/gh-read.test.ts"]],
]);
for (const [source, targets] of expectedTargets) {
expect(resolveChangedTestTargetPlan([source]), source).toEqual({
mode: "targets",
targets,
});
}
});
it("keeps shared script library edits on owner tests", () => {
const expectedTargets = new Map([
[