perf(ci): add sharded test runner phases
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { selectCiTestTargets } from "./run-ci-tests"
|
||||
|
||||
describe("test script isolation", () => {
|
||||
test("#given mock.module tests in the suite #then bun run test uses the isolated CI runner", async () => {
|
||||
@@ -8,4 +9,37 @@ describe("test script isolation", () => {
|
||||
//#then
|
||||
expect(packageJson.scripts.test).toBe("bun run script/run-ci-tests.ts")
|
||||
})
|
||||
|
||||
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"] })
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user