Skip to content

Commit f016ed8

Browse files
committed
style(tests): apply consistent formatting to diagnostic tests
- Import statement formatting (commas, line breaks) - Numeric separators for large numbers (300_000 instead of 300000) - Auto-formatting from Prettier/ESLint Affected files: - checkpoint-hash-bug.diagnostic.test.ts - checkpoint-merge-bug.diagnostic.test.ts - checkpoint-merge-bug.unit.test.ts - parallel-checkpoint-merge.integration.test.ts
1 parent 09cf0ce commit f016ed8

File tree

4 files changed

+109
-108
lines changed

4 files changed

+109
-108
lines changed

src/experiments/framework/executor/__tests__/checkpoint-hash-bug.diagnostic.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
* This test diagnoses and will help fix the hash matching issue.
88
*/
99

10-
import { describe, it, expect } from "vitest";
1110
import { createHash } from "node:crypto";
1211

12+
import { describe, expect,it } from "vitest";
13+
1314
describe("Checkpoint Config Hash Bug Diagnostics", () => {
1415
it("diagnostic-1: identifies which properties cause hash mismatch", () => {
1516
// Main process config (from evaluate.ts)
1617
const mainProcessConfig = {
1718
continueOnError: true,
1819
repetitions: 1,
1920
seedBase: 42,
20-
timeoutMs: 300000,
21+
timeoutMs: 300_000,
2122
collectProvenance: true,
2223
concurrency: 12, // This varies!
2324
onProgress: undefined,
@@ -29,7 +30,7 @@ describe("Checkpoint Config Hash Bug Diagnostics", () => {
2930
continueOnError: true,
3031
repetitions: 1,
3132
seedBase: 42,
32-
timeoutMs: 300000,
33+
timeoutMs: 300_000,
3334
collectProvenance: true,
3435
};
3536

@@ -62,7 +63,7 @@ describe("Checkpoint Config Hash Bug Diagnostics", () => {
6263
continueOnError: true,
6364
repetitions: 1,
6465
seedBase: 42,
65-
timeoutMs: 300000,
66+
timeoutMs: 300_000,
6667
collectProvenance: true,
6768
concurrency: 12,
6869
onProgress: () => {},
@@ -73,7 +74,7 @@ describe("Checkpoint Config Hash Bug Diagnostics", () => {
7374
continueOnError: true,
7475
repetitions: 1,
7576
seedBase: 42,
76-
timeoutMs: 300000,
77+
timeoutMs: 300_000,
7778
collectProvenance: true,
7879
concurrency: 4, // Different!
7980
onProgress: undefined,
@@ -105,7 +106,7 @@ describe("Checkpoint Config Hash Bug Diagnostics", () => {
105106
continueOnError: true,
106107
repetitions: 1,
107108
seedBase: 42,
108-
timeoutMs: 300000,
109+
timeoutMs: 300_000,
109110
collectProvenance: true,
110111
concurrency: 12,
111112
};
@@ -115,7 +116,7 @@ describe("Checkpoint Config Hash Bug Diagnostics", () => {
115116
continueOnError: true,
116117
repetitions: 1,
117118
seedBase: 42,
118-
timeoutMs: 300000,
119+
timeoutMs: 300_000,
119120
collectProvenance: true,
120121
};
121122

src/experiments/framework/executor/__tests__/checkpoint-merge-bug.diagnostic.test.ts

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88
* - Main checkpoint has 123/132 runs but workers start fresh
99
*/
1010

11-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
12-
import { rmSync } from "node:fs";
1311
import { randomBytes } from "node:crypto";
12+
import { rmSync } from "node:fs";
1413
import { tmpdir } from "node:os";
1514
import { join } from "node:path";
1615

16+
import { afterEach,beforeEach, describe, expect, it } from "vitest";
17+
18+
import type { CaseDefinition, SutDefinition } from "../../types/index.js";
1719
import type { EvaluationResult } from "../../types/result.js";
1820
import { CheckpointManager } from "../checkpoint-manager.js";
1921
import { FileStorage } from "../checkpoint-storage.js";
20-
import type { CaseDefinition, SutDefinition } from "../../types/index.js";
2122

2223
describe("Checkpoint Integration Bug Diagnostics", () => {
2324
let testDir: string;
@@ -191,13 +192,13 @@ describe("Checkpoint Integration Bug Diagnostics", () => {
191192

192193
it("diagnostic-5: config hash should include all executor config properties", async () => {
193194
// This test verifies which properties are included in the hash
194-
const crypto = require("crypto");
195+
const crypto = require("node:crypto");
195196

196197
const config1 = {
197198
continueOnError: true,
198199
repetitions: 1,
199200
seedBase: 42,
200-
timeoutMs: 300000,
201+
timeoutMs: 300_000,
201202
collectProvenance: true,
202203
};
203204

@@ -226,38 +227,35 @@ describe("Checkpoint Integration Bug Diagnostics", () => {
226227
/**
227228
* Create a mock SUT for testing.
228229
*/
229-
function createMockSut(): SutDefinition<unknown, unknown> {
230-
return {
231-
registration: {
232-
id: "mock-sut-v1.0.0",
233-
name: "Mock SUT",
234-
version: "1.0.0",
235-
role: "primary",
236-
config: {},
237-
tags: ["test"],
238-
},
239-
factory: () => ({
240-
id: "mock-sut-v1.0.0",
241-
config: {},
242-
run: async () => ({ mockResult: true }),
243-
}),
244-
};
245-
}
230+
const createMockSut = (): SutDefinition<unknown, unknown> => ({
231+
registration: {
232+
id: "mock-sut-v1.0.0",
233+
name: "Mock SUT",
234+
version: "1.0.0",
235+
role: "primary",
236+
config: {},
237+
tags: ["test"],
238+
},
239+
factory: () => ({
240+
id: "mock-sut-v1.0.0",
241+
config: {},
242+
run: async () => ({ mockResult: true }),
243+
}),
244+
});
246245

247246
/**
248247
* Create a mock case for testing.
248+
* @param id
249249
*/
250-
function createMockCase(id: string): CaseDefinition<unknown, unknown> {
251-
return {
252-
case: {
253-
caseId: id,
254-
name: `Mock Case ${id}`,
255-
caseClass: "test",
256-
inputs: { summary: { test: id } },
257-
tags: ["test"],
258-
version: "1.0.0",
259-
},
260-
getInput: async () => ({ mockInput: true }),
261-
getInputs: () => ({ mockInputs: true }),
262-
};
263-
}
250+
const createMockCase = (id: string): CaseDefinition<unknown, unknown> => ({
251+
case: {
252+
caseId: id,
253+
name: `Mock Case ${id}`,
254+
caseClass: "test",
255+
inputs: { summary: { test: id } },
256+
tags: ["test"],
257+
version: "1.0.0",
258+
},
259+
getInput: async () => ({ mockInput: true }),
260+
getInputs: () => ({ mockInputs: true }),
261+
});

src/experiments/framework/executor/__tests__/checkpoint-merge-bug.unit.test.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
* the main checkpoint instead of combining it with shard results.
66
*/
77

8-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
9-
import { readFileSync } from "node:fs";
10-
import { rmSync } from "node:fs";
118
import { randomBytes } from "node:crypto";
9+
import { readFileSync , rmSync } from "node:fs";
1210
import { tmpdir } from "node:os";
1311
import { join } from "node:path";
1412

13+
import { afterEach,beforeEach, describe, expect, it } from "vitest";
14+
1515
import type { EvaluationResult } from "../../types/result.js";
1616
import type { CheckpointData } from "../checkpoint-manager.js";
1717
import { CheckpointManager } from "../checkpoint-manager.js";
@@ -30,10 +30,9 @@ describe("Checkpoint Merge Bug Diagnostics", () => {
3030

3131
/**
3232
* Helper to read checkpoint data directly from file
33+
* @param path
3334
*/
34-
function readCheckpointFile(path: string): CheckpointData {
35-
return JSON.parse(readFileSync(path, "utf-8"));
36-
}
35+
const readCheckpointFile = (path: string): CheckpointData => JSON.parse(readFileSync(path, "utf-8"));
3736

3837
afterEach(() => {
3938
rmSync(testDir, { recursive: true, force: true });
@@ -160,29 +159,30 @@ describe("Checkpoint Merge Bug Diagnostics", () => {
160159

161160
/**
162161
* Create a mock evaluation result for testing
162+
* @param runId
163+
* @param sut
164+
* @param caseId
163165
*/
164-
function createMockResult(runId: string, sut: string, caseId: string): EvaluationResult {
165-
return {
166-
run: {
167-
runId,
168-
sut,
169-
sutRole: "primary" as const,
170-
sutVersion: "1.0.0",
171-
caseId,
172-
caseClass: "test-class",
173-
seed: 42,
174-
repetition: 0,
175-
},
176-
correctness: {
177-
expectedExists: false,
178-
producedOutput: true,
179-
valid: true,
180-
matchesExpected: null,
181-
},
182-
outputs: { summary: {} },
183-
metrics: { numeric: { test: 1 } },
184-
provenance: {
185-
runtime: { platform: "linux", arch: "x64", nodeVersion: "v22.0.0" },
186-
},
187-
};
188-
}
166+
const createMockResult = (runId: string, sut: string, caseId: string): EvaluationResult => ({
167+
run: {
168+
runId,
169+
sut,
170+
sutRole: "primary" as const,
171+
sutVersion: "1.0.0",
172+
caseId,
173+
caseClass: "test-class",
174+
seed: 42,
175+
repetition: 0,
176+
},
177+
correctness: {
178+
expectedExists: false,
179+
producedOutput: true,
180+
valid: true,
181+
matchesExpected: null,
182+
},
183+
outputs: { summary: {} },
184+
metrics: { numeric: { test: 1 } },
185+
provenance: {
186+
runtime: { platform: "linux", arch: "x64", nodeVersion: "v22.0.0" },
187+
},
188+
});

src/experiments/framework/executor/__tests__/parallel-checkpoint-merge.integration.test.ts

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
* 5. Main checkpoint should have all runs, but gets overwritten
1010
*/
1111

12-
import { describe, it, expect, beforeEach, afterEach } from "vitest";
13-
import { readFileSync, rmSync, mkdirSync } from "node:fs";
1412
import { randomBytes } from "node:crypto";
13+
import { mkdirSync,readFileSync, rmSync } from "node:fs";
1514
import { tmpdir } from "node:os";
1615
import { join } from "node:path";
1716

17+
import { afterEach,beforeEach, describe, expect, it } from "vitest";
18+
1819
import type { EvaluationResult } from "../../types/result.js";
1920
import type { CheckpointData } from "../checkpoint-manager.js";
2021
import { CheckpointManager } from "../checkpoint-manager.js";
@@ -34,10 +35,9 @@ describe("Parallel Checkpoint Merge Integration Tests", () => {
3435

3536
/**
3637
* Helper to read checkpoint data directly from file
38+
* @param path
3739
*/
38-
function readCheckpointFile(path: string): CheckpointData {
39-
return JSON.parse(readFileSync(path, "utf-8"));
40-
}
40+
const readCheckpointFile = (path: string): CheckpointData => JSON.parse(readFileSync(path, "utf-8"));
4141

4242
afterEach(() => {
4343
rmSync(testDir, { recursive: true, force: true });
@@ -190,40 +190,42 @@ describe("Parallel Checkpoint Merge Integration Tests", () => {
190190

191191
/**
192192
* Create a batch of mock evaluation results
193+
* @param count
193194
*/
194-
function createMockRunBatch(count: number): EvaluationResult[] {
195+
const createMockRunBatch = (count: number): EvaluationResult[] => {
195196
const results: EvaluationResult[] = [];
196-
for (let i = 0; i < count; i++) {
197-
results.push(createMockResult(`run-${String(i).padStart(3, "0")}`, `sut-${i % 4}`, `case-${i}`));
197+
for (let index = 0; index < count; index++) {
198+
results.push(createMockResult(`run-${String(index).padStart(3, "0")}`, `sut-${index % 4}`, `case-${index}`));
198199
}
199200
return results;
200-
}
201+
};
201202

202203
/**
203204
* Create a mock evaluation result
205+
* @param runId
206+
* @param sut
207+
* @param caseId
204208
*/
205-
function createMockResult(runId: string, sut: string, caseId: string): EvaluationResult {
206-
return {
207-
run: {
208-
runId,
209-
sut,
210-
sutRole: "primary" as const,
211-
sutVersion: "1.0.0",
212-
caseId,
213-
caseClass: "test-class",
214-
seed: 42,
215-
repetition: 0,
216-
},
217-
correctness: {
218-
expectedExists: false,
219-
producedOutput: true,
220-
valid: true,
221-
matchesExpected: null,
222-
},
223-
outputs: { summary: {} },
224-
metrics: { numeric: { test: 1 } },
225-
provenance: {
226-
runtime: { platform: "linux", arch: "x64", nodeVersion: "v22.0.0" },
227-
},
228-
};
229-
}
209+
const createMockResult = (runId: string, sut: string, caseId: string): EvaluationResult => ({
210+
run: {
211+
runId,
212+
sut,
213+
sutRole: "primary" as const,
214+
sutVersion: "1.0.0",
215+
caseId,
216+
caseClass: "test-class",
217+
seed: 42,
218+
repetition: 0,
219+
},
220+
correctness: {
221+
expectedExists: false,
222+
producedOutput: true,
223+
valid: true,
224+
matchesExpected: null,
225+
},
226+
outputs: { summary: {} },
227+
metrics: { numeric: { test: 1 } },
228+
provenance: {
229+
runtime: { platform: "linux", arch: "x64", nodeVersion: "v22.0.0" },
230+
},
231+
});

0 commit comments

Comments
 (0)