Skip to content

Commit 4fe0ce2

Browse files
committed
Add a test of the e3-testsuite CLI args configuration
1 parent a3e3baa commit 4fe0ce2

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

integration/vscode/ada/src/e3Testsuite.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ export function activateE3TestsuiteIntegration(context: vscode.ExtensionContext)
219219
}
220220

221221
const run = controller.createTestRun(request, 'e3-testsuite');
222-
run.appendOutput(`Running: ${cmd.map((c) => '"' + c + '"').join(' ')}\n\r`);
223222

224223
const env = getEnv();
225224
if (enableEventSystem) {
@@ -241,6 +240,8 @@ export function activateE3TestsuiteIntegration(context: vscode.ExtensionContext)
241240
...(vscode.workspace.getConfiguration('e3-testsuite').get<string[]>('args') ?? []),
242241
);
243242

243+
run.appendOutput(`Running: ${cmd.map((c) => '"' + c + '"').join(' ')}\n\r`);
244+
244245
const cwd = vscode.workspace.workspaceFolders![0].uri.fsPath;
245246
await new Promise<void>((resolve, reject) => {
246247
const p = spawn(cmd[0], cmd.splice(1), {

integration/vscode/ada/test/e3-testsuite/e3_testsuite.test.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,76 @@ suite('e3-testsuite', function () {
408408
reset(spyCtrl);
409409
}
410410
});
411+
412+
test('Settings e3-testsuite.args', async function () {
413+
await e3.controller.refreshHandler!(new CancellationTokenSource().token);
414+
415+
// Get original configuration to restore later
416+
const config = workspace.getConfiguration('e3-testsuite');
417+
const originalArgs = config.get<string[]>('args');
418+
419+
try {
420+
// Set custom args in workspace configuration
421+
const testArgs = ['--verbose', '--show-time-info'];
422+
await config.update('args', testArgs, false);
423+
424+
const spyCtrl = spy(e3.controller);
425+
try {
426+
const mockRun = mock<TestRun>();
427+
let consoleOutput = '';
428+
when(mockRun.appendOutput(anything())).thenCall((output: string) => {
429+
consoleOutput += output.replace(/(\r+\n|\n\r+)/g, '\n');
430+
});
431+
432+
const run = instance(mockRun);
433+
434+
when(spyCtrl.createTestRun(anything())).thenReturn(run);
435+
when(spyCtrl.createTestRun(anything(), anything())).thenReturn(run);
436+
when(spyCtrl.createTestRun(anything(), anything(), anything())).thenReturn(run);
437+
438+
// Run the handler
439+
await e3.runHandler(
440+
{ include: undefined, exclude: undefined, profile: undefined },
441+
new CancellationTokenSource().token,
442+
);
443+
444+
// Check that the custom args appear in the console output
445+
assert.ok(
446+
consoleOutput.includes('--verbose'),
447+
`Expected '--verbose' argument not found in console output: ${consoleOutput}`,
448+
);
449+
assert.ok(
450+
consoleOutput.includes('--show-time-info'),
451+
`Expected '--show-time-info' argument not found in console output: ` +
452+
`${consoleOutput}`,
453+
);
454+
455+
// Verify the command line includes both the failure-exit-code and our custom args
456+
const commandLineRegex = /Running: ".*python.*" ".*testsuite\.py" ".*"/;
457+
const match = consoleOutput.match(commandLineRegex);
458+
assert.ok(match, `Command line not found in console output: ${consoleOutput}`);
459+
460+
const commandLine = match[0];
461+
assert.ok(
462+
commandLine.includes('--failure-exit-code=0'),
463+
`Expected '--failure-exit-code=0' not found in command: ${commandLine}`,
464+
);
465+
assert.ok(
466+
commandLine.includes('--verbose'),
467+
`Expected '--verbose' not found in command: ${commandLine}`,
468+
);
469+
assert.ok(
470+
commandLine.includes('--show-time-info'),
471+
`Expected '--show-time-info' not found in command: ${commandLine}`,
472+
);
473+
} finally {
474+
reset(spyCtrl);
475+
}
476+
} finally {
477+
// Always restore original configuration
478+
await config.update('args', originalArgs, false);
479+
}
480+
});
411481
});
412482

413483
interface TestResultItem {

0 commit comments

Comments
 (0)