From b2d78abe94d56a96f88d335d1fbd78dfa0df1778 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 21 Jun 2026 04:52:47 +0200 Subject: [PATCH] test(scripts): route extensionless helper scripts --- scripts/test-projects.test-support.mjs | 2 ++ test/scripts/gh-read.test.ts | 17 +++++++++++++++++ test/scripts/test-projects.test.ts | 14 ++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/scripts/test-projects.test-support.mjs b/scripts/test-projects.test-support.mjs index ca33cb9a500b..f19a11e23232 100644 --- a/scripts/test-projects.test-support.mjs +++ b/scripts/test-projects.test-support.mjs @@ -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"]], diff --git a/test/scripts/gh-read.test.ts b/test/scripts/gh-read.test.ts index ab8c79d80e58..2be3e67f8ebb 100644 --- a/test/scripts/gh-read.test.ts +++ b/test/scripts/gh-read.test.ts @@ -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 "); + 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"); diff --git a/test/scripts/test-projects.test.ts b/test/scripts/test-projects.test.ts index fd902321fdc5..ed499afa2a54 100644 --- a/test/scripts/test-projects.test.ts +++ b/test/scripts/test-projects.test.ts @@ -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([ [