test(ci): deduplicate coverage command setup

This commit is contained in:
imccyu
2026-08-21 11:36:57 +08:00
parent 4f2868409d
commit 4b086d0a4a
+10 -10
View File
@@ -28,6 +28,14 @@ async function temporaryRoot(): Promise<string> {
return await mkdtemp(join(tmpdir(), 'dsh-coverage-partitions-'))
}
function successfulCommandRecorder(commands: CoverageCommand[]) {
return vi.fn(async (command: CoverageCommand) => {
commands.push(command)
await writeBlob(command)
return passed
})
}
describe('coverage partition count', () => {
it.each([
[undefined, undefined],
@@ -77,11 +85,7 @@ describe('coverage partition coordinator', () => {
it('runs every single-worker partition before one merged threshold check', async () => {
const root = await temporaryRoot()
const commands: CoverageCommand[] = []
const runCommand = vi.fn(async (command: CoverageCommand) => {
commands.push(command)
await writeBlob(command)
return passed
})
const runCommand = successfulCommandRecorder(commands)
const coordinator = new CoveragePartitionCoordinator({
root,
partitions: 3,
@@ -128,11 +132,7 @@ describe('coverage partition coordinator', () => {
it('runs a native pnpm entrypoint directly', async () => {
const root = await temporaryRoot()
const commands: CoverageCommand[] = []
const runCommand = vi.fn(async (command: CoverageCommand) => {
commands.push(command)
await writeBlob(command)
return passed
})
const runCommand = successfulCommandRecorder(commands)
const coordinator = new CoveragePartitionCoordinator({
root,
partitions: 2,