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 Jun 12, 2024
2 parents ab27cbb + 3f3fdcd commit 9eae1b3
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 121 deletions.
14 changes: 7 additions & 7 deletions integration/vscode/ada/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion integration/vscode/ada/src/AdaCodeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
SymbolKind,
TextDocument,
commands,
Uri,
} from 'vscode';
import { CMD_BUILD_AND_DEBUG_MAIN, CMD_BUILD_AND_RUN_MAIN } from './commands';
import { getMains, getSymbols } from './helpers';
Expand All @@ -30,7 +31,14 @@ export class AdaCodeLensProvider implements CodeLensProvider {
* For main procedures, provide Run and Debug CodeLenses.
*/
const res1 = getMains().then((mains) => {
if (mains.some((m) => m == document.fileName)) {
if (
mains.some(
(m) =>
// Here we go through the Uri class to benefit from the normalization
// of path casing on Windows. See Uri.fsPath documentation.
Uri.file(m).fsPath == document.uri.fsPath
)
) {
// It's a main file, so let's offer Run and Debug actions on the main subprogram
return symbols.then((symbols) => {
const functions = symbols.filter((s) => s.kind == SymbolKind.Function);
Expand Down
47 changes: 26 additions & 21 deletions integration/vscode/ada/test/suite/general/codelens.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import assert from 'assert';
import { Uri, window, workspace } from 'vscode';
import { adaExtState } from '../../../src/extension';
import { activate } from '../utils';
import { activate, closeAllEditors } from '../utils';

suite('CodeLens', function () {
this.beforeAll(async () => {
await activate();
});

this.beforeEach(async function () {
await closeAllEditors();
});

test('in main file offer run & debug', async () => {
assert(workspace.workspaceFolders !== undefined);
const rootUri = workspace.workspaceFolders[0].uri;
Expand All @@ -16,28 +20,29 @@ suite('CodeLens', function () {
const codelenses = await adaExtState.codelensProvider.provideCodeLenses(
textEditor.document
);
assert.equal(
assert.deepEqual(
/**
* Check a string representation of the CodeLenses.
* Check a subset of the fields in CodeLenses
*/
toString(codelenses),
`
[
{
"command": "ada.buildAndRunMain",
"title": "$(run) Run",
"arguments": [
"src/main1.adb"
]
},
{
"command": "ada.buildAndDebugMain",
"title": "$(debug-alt-small) Debug",
"arguments": [
"src/main1.adb"
]
}
]`.trim()
codelenses?.map((v) => ({
...v.command,
// The argument is expected to be a Uri, in which case use the
// normalized fsPath for comparison with the expected result
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
arguments: v.command?.arguments?.map((a) => (a instanceof Uri ? a.fsPath : a)),
})),
[
{
command: 'ada.buildAndRunMain',
title: '$(run) Run',
arguments: [mainUri.fsPath],
},
{
command: 'ada.buildAndDebugMain',
title: '$(debug-alt-small) Debug',
arguments: [mainUri.fsPath],
},
]
);
});

Expand Down
171 changes: 82 additions & 89 deletions integration/vscode/ada/test/suite/general/debug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,83 +10,82 @@ import { activate } from '../utils';
import { adaExtState } from '../../../src/extension';

suite('Debug Configurations', function () {
let expectedConfigs: string;
let expectedConfigs: AdaConfig[];

this.beforeAll(async () => {
await activate();
expectedConfigs = `
[
{
"type": "cppdbg",
"name": "Ada: Debug main - src/main1.adb",
"request": "launch",
"targetArchitecture": "x64",
"cwd": "\${workspaceFolder}",
"program": "\${workspaceFolder}/obj/main1exec${exe}",
"stopAtEntry": false,
"externalConsole": false,
"args": [],
"MIMode": "gdb",
"preLaunchTask": "ada: Build main - src/main1.adb",
"setupCommands": [
{
"description": "Catch all Ada exceptions",
"text": "catch exception",
"ignoreFailures": true
},
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"miDebuggerPath": "${getOrFindGdb()?.replace(/\\/g, '\\\\') ?? '<undefined>'}"
},
{
"name": "Ada: Attach debugger to running process - src/main1.adb",
"type": "cppdbg",
"request": "attach",
"program": "\${workspaceFolder}/obj/main1exec${exe}",
"processId": "\${command:pickProcess}",
"MIMode": "gdb",
"miDebuggerPath": "${getOrFindGdb()?.replace(/\\/g, '\\\\') ?? '<undefined>'}"
},
{
"type": "cppdbg",
"name": "Ada: Debug main - src/test.adb",
"request": "launch",
"targetArchitecture": "x64",
"cwd": "\${workspaceFolder}",
"program": "\${workspaceFolder}/obj/test${exe}",
"stopAtEntry": false,
"externalConsole": false,
"args": [],
"MIMode": "gdb",
"preLaunchTask": "ada: Build main - src/test.adb",
"setupCommands": [
{
"description": "Catch all Ada exceptions",
"text": "catch exception",
"ignoreFailures": true
},
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"miDebuggerPath": "${getOrFindGdb() ?? '<undefined>'}"
},
{
"name": "Ada: Attach debugger to running process - src/test.adb",
"type": "cppdbg",
"request": "attach",
"program": "\${workspaceFolder}/obj/test${exe}",
"processId": "\${command:pickProcess}",
"MIMode": "gdb",
"miDebuggerPath": "${getOrFindGdb() ?? '<undefined>'}"
}
]`;
expectedConfigs = [
{
type: 'cppdbg',
name: 'Ada: Debug main - src/main1.adb',
request: 'launch',
targetArchitecture: 'x64',
cwd: '${workspaceFolder}',
program: '${workspaceFolder}/obj/main1exec' + exe,
stopAtEntry: false,
externalConsole: false,
args: [],
MIMode: 'gdb',
preLaunchTask: 'ada: Build main - src/main1.adb',
setupCommands: [
{
description: 'Catch all Ada exceptions',
text: 'catch exception',
ignoreFailures: true,
},
{
description: 'Enable pretty-printing for gdb',
text: '-enable-pretty-printing',
ignoreFailures: true,
},
],
miDebuggerPath: getOrFindGdb() ?? '<undefined>',
},
{
name: 'Ada: Attach debugger to running process - src/main1.adb',
type: 'cppdbg',
request: 'attach',
program: '${workspaceFolder}/obj/main1exec' + exe,
processId: '${command:pickProcess}',
MIMode: 'gdb',
miDebuggerPath: getOrFindGdb() ?? '<undefined>',
},
{
type: 'cppdbg',
name: 'Ada: Debug main - src/test.adb',
request: 'launch',
targetArchitecture: 'x64',
cwd: '${workspaceFolder}',
program: '${workspaceFolder}/obj/test' + exe,
stopAtEntry: false,
externalConsole: false,
args: [],
MIMode: 'gdb',
preLaunchTask: 'ada: Build main - src/test.adb',
setupCommands: [
{
description: 'Catch all Ada exceptions',
text: 'catch exception',
ignoreFailures: true,
},
{
description: 'Enable pretty-printing for gdb',
text: '-enable-pretty-printing',
ignoreFailures: true,
},
],
miDebuggerPath: getOrFindGdb() ?? '<undefined>',
},
{
name: 'Ada: Attach debugger to running process - src/test.adb',
type: 'cppdbg',
request: 'attach',
program: '${workspaceFolder}/obj/test' + exe,
processId: '${command:pickProcess}',
MIMode: 'gdb',
miDebuggerPath: getOrFindGdb() ?? '<undefined>',
},
];
});

test('GDB path is explicitely set in offered debug config', async () => {
Expand Down Expand Up @@ -136,24 +135,18 @@ All of the above - Create all of the above configurations in the launch.json fil
expected.trim()
);

assert.equal(
JSON.stringify(
quickpick
.filter((e) => 'conf' in e)
.map((e) => {
assert('conf' in e);
return e.conf;
}),
null,
2
).trim(),
expectedConfigs.trim()
);
const actualConfigs = quickpick
.filter((e) => 'conf' in e)
.map((e) => {
assert('conf' in e);
return e.conf;
});

assert.deepEqual(actualConfigs, expectedConfigs);
});

test('Dynamic', async () => {
const configs = await adaExtState.dynamicDebugConfigProvider.provideDebugConfigurations();

assert.equal(JSON.stringify(configs, undefined, 2).trim(), expectedConfigs.trim());
assert.deepEqual(configs, expectedConfigs);
});
});
6 changes: 3 additions & 3 deletions integration/vscode/ada/test/suite/general/tasks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import assert from 'assert';
import path from 'path';
import * as vscode from 'vscode';
import { getEnclosingSymbol, getSelectedRegion } from '../../../src/commands';
import { getProjectFile } from '../../../src/helpers';
import { exe, getProjectFile } from '../../../src/helpers';
import {
SimpleTaskDef,
createAdaTaskProvider,
Expand Down Expand Up @@ -60,9 +60,9 @@ ada: Create a report after a GNAT SAS analysis - gnatsas report sarif -P ${proje
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
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
ada: Run main - src/test.adb - obj/test${exe}
`.trim();

const prov = createAdaTaskProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/b__*.ad?
/*.bexch
/main1exec
/main1exec.exe

0 comments on commit 9eae1b3

Please sign in to comment.