diff --git a/integration/vscode/ada/package-lock.json b/integration/vscode/ada/package-lock.json index 0cf798da6..cdce23302 100644 --- a/integration/vscode/ada/package-lock.json +++ b/integration/vscode/ada/package-lock.json @@ -1268,12 +1268,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -2340,9 +2340,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "dependencies": { "to-regex-range": "^5.0.1" diff --git a/integration/vscode/ada/src/AdaCodeLensProvider.ts b/integration/vscode/ada/src/AdaCodeLensProvider.ts index f18595546..c9c4df2bb 100644 --- a/integration/vscode/ada/src/AdaCodeLensProvider.ts +++ b/integration/vscode/ada/src/AdaCodeLensProvider.ts @@ -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'; @@ -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); diff --git a/integration/vscode/ada/test/suite/general/codelens.test.ts b/integration/vscode/ada/test/suite/general/codelens.test.ts index c07ca4a03..f57f24b48 100644 --- a/integration/vscode/ada/test/suite/general/codelens.test.ts +++ b/integration/vscode/ada/test/suite/general/codelens.test.ts @@ -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; @@ -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], + }, + ] ); }); diff --git a/integration/vscode/ada/test/suite/general/debug.test.ts b/integration/vscode/ada/test/suite/general/debug.test.ts index 92b146cb7..34a755439 100644 --- a/integration/vscode/ada/test/suite/general/debug.test.ts +++ b/integration/vscode/ada/test/suite/general/debug.test.ts @@ -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, '\\\\') ?? ''}" - }, - { - "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, '\\\\') ?? ''}" - }, - { - "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() ?? ''}" - }, - { - "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() ?? ''}" - } -]`; + 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() ?? '', + }, + { + 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() ?? '', + }, + { + 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() ?? '', + }, + { + 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() ?? '', + }, + ]; }); test('GDB path is explicitely set in offered debug config', async () => { @@ -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); }); }); diff --git a/integration/vscode/ada/test/suite/general/tasks.test.ts b/integration/vscode/ada/test/suite/general/tasks.test.ts index d661e3916..76218a08b 100644 --- a/integration/vscode/ada/test/suite/general/tasks.test.ts +++ b/integration/vscode/ada/test/suite/general/tasks.test.ts @@ -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, @@ -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(); diff --git a/integration/vscode/ada/test/workspaces/general/default_without_obj_dir/.gitignore b/integration/vscode/ada/test/workspaces/general/default_without_obj_dir/.gitignore index f4415524f..c9431d721 100644 --- a/integration/vscode/ada/test/workspaces/general/default_without_obj_dir/.gitignore +++ b/integration/vscode/ada/test/workspaces/general/default_without_obj_dir/.gitignore @@ -7,3 +7,4 @@ /b__*.ad? /*.bexch /main1exec +/main1exec.exe