diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index f81c2fdef..30c1133ea 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -98,6 +98,6 @@ jobs: AWS_DEFAULT_REGION: eu-west-1 run: | for FILE in *.vsix ; do - aws s3 cp ${FILE} s3://adacore-gha-tray-eu-west-1/vscode-extension/${TAG}/ --sse=AES256 + aws s3 cp ${FILE} s3://als-publish-adacore-eu-west-1/vscode-extension/${TAG}/ --sse=AES256 done - aws s3 ls s3://adacore-gha-tray-eu-west-1/vscode-extension/${TAG}/ + aws s3 ls s3://als-publish-adacore-eu-west-1/vscode-extension/${TAG}/ diff --git a/.vscode/settings.json.tmpl b/.vscode/settings.json.tmpl index cb2116691..63dba1ddc 100644 --- a/.vscode/settings.json.tmpl +++ b/.vscode/settings.json.tmpl @@ -65,6 +65,10 @@ "source.fixAll.eslint": true } }, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true + }, "[json]": { "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode", diff --git a/integration/vscode/ada/test/suite/general/extension.test.ts b/integration/vscode/ada/test/suite/general/extension.test.ts index 268d93db1..702b9b2dd 100644 --- a/integration/vscode/ada/test/suite/general/extension.test.ts +++ b/integration/vscode/ada/test/suite/general/extension.test.ts @@ -5,6 +5,7 @@ import { assertEqualToFileContent, activate } from '../utils'; import * as vscode from 'vscode'; import { readFileSync, writeFileSync } from 'fs'; +import { basename } from 'path'; suite('Extensions Test Suite', function () { // Make sure the extension is activated @@ -14,8 +15,8 @@ suite('Extensions Test Suite', function () { test('Project File Response', async () => { if (vscode.workspace.workspaceFolders !== undefined) { const result: string = await getProjectFile(adaExtState.adaClient); - const name = result.replace(/^.*[\\/]/, ''); - assert.strictEqual(name, 'default.gpr'); + const name = basename(result); + assert.strictEqual(name, 'prj.gpr'); } else { throw new Error('No workspace folder found for the specified URI'); } diff --git a/integration/vscode/ada/test/suite/general/tasks.test.ts b/integration/vscode/ada/test/suite/general/tasks.test.ts index c54e724d3..cf2f1d185 100644 --- a/integration/vscode/ada/test/suite/general/tasks.test.ts +++ b/integration/vscode/ada/test/suite/general/tasks.test.ts @@ -17,6 +17,9 @@ import { closeAllEditors, getCmdLine, getCommandLines, + isCoreTask, + isGNATSASTask, + negate, runTaskAndGetResult, testTask, } from '../utils'; @@ -44,13 +47,7 @@ ada: Clean current project ada: Build current project ada: Check current file ada: Compile current file -ada: Analyze the project with GNAT SAS -ada: Analyze the current file with GNAT SAS -ada: Create a report after a GNAT SAS analysis -ada: Analyze the project with GNAT SAS and produce a report -ada: Analyze the current file with GNAT SAS and produce a report ada: Generate documentation from the project -ada: Create/update test skeletons for the project ada: Build main - src/main1.adb ada: Run main - src/main1.adb ada: Build and run main - src/main1.adb @@ -59,7 +56,10 @@ ada: Run main - src/test.adb ada: Build and run main - src/test.adb `.trim(); - const actualTaskList = tasks.map((t) => `${t.source}: ${t.name}`).join('\n'); + const actualTaskList = tasks + .filter(isCoreTask) + .map((t) => `${t.source}: ${t.name}`) + .join('\n'); assert.strictEqual(actualTaskList, expectedTasksList); }); @@ -69,11 +69,7 @@ ada: Clean current project - gprclean -P ${projectPath} ada: Build current project - gprbuild -P ${projectPath} -cargs:ada -gnatef ada: Check current file - gprbuild -q -f -c -u -gnatc -P ${projectPath} \${fileBasename} -cargs:ada -gnatef ada: Compile current file - gprbuild -q -f -c -u -P ${projectPath} \${fileBasename} -cargs:ada -gnatef -ada: Analyze the project with GNAT SAS - gnatsas analyze -P ${projectPath} -ada: Analyze the current file with GNAT SAS - gnatsas analyze -P ${projectPath} --file=\${fileBasename} -ada: Create a report after a GNAT SAS analysis - gnatsas report sarif -P ${projectPath} -o report.sarif ada: Generate documentation from the project - gnatdoc -P ${projectPath} -ada: Create/update test skeletons for the project - gnattest -P ${projectPath} ada: Build main - src/main1.adb - gprbuild -P ${projectPath} src/main1.adb -cargs:ada -gnatef ada: Run main - src/main1.adb - obj/main1exec${exe} ada: Build main - src/test.adb - gprbuild -P ${projectPath} src/test.adb -cargs:ada -gnatef @@ -81,7 +77,10 @@ ada: Run main - src/test.adb - obj/test${exe} `.trim(); const prov = createAdaTaskProvider(); - const actualCommandLines = await getCommandLines(prov); + /** + * Exclude GNAT SAS tasks because they are tested in integration-testsuite. + */ + const actualCommandLines = await getCommandLines(prov, isCoreTask); assert.equal(actualCommandLines, expectedCmdLines); }); @@ -283,7 +282,7 @@ suite('Task Execution', function () { this.beforeAll(async () => { await activate(); - allProvidedTasks.push(...(await createAdaTaskProvider().provideTasks())); + allProvidedTasks.push(...(await createAdaTaskProvider().provideTasks()).filter(isCoreTask)); }); this.beforeEach(async function () { @@ -300,13 +299,7 @@ suite('Task Execution', function () { declTaskTest('ada: Build main - src/test.adb'); declTaskTest('ada: Build and run main - src/main1.adb'); declTaskTest('ada: Build and run main - src/test.adb'); - declTaskTest('ada: Analyze the project with GNAT SAS'); - declTaskTest('ada: Create a report after a GNAT SAS analysis'); - declTaskTest('ada: Analyze the project with GNAT SAS and produce a report'); - declTaskTest('ada: Analyze the current file with GNAT SAS and produce a report', openSrcFile); - declTaskTest('ada: Analyze the current file with GNAT SAS', openSrcFile); declTaskTest('ada: Generate documentation from the project'); - declTaskTest('ada: Create/update test skeletons for the project'); /** * Check that the 'buildAndRunMain' task works fine with projects that diff --git a/integration/vscode/ada/test/suite/utils.ts b/integration/vscode/ada/test/suite/utils.ts index c82953507..847a8c22e 100644 --- a/integration/vscode/ada/test/suite/utils.ts +++ b/integration/vscode/ada/test/suite/utils.ts @@ -82,10 +82,17 @@ export async function activate(): Promise { * provider that are based on a ShellExecution. The string includes the command * line of each task. */ -export async function getCommandLines(prov: SimpleTaskProvider) { - const tasks = await prov.provideTasks(); +export async function getCommandLines( + prov: SimpleTaskProvider, + filter?: (t: vscode.Task) => boolean +) { + let tasks = await prov.provideTasks(); assert(tasks); + if (filter) { + tasks = tasks.filter(filter); + } + const actualCommandLines = ( await Promise.all( tasks.map(async (t) => { @@ -191,14 +198,14 @@ export function getCmdLine(exec: vscode.ShellExecution) { */ export async function testTask( taskName: string, - testedTasks: Set, + testedTasks?: Set, allProvidedTasks?: vscode.Task[] ) { assert(vscode.workspace.workspaceFolders); const task = await findTaskByName(taskName, allProvidedTasks); assert(task); - testedTasks.add(getConventionalTaskLabel(task)); + testedTasks?.add(getConventionalTaskLabel(task)); const execStatus: number | undefined = await runTaskAndGetResult(task); @@ -220,18 +227,24 @@ export async function testTask( setTerminalEnvironment(env); const cp = spawnSync(cmdLine[0], cmdLine.slice(1), { cwd: cwd, env: env }); - if (cp.status) { + if (cp.status != null) { // eslint-disable-next-line @typescript-eslint/restrict-template-expressions msg += `\nProcess ended with exit code ${cp.status} and output:\n`; // msg += cp.stdout.toString() + cp.stderr.toString(); msg += cp.output?.map((b) => (b != null ? b.toString() : '')).join(''); - } else { + } else if (cp.signal != null) { // eslint-disable-next-line @typescript-eslint/restrict-template-expressions msg += `\nProcess ended with signal: ${cp.signal}`; + } else if (cp.error != undefined) { + throw cp.error; } } catch (error) { // eslint-disable-next-line @typescript-eslint/restrict-template-expressions msg += `\nEncountered an error: ${error}`; + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + if (`${error}`.includes('ENOENT')) { + msg += '\nIt is likely that the executable is not on PATH'; + } } } @@ -333,3 +346,39 @@ export function rangeToStr(range: vscode.Range): string { // eslint-disable-next-line max-len return `${range.start.line}:${range.start.character} -> ${range.end.line}:${range.end.character}`; } + +/** + * Utility filter for selecting GNAT SAS tasks. + */ +export function isGNATSASTask(t: vscode.Task): boolean { + return t.name.includes('GNAT SAS'); +} + +/** + * Utility function for creating a predicated that is the negation of another predicate. + */ +export function negate(predicate: (...args: T) => boolean) { + return (...inputs: T) => !predicate(...inputs); +} + +/** + * Utility function for creating a predicated that is the negation of another predicate. + */ +export function and(...predicates: ((...args: T) => boolean)[]) { + return (...inputs: T) => { + return predicates.reduce((acc, cur) => acc && cur(...inputs), true); + }; +} + +/** + * Utility filter for selecting GNATtest tasks. + */ +export function isGNATTestTask(t: vscode.Task): boolean { + return t.name.includes('test skeleton'); +} + +/** + * Utility filter for selecting core tasks that are not related to other tools + * such as GNAT SAS or GNATtest. + */ +export const isCoreTask = and(negate(isGNATSASTask), negate(isGNATTestTask)); diff --git a/integration/vscode/ada/test/workspaces/general/default.gpr b/integration/vscode/ada/test/workspaces/general/prj.gpr similarity index 87% rename from integration/vscode/ada/test/workspaces/general/default.gpr rename to integration/vscode/ada/test/workspaces/general/prj.gpr index 1102cc34d..e323e27aa 100644 --- a/integration/vscode/ada/test/workspaces/general/default.gpr +++ b/integration/vscode/ada/test/workspaces/general/prj.gpr @@ -1,4 +1,4 @@ -project Default is +project Prj is Tools_Mains := ("main1.adb", @@ -20,7 +20,7 @@ project Default is -- This project contains intentionally invalid code which causes gnatdoc -- to fail when testing the corresponding vscode task. This gets the -- project skipped by gnatdoc for the purpose of testing. - for Excluded_Project_Files use ("default.gpr"); + for Excluded_Project_Files use ("prj.gpr"); end Documentation; -end Default; +end Prj;