Skip to content

Commit baafa95

Browse files
author
automatic-merge
committedAug 14, 2024
Merge remote branch 'origin/master' into edge
2 parents 679968f + 7a3e670 commit baafa95

File tree

6 files changed

+79
-32
lines changed

6 files changed

+79
-32
lines changed
 

‎.github/workflows/build-binaries.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,6 @@ jobs:
9898
AWS_DEFAULT_REGION: eu-west-1
9999
run: |
100100
for FILE in *.vsix ; do
101-
aws s3 cp ${FILE} s3://adacore-gha-tray-eu-west-1/vscode-extension/${TAG}/ --sse=AES256
101+
aws s3 cp ${FILE} s3://als-publish-adacore-eu-west-1/vscode-extension/${TAG}/ --sse=AES256
102102
done
103-
aws s3 ls s3://adacore-gha-tray-eu-west-1/vscode-extension/${TAG}/
103+
aws s3 ls s3://als-publish-adacore-eu-west-1/vscode-extension/${TAG}/

‎.vscode/settings.json.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
"source.fixAll.eslint": true
6666
}
6767
},
68+
"[javascript]": {
69+
"editor.defaultFormatter": "esbenp.prettier-vscode",
70+
"editor.formatOnSave": true
71+
},
6872
"[json]": {
6973
"editor.formatOnSave": true,
7074
"editor.defaultFormatter": "esbenp.prettier-vscode",

‎integration/vscode/ada/test/suite/general/extension.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { assertEqualToFileContent, activate } from '../utils';
55

66
import * as vscode from 'vscode';
77
import { readFileSync, writeFileSync } from 'fs';
8+
import { basename } from 'path';
89

910
suite('Extensions Test Suite', function () {
1011
// Make sure the extension is activated
@@ -14,8 +15,8 @@ suite('Extensions Test Suite', function () {
1415
test('Project File Response', async () => {
1516
if (vscode.workspace.workspaceFolders !== undefined) {
1617
const result: string = await getProjectFile(adaExtState.adaClient);
17-
const name = result.replace(/^.*[\\/]/, '');
18-
assert.strictEqual(name, 'default.gpr');
18+
const name = basename(result);
19+
assert.strictEqual(name, 'prj.gpr');
1920
} else {
2021
throw new Error('No workspace folder found for the specified URI');
2122
}

‎integration/vscode/ada/test/suite/general/tasks.test.ts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import {
1717
closeAllEditors,
1818
getCmdLine,
1919
getCommandLines,
20+
isCoreTask,
21+
isGNATSASTask,
22+
negate,
2023
runTaskAndGetResult,
2124
testTask,
2225
} from '../utils';
@@ -44,13 +47,7 @@ ada: Clean current project
4447
ada: Build current project
4548
ada: Check current file
4649
ada: Compile current file
47-
ada: Analyze the project with GNAT SAS
48-
ada: Analyze the current file with GNAT SAS
49-
ada: Create a report after a GNAT SAS analysis
50-
ada: Analyze the project with GNAT SAS and produce a report
51-
ada: Analyze the current file with GNAT SAS and produce a report
5250
ada: Generate documentation from the project
53-
ada: Create/update test skeletons for the project
5451
ada: Build main - src/main1.adb
5552
ada: Run main - src/main1.adb
5653
ada: Build and run main - src/main1.adb
@@ -59,7 +56,10 @@ ada: Run main - src/test.adb
5956
ada: Build and run main - src/test.adb
6057
`.trim();
6158

62-
const actualTaskList = tasks.map((t) => `${t.source}: ${t.name}`).join('\n');
59+
const actualTaskList = tasks
60+
.filter(isCoreTask)
61+
.map((t) => `${t.source}: ${t.name}`)
62+
.join('\n');
6363
assert.strictEqual(actualTaskList, expectedTasksList);
6464
});
6565

@@ -69,19 +69,18 @@ ada: Clean current project - gprclean -P ${projectPath}
6969
ada: Build current project - gprbuild -P ${projectPath} -cargs:ada -gnatef
7070
ada: Check current file - gprbuild -q -f -c -u -gnatc -P ${projectPath} \${fileBasename} -cargs:ada -gnatef
7171
ada: Compile current file - gprbuild -q -f -c -u -P ${projectPath} \${fileBasename} -cargs:ada -gnatef
72-
ada: Analyze the project with GNAT SAS - gnatsas analyze -P ${projectPath}
73-
ada: Analyze the current file with GNAT SAS - gnatsas analyze -P ${projectPath} --file=\${fileBasename}
74-
ada: Create a report after a GNAT SAS analysis - gnatsas report sarif -P ${projectPath} -o report.sarif
7572
ada: Generate documentation from the project - gnatdoc -P ${projectPath}
76-
ada: Create/update test skeletons for the project - gnattest -P ${projectPath}
7773
ada: Build main - src/main1.adb - gprbuild -P ${projectPath} src/main1.adb -cargs:ada -gnatef
7874
ada: Run main - src/main1.adb - obj/main1exec${exe}
7975
ada: Build main - src/test.adb - gprbuild -P ${projectPath} src/test.adb -cargs:ada -gnatef
8076
ada: Run main - src/test.adb - obj/test${exe}
8177
`.trim();
8278

8379
const prov = createAdaTaskProvider();
84-
const actualCommandLines = await getCommandLines(prov);
80+
/**
81+
* Exclude GNAT SAS tasks because they are tested in integration-testsuite.
82+
*/
83+
const actualCommandLines = await getCommandLines(prov, isCoreTask);
8584
assert.equal(actualCommandLines, expectedCmdLines);
8685
});
8786

@@ -283,7 +282,7 @@ suite('Task Execution', function () {
283282

284283
this.beforeAll(async () => {
285284
await activate();
286-
allProvidedTasks.push(...(await createAdaTaskProvider().provideTasks()));
285+
allProvidedTasks.push(...(await createAdaTaskProvider().provideTasks()).filter(isCoreTask));
287286
});
288287

289288
this.beforeEach(async function () {
@@ -300,13 +299,7 @@ suite('Task Execution', function () {
300299
declTaskTest('ada: Build main - src/test.adb');
301300
declTaskTest('ada: Build and run main - src/main1.adb');
302301
declTaskTest('ada: Build and run main - src/test.adb');
303-
declTaskTest('ada: Analyze the project with GNAT SAS');
304-
declTaskTest('ada: Create a report after a GNAT SAS analysis');
305-
declTaskTest('ada: Analyze the project with GNAT SAS and produce a report');
306-
declTaskTest('ada: Analyze the current file with GNAT SAS and produce a report', openSrcFile);
307-
declTaskTest('ada: Analyze the current file with GNAT SAS', openSrcFile);
308302
declTaskTest('ada: Generate documentation from the project');
309-
declTaskTest('ada: Create/update test skeletons for the project');
310303

311304
/**
312305
* Check that the 'buildAndRunMain' task works fine with projects that

‎integration/vscode/ada/test/suite/utils.ts

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,17 @@ export async function activate(): Promise<void> {
8282
* provider that are based on a ShellExecution. The string includes the command
8383
* line of each task.
8484
*/
85-
export async function getCommandLines(prov: SimpleTaskProvider) {
86-
const tasks = await prov.provideTasks();
85+
export async function getCommandLines(
86+
prov: SimpleTaskProvider,
87+
filter?: (t: vscode.Task) => boolean
88+
) {
89+
let tasks = await prov.provideTasks();
8790
assert(tasks);
8891

92+
if (filter) {
93+
tasks = tasks.filter(filter);
94+
}
95+
8996
const actualCommandLines = (
9097
await Promise.all(
9198
tasks.map(async (t) => {
@@ -191,14 +198,14 @@ export function getCmdLine(exec: vscode.ShellExecution) {
191198
*/
192199
export async function testTask(
193200
taskName: string,
194-
testedTasks: Set<string>,
201+
testedTasks?: Set<string>,
195202
allProvidedTasks?: vscode.Task[]
196203
) {
197204
assert(vscode.workspace.workspaceFolders);
198205

199206
const task = await findTaskByName(taskName, allProvidedTasks);
200207
assert(task);
201-
testedTasks.add(getConventionalTaskLabel(task));
208+
testedTasks?.add(getConventionalTaskLabel(task));
202209

203210
const execStatus: number | undefined = await runTaskAndGetResult(task);
204211

@@ -220,18 +227,24 @@ export async function testTask(
220227
setTerminalEnvironment(env);
221228
const cp = spawnSync(cmdLine[0], cmdLine.slice(1), { cwd: cwd, env: env });
222229

223-
if (cp.status) {
230+
if (cp.status != null) {
224231
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
225232
msg += `\nProcess ended with exit code ${cp.status} and output:\n`;
226233
// msg += cp.stdout.toString() + cp.stderr.toString();
227234
msg += cp.output?.map((b) => (b != null ? b.toString() : '')).join('');
228-
} else {
235+
} else if (cp.signal != null) {
229236
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
230237
msg += `\nProcess ended with signal: ${cp.signal}`;
238+
} else if (cp.error != undefined) {
239+
throw cp.error;
231240
}
232241
} catch (error) {
233242
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
234243
msg += `\nEncountered an error: ${error}`;
244+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
245+
if (`${error}`.includes('ENOENT')) {
246+
msg += '\nIt is likely that the executable is not on PATH';
247+
}
235248
}
236249
}
237250

@@ -333,3 +346,39 @@ export function rangeToStr(range: vscode.Range): string {
333346
// eslint-disable-next-line max-len
334347
return `${range.start.line}:${range.start.character} -> ${range.end.line}:${range.end.character}`;
335348
}
349+
350+
/**
351+
* Utility filter for selecting GNAT SAS tasks.
352+
*/
353+
export function isGNATSASTask(t: vscode.Task): boolean {
354+
return t.name.includes('GNAT SAS');
355+
}
356+
357+
/**
358+
* Utility function for creating a predicated that is the negation of another predicate.
359+
*/
360+
export function negate<T extends unknown[]>(predicate: (...args: T) => boolean) {
361+
return (...inputs: T) => !predicate(...inputs);
362+
}
363+
364+
/**
365+
* Utility function for creating a predicated that is the negation of another predicate.
366+
*/
367+
export function and<T extends unknown[]>(...predicates: ((...args: T) => boolean)[]) {
368+
return (...inputs: T) => {
369+
return predicates.reduce<boolean>((acc, cur) => acc && cur(...inputs), true);
370+
};
371+
}
372+
373+
/**
374+
* Utility filter for selecting GNATtest tasks.
375+
*/
376+
export function isGNATTestTask(t: vscode.Task): boolean {
377+
return t.name.includes('test skeleton');
378+
}
379+
380+
/**
381+
* Utility filter for selecting core tasks that are not related to other tools
382+
* such as GNAT SAS or GNATtest.
383+
*/
384+
export const isCoreTask = and(negate(isGNATSASTask), negate(isGNATTestTask));

‎integration/vscode/ada/test/workspaces/general/default.gpr renamed to ‎integration/vscode/ada/test/workspaces/general/prj.gpr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
project Default is
1+
project Prj is
22

33
Tools_Mains :=
44
("main1.adb",
@@ -20,7 +20,7 @@ project Default is
2020
-- This project contains intentionally invalid code which causes gnatdoc
2121
-- to fail when testing the corresponding vscode task. This gets the
2222
-- project skipped by gnatdoc for the purpose of testing.
23-
for Excluded_Project_Files use ("default.gpr");
23+
for Excluded_Project_Files use ("prj.gpr");
2424
end Documentation;
2525

26-
end Default;
26+
end Prj;

0 commit comments

Comments
 (0)
Please sign in to comment.