Skip to content

Commit ff3130e

Browse files
authored
test(eval): guard workspace path override compatibility
1 parent 919e457 commit ff3130e

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

‎apps/cli/test/eval.integration.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,31 @@ describe('agentv eval CLI', () => {
505505
}
506506
}, 30_000);
507507

508+
it('keeps --workspace-path as a static workspace override for existing workspaces', async () => {
509+
const fixture = await createFixture();
510+
try {
511+
const workspacePath = path.join(fixture.baseDir, 'prepared-workspace');
512+
await mkdir(workspacePath, { recursive: true });
513+
514+
const result = await runCli(fixture, [
515+
'eval',
516+
fixture.testFilePath,
517+
'--workspace-path',
518+
workspacePath,
519+
]);
520+
521+
expect(result.exitCode).toBe(0);
522+
const diagnostics = await readDiagnostics(fixture);
523+
expect(diagnostics).toMatchObject({
524+
workspaceMode: 'static',
525+
workspacePath,
526+
resultCount: 2,
527+
});
528+
} finally {
529+
await rm(fixture.baseDir, { recursive: true, force: true });
530+
}
531+
}, 30_000);
532+
508533
it('passes run-level budget tracking through to the evaluator', async () => {
509534
const fixture = await createFixture();
510535
try {

‎apps/cli/test/fixtures/mock-run-evaluation.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ interface RunEvaluationOptionsLike {
1919
readonly evalCases?: ReadonlyArray<unknown>;
2020
readonly verbose?: boolean;
2121
readonly maxConcurrency?: number;
22+
readonly workspaceMode?: string;
23+
readonly workspacePath?: string;
2224
readonly trials?: {
2325
readonly count: number;
2426
readonly strategy: string;
@@ -181,6 +183,8 @@ async function maybeWriteDiagnostics(
181183
envLocalOnly: process.env.CLI_ENV_LOCAL_ONLY ?? null,
182184
budgetUsd: options.budgetUsd ?? null,
183185
maxConcurrency: options.maxConcurrency ?? null,
186+
workspaceMode: options.workspaceMode ?? null,
187+
workspacePath: options.workspacePath ?? null,
184188
trials: options.trials ?? null,
185189
threshold: options.threshold ?? null,
186190
hasRunBudgetTracker: options.runBudgetTracker !== undefined,

‎packages/core/test/evaluation/workspace/setup.test.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,40 @@ describe('prepareSharedWorkspaceSetup', () => {
113113
expect(readFileSync(path.join(repoDir, 'tracked.txt'), 'utf8')).toBe('clean\n');
114114
expect(existsSync(path.join(repoDir, 'stale.txt'))).toBe(false);
115115
}, 30_000);
116+
117+
it('uses CLI workspacePath as an existing static workspace without materializing repos', async () => {
118+
const existingWorkspace = path.join(tmpDir, 'existing-workspace');
119+
mkdirSync(existingWorkspace, { recursive: true });
120+
writeFileSync(path.join(existingWorkspace, 'marker.txt'), 'already prepared\n', 'utf8');
121+
122+
const evalCase: EvalTest = {
123+
id: 'case-1',
124+
question: 'test',
125+
criteria: 'ok',
126+
workspace: {
127+
repos: [
128+
{
129+
path: './repo-a',
130+
repo: 'https://example.com/repo-a.git',
131+
commit: 'main',
132+
},
133+
],
134+
},
135+
};
136+
137+
setup = await prepareSharedWorkspaceSetup({
138+
evalRunId: 'test-cli-workspace-path',
139+
evalCases: [evalCase],
140+
evalDir: tmpDir,
141+
workspacePath: existingWorkspace,
142+
workers: 1,
143+
});
144+
145+
expect(setup.sharedWorkspacePath).toBe(existingWorkspace);
146+
expect(setup.repoManager).toBeUndefined();
147+
expect(readFileSync(path.join(existingWorkspace, 'marker.txt'), 'utf8')).toBe(
148+
'already prepared\n',
149+
);
150+
expect(existsSync(path.join(existingWorkspace, 'repo-a'))).toBe(false);
151+
});
116152
});

0 commit comments

Comments
 (0)