Files
YeonGyu-Kim 4f9813848a feat: add ci test runner, session routing, bash parser, and test fixtures
- script/run-ci-tests.ts: CI test sharding and isolation logic
- script/run-ci-tests.test.ts: tests for CI test target selection
- src/features/background-agent/session-route.ts: session prompt routing for background agents
- src/hooks/interactive-bash-session/parser.ts: interactive bash output parser
- src/hooks/ralph-loop/completion-promise-detector-test-input.ts: test fixture for completion promise detection
2026-05-16 23:51:43 +09:00

46 lines
1.8 KiB
TypeScript

import { describe, expect, test } from "bun:test"
import { selectCiTestTargets } from "./run-ci-tests"
describe("plain test script policy", () => {
test("#given mock.module tests in the suite #then bun run test remains the package test script", async () => {
//#given
const packageJson = await Bun.file("package.json").json()
//#then
expect(packageJson.scripts.test).toBe("bun test")
})
test("#given isolated test shards #when selecting targets #then shards are deterministic and complete", () => {
// given
const ciTestPlan = {
isolatedModuleMockFiles: [],
isolatedTestTargets: ["a.test.ts", "b.test.ts", "c.test.ts", "d.test.ts", "e.test.ts"],
sharedTestFiles: ["shared.test.ts"],
}
// when
const shardOne = selectCiTestTargets(ciTestPlan, { phase: "isolated", shardCount: 2, shardIndex: 0 })
const shardTwo = selectCiTestTargets(ciTestPlan, { phase: "isolated", shardCount: 2, shardIndex: 1 })
// then
expect(shardOne).toEqual({ isolatedTestTargets: ["a.test.ts", "c.test.ts", "e.test.ts"], sharedTestFiles: [] })
expect(shardTwo).toEqual({ isolatedTestTargets: ["b.test.ts", "d.test.ts"], sharedTestFiles: [] })
expect([...shardOne.isolatedTestTargets, ...shardTwo.isolatedTestTargets].sort()).toEqual(ciTestPlan.isolatedTestTargets)
})
test("#given shared phase #when selecting targets #then only shared tests run", () => {
// given
const ciTestPlan = {
isolatedModuleMockFiles: [],
isolatedTestTargets: ["isolated.test.ts"],
sharedTestFiles: ["shared.test.ts"],
}
// when
const selectedTargets = selectCiTestTargets(ciTestPlan, { phase: "shared", shardCount: 1, shardIndex: 0 })
// then
expect(selectedTargets).toEqual({ isolatedTestTargets: [], sharedTestFiles: ["shared.test.ts"] })
})
})