Skip to content

Commit

Permalink
Merge remote branch 'origin/master' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
automatic-merge committed Aug 14, 2024
2 parents 679968f + 7a3e670 commit baafa95
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}/
4 changes: 4 additions & 0 deletions .vscode/settings.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions integration/vscode/ada/test/suite/general/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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');
}
Expand Down
31 changes: 12 additions & 19 deletions integration/vscode/ada/test/suite/general/tasks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import {
closeAllEditors,
getCmdLine,
getCommandLines,
isCoreTask,
isGNATSASTask,
negate,
runTaskAndGetResult,
testTask,
} from '../utils';
Expand Down Expand Up @@ -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
Expand All @@ -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);
});

Expand All @@ -69,19 +69,18 @@ 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
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);
});

Expand Down Expand Up @@ -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 () {
Expand All @@ -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
Expand Down
61 changes: 55 additions & 6 deletions integration/vscode/ada/test/suite/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,17 @@ export async function activate(): Promise<void> {
* 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) => {
Expand Down Expand Up @@ -191,14 +198,14 @@ export function getCmdLine(exec: vscode.ShellExecution) {
*/
export async function testTask(
taskName: string,
testedTasks: Set<string>,
testedTasks?: Set<string>,
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);

Expand All @@ -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';
}
}
}

Expand Down Expand Up @@ -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<T extends unknown[]>(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<T extends unknown[]>(...predicates: ((...args: T) => boolean)[]) {
return (...inputs: T) => {
return predicates.reduce<boolean>((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));
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project Default is
project Prj is

Tools_Mains :=
("main1.adb",
Expand All @@ -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;

0 comments on commit baafa95

Please sign in to comment.