Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
test: exercise source test selection through Git and Vitest
morluto25711ad2590a
diff --git a/tests/boundary/filesystem/developmentTests.test.ts b/tests/boundary/filesystem/developmentTests.test.tsnew file mode 100644index 000000000..1b52bb475--- /dev/null+++ b/tests/boundary/filesystem/developmentTests.test.ts@@ -0,0 +1,110 @@+import {+ copyFile,+ mkdir,+ readFile,+ symlink,+ writeFile,+} from "node:fs/promises";+import { join } from "node:path";++import { expect, it } from "vitest";++import { execFileOutput } from "../../../src/process/ExecFileOutput.js";+import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";++const run = (root: string, command: string, arguments_: readonly string[]) =>+ execFileOutput(command, arguments_, {+ cwd: root,+ stopSignal: "SIGTERM",+ timeout: 20_000,+ });++const commit = (root: string, message: string) =>+ run(root, "git", [+ "-c",+ "user.name=REA fixture",+ "-c",+ "[email protected]",+ "-c",+ "commit.gpgSign=false",+ "commit",+ "--quiet",+ "-m",+ message,+ ]);++const fixture = async () => {+ const root = await createTestTempDirectory("rea-development-tests-");+ await mkdir(join(root, "scripts", "lib"), { recursive: true });+ await mkdir(join(root, "src"));+ for (const path of [+ "scripts/run-development-tests.mjs",+ "scripts/lib/development-tests.mjs",+ ])+ await copyFile(join(process.cwd(), path), join(root, path));+ await symlink(+ join(process.cwd(), "node_modules"),+ join(root, "node_modules"),+ process.platform === "win32" ? "junction" : undefined,+ );+ await writeFile(join(root, "package.json"), '{"type":"module"}\n');+ await writeFile(join(root, ".gitignore"), "node_modules\nselected.txt\n");+ await writeFile(+ join(root, "vitest.config.mjs"),+ 'export default { test: { projects: [{ test: { name: "domain", include: ["src/**/*.test.ts"] } }] } };\n',+ );+ await writeFile(join(root, "src", "value.ts"), "export const value = 1;\n");+ await writeFile(+ join(root, "src", "value.test.ts"),+ 'import { expect, it } from "vitest"; import { writeFileSync } from "node:fs"; import { value } from "./value.js"; it("checks the selected source", () => { expect(value).toBe(1); writeFileSync("selected.txt", String(value)); });\n',+ );+ await run(root, "git", ["init", "--quiet"]);+ await run(root, "git", ["add", "."]);+ await commit(root, "fixture");+ return root;+};++const testCommand = (root: string, ...arguments_: string[]) =>+ run(root, process.execPath, [+ "scripts/run-development-tests.mjs",+ ...arguments_,+ ]);++it("executes an explicitly selected source test on a clean tree without build artifacts", async () => {+ const root = await fixture();+ const { stdout: status } = await run(root, "git", ["status", "--porcelain"]);+ expect(status).toBe("");+ await testCommand(root, "local", "src/value.test.ts");+ expect(await readFile(join(root, "selected.txt"), "utf8")).toBe("1");+});++it("uses committed dependency changes since the requested Git base to select source tests", async () => {+ const root = await fixture();+ const { stdout: base } = await run(root, "git", ["rev-parse", "HEAD"]);+ await writeFile(join(root, "src", "value.ts"), "export const value = 2;\n");+ await run(root, "git", ["add", "src/value.ts"]);+ await commit(root, "change dependency");+ await expect(+ testCommand(root, "changed", "--base", base.trim()),+ ).rejects.toMatchObject({+ code: 1,+ stdout: expect.stringContaining("src/value.test.ts"),+ stderr: expect.stringContaining("expected 2 to be 1"),+ });+});++it("rejects a compiled boundary in the source-only command and a missing exact test", async () => {+ const root = await fixture();+ await expect(+ testCommand(root, "local", "tests/acceptance/runtime.test.ts"),+ ).rejects.toMatchObject({+ code: 1,+ stderr: expect.stringContaining("Use test:focused"),+ });+ await expect(+ testCommand(root, "local", "src/missing.test.ts"),+ ).rejects.toMatchObject({+ code: 1,+ stderr: expect.stringContaining("ENOENT"),+ });+});diff --git a/tests/evaluation/developmentTestPlan.test.ts b/tests/evaluation/developmentTestPlan.test.tsdeleted file mode 100644index 0544aa1f4..000000000--- a/tests/evaluation/developmentTestPlan.test.ts+++ /dev/null@@ -1,87 +0,0 @@-import { describe, expect, it } from "vitest";--import {- developmentTestPlan,- parseDevelopmentTestRequest,-} from "../../scripts/lib/development-tests.mjs";--describe("development test selection", () => {- it("keeps dirty source feedback independent of compiled artifacts", () => {- const plan = developmentTestPlan(parseDevelopmentTestRequest("local", []));- expect(plan.needsBuild).toBe(false);- expect(plan.vitestArguments).toContain("--changed");- expect(plan.vitestArguments).not.toContain("acceptance");- expect(plan.vitestArguments).not.toContain("process-global");- });-- it("always runs explicitly selected source tests, including on a clean tree", () => {- const path = "src/config.test.ts";- const plan = developmentTestPlan(- parseDevelopmentTestRequest("local", [path, path]),- );- expect(plan.needsBuild).toBe(false);- expect(- plan.vitestArguments.filter((argument) => argument === path),- ).toHaveLength(1);- expect(- plan.vitestArguments.some((argument) => argument.startsWith("--changed")),- ).toBe(false);- expect(plan.vitestArguments).not.toContain("--passWithNoTests");- });-- it("builds before explicitly selected compiled boundaries", () => {- const plan = developmentTestPlan(- parseDevelopmentTestRequest("focused", [- "src/config.test.ts",- "tests/acceptance/applications/runtime.test.ts",- ]),- );- expect(plan.needsBuild).toBe(true);- expect(plan.vitestArguments).not.toContain("--changed");- });-- it("prepares test catalogs and managed evidence only for their consumers", () => {- const ordinary = developmentTestPlan(- parseDevelopmentTestRequest("focused", [- "tests/boundary/mcp/sessionMcp.test.ts",- ]),- );- expect(ordinary.artifactTasks).toEqual([]);- const consumers = developmentTestPlan(- parseDevelopmentTestRequest("focused", [- "tests/boundary/mcp/toolSchemaValidity.test.ts",- "tests/boundary/filesystem/setupSkill.test.ts",- ]),- );- expect(consumers.artifactTasks).toEqual([- "artifacts:mcp-catalog",- "artifacts:managed-evidence",- ]);- });-- it("uses the resolved branch merge base for committed source changes", () => {- const request = parseDevelopmentTestRequest("changed", ["--base", "main"]);- const plan = developmentTestPlan(request, "a".repeat(40));- expect(request.base).toBe("main");- expect(plan.vitestArguments).toContain(`--changed=${"a".repeat(40)}`);- expect(() => developmentTestPlan(request)).toThrow(- "resolved Git merge base",- );- });-- it.each([- ["focused", []],- ["focused", ["../src/config.test.ts"]],- ["focused", ["src/../config.test.ts"]],- ["focused", ["--passWithNoTests"]],- ["focused", ["--changed"]],- ["local", ["tests/acceptance/applications/runtime.test.ts"]],- ["changed", ["--base"]],- ["changed", ["--base=--help"]],- ["changed", ["src/config.test.ts"]],- ["local", ["--base", "main"]],- ["unknown", []],- ])("rejects invalid %s selections: %j", (mode, paths) => {- expect(() => parseDevelopmentTestRequest(mode, paths)).toThrow();- });-});