Skip to content

Commit d3c9bad

Browse files
committed
Merge branch 'topic/gnattest' into 'master'
Improve test invocation logging and task provider robustness See merge request eng/ide/ada_language_server!1944
2 parents 7b9105a + 3b160c5 commit d3c9bad

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

Diff for: integration/vscode/ada/src/gnattest.ts

+16-3
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,6 @@ async function handleRunRequestedTests(
624624
}
625625
const start = Date.now();
626626
run.started(test);
627-
const cmd = [execPath, '--passed-tests=show', `--routines=${test.id}`];
628627

629628
if (coverage) {
630629
/**
@@ -633,7 +632,17 @@ async function handleRunRequestedTests(
633632
env['GNATCOV_TRACE_FILE'] = getTracePath(test);
634633
}
635634

636-
const driver = logAndRun(run, cmd, env);
635+
/**
636+
* Use a path relative to the workspace root in the command line to
637+
* make log lines shorter.
638+
*/
639+
const cmd = [
640+
vscode.workspace.asRelativePath(execPath),
641+
'--passed-tests=show',
642+
`--routines=${test.id}`,
643+
];
644+
const testCwd = vscode.workspace.workspaceFolders![0].uri.fsPath;
645+
const driver = logAndRun(run, cmd, env, testCwd);
637646
const duration = Date.now() - start;
638647
if (driver.status !== null) {
639648
/**
@@ -1117,9 +1126,13 @@ function logAndRun(
11171126
run: vscode.TestRun,
11181127
cmd: string[],
11191128
env?: NodeJS.ProcessEnv,
1129+
cwd?: string,
11201130
): cp.SpawnSyncReturns<Buffer> {
11211131
run.appendOutput(`$ ${cmd.map((arg) => `"${arg}"`).join(' ')}\r\n`);
1122-
return cp.spawnSync(cmd[0], cmd.slice(1), { env: env });
1132+
return cp.spawnSync(cmd[0], cmd.slice(1), {
1133+
env: env,
1134+
cwd: cwd,
1135+
});
11231136
}
11241137

11251138
/**

Diff for: integration/vscode/ada/src/taskProviders.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,19 @@ export class SimpleTaskProvider implements vscode.TaskProvider {
534534
/**
535535
* If a test harness project exists, provide a task to build it.
536536
*/
537-
const harnessPrj = await getGnatTestDriverProjectPath();
538-
if (existsSync(harnessPrj)) {
537+
const harnessPrj = await getGnatTestDriverProjectPath().catch(
538+
/**
539+
* In case of errors fallback silently to keep providing tasks
540+
* even in case of errors.
541+
*/
542+
(reason) => {
543+
logger.error(
544+
'Error while querying for the GNATtest test driver project:\n' + reason,
545+
);
546+
return undefined;
547+
},
548+
);
549+
if (harnessPrj && existsSync(harnessPrj)) {
539550
taskDeclsToOffer.push({
540551
label: TASK_BUILD_TEST_DRIVER,
541552
taskDef: {

0 commit comments

Comments
 (0)