Skip to content

Commit 8486b8b

Browse files
author
automatic-merge
committed
Merge remote branch 'origin/master' into edge
2 parents a166984 + ce451f2 commit 8486b8b

26 files changed

+873
-143
lines changed

.vscode/launch.json

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -38,110 +38,6 @@
3838
"PATH": "${env:PATH}"
3939
}
4040
},
41-
{
42-
"name": "(vscode) Run testsuite 'general'",
43-
"type": "extensionHost",
44-
"request": "launch",
45-
"runtimeExecutable": "${execPath}",
46-
"outFiles": [
47-
"${workspaceFolder}/integration/vscode/ada/out/**/*.js",
48-
"!**/node_modules/**"
49-
],
50-
"args": [
51-
"--extensionDevelopmentPath=${workspaceFolder}/integration/vscode/ada",
52-
"--extensionTestsPath=${workspaceFolder}/integration/vscode/ada/out/test/suite/general/index",
53-
"${workspaceFolder}/integration/vscode/ada/test/workspaces/general"
54-
],
55-
// Below we make the executables of node modules visible to the tests.
56-
// In particular, vscode-tmgrammar-snap is used for syntax highlighting
57-
// tests.
58-
"env": {
59-
"MOCHA_GREP": "${input:testPattern}",
60-
// This is necessary to make the "child" vscode inherit the PATH
61-
// variable set in the workspace settings. Without it in some setups
62-
// (e.g. vscode remote) the child vscode does not get visibility
63-
// over the Ada toolchain available in the parent vscode
64-
// environment.
65-
"PATH": "${env:PATH}",
66-
// This is custom env var that we use in
67-
// integration/vscode/ada/test/suite/index.ts to prevent timeouts in
68-
// tests when debugging
69-
"MOCHA_TIMEOUT": "0",
70-
"MOCHA_ALS_UPDATE": "${input:updateTestRefs}"
71-
},
72-
"preLaunchTask": "npm: pretest - integration/vscode/ada",
73-
"internalConsoleOptions": "openOnSessionStart"
74-
},
75-
{
76-
"name": "(vscode) Run testsuite 'gnattest'",
77-
"type": "extensionHost",
78-
"request": "launch",
79-
"runtimeExecutable": "${execPath}",
80-
"outFiles": [
81-
"${workspaceFolder}/integration/vscode/ada/out/**/*.js",
82-
"!**/node_modules/**"
83-
],
84-
"args": [
85-
"--extensionDevelopmentPath=${workspaceFolder}/integration/vscode/ada",
86-
"--extensionTestsPath=${workspaceFolder}/integration/vscode/ada/out/test/suite/gnattest/index",
87-
"${workspaceFolder}/integration/vscode/ada/test/workspaces/gnattest"
88-
],
89-
// Below we make the executables of node modules visible to the tests.
90-
// In particular, vscode-tmgrammar-snap is used for syntax highlighting
91-
// tests.
92-
"env": {
93-
"MOCHA_GREP": "${input:testPattern}",
94-
// This is necessary to make the "child" vscode inherit the PATH
95-
// variable set in the workspace settings. Without it in some setups
96-
// (e.g. vscode remote) the child vscode does not get visibility
97-
// over the Ada toolchain available in the parent vscode
98-
// environment.
99-
"PATH": "${env:PATH}",
100-
// This is custom env var that we use in
101-
// integration/vscode/ada/test/suite/index.ts to prevent timeouts in
102-
// tests when debugging
103-
"MOCHA_TIMEOUT": "0",
104-
"MOCHA_ALS_UPDATE": "${input:updateTestRefs}"
105-
},
106-
"preLaunchTask": "npm: pretest - integration/vscode/ada",
107-
// Switch to Debug Console to see test results
108-
"internalConsoleOptions": "openOnSessionStart"
109-
},
110-
{
111-
"name": "(vscode) Run testsuite 'workspace_missing_dirs'",
112-
"type": "extensionHost",
113-
"request": "launch",
114-
"runtimeExecutable": "${execPath}",
115-
"outFiles": [
116-
"${workspaceFolder}/integration/vscode/ada/out/**/*.js",
117-
"!**/node_modules/**"
118-
],
119-
"args": [
120-
"--extensionDevelopmentPath=${workspaceFolder}/integration/vscode/ada",
121-
"--extensionTestsPath=${workspaceFolder}/integration/vscode/ada/out/test/suite/workspace_missing_dirs/index",
122-
"${workspaceFolder}/integration/vscode/ada/test/workspaces/workspace_missing_dirs"
123-
],
124-
// Below we make the executables of node modules visible to the tests.
125-
// In particular, vscode-tmgrammar-snap is used for syntax highlighting
126-
// tests.
127-
"env": {
128-
"MOCHA_GREP": "${input:testPattern}",
129-
// This is necessary to make the "child" vscode inherit the PATH
130-
// variable set in the workspace settings. Without it in some setups
131-
// (e.g. vscode remote) the child vscode does not get visibility
132-
// over the Ada toolchain available in the parent vscode
133-
// environment.
134-
"PATH": "${env:PATH}",
135-
// This is custom env var that we use in
136-
// integration/vscode/ada/test/suite/index.ts to prevent timeouts in
137-
// tests when debugging
138-
"MOCHA_TIMEOUT": "0",
139-
"MOCHA_ALS_UPDATE": "${input:updateTestRefs}"
140-
},
141-
"preLaunchTask": "npm: pretest - integration/vscode/ada",
142-
// Switch to Debug Console to see test results
143-
"internalConsoleOptions": "openOnSessionStart"
144-
},
14541
{
14642
"name": "(npm) Launch all vscode tests with npm",
14743
"type": "node",

.vscode/settings.json.tmpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,12 @@
9393
"suite": ["describe", "suite"],
9494
"test": ["it", "test"],
9595
"extractWith": "syntax"
96+
},
97+
"extension-test-runner.debugOptions": {
98+
"outFiles": [
99+
"${workspaceFolder}/integration/vscode/ada/out/**/*.js",
100+
"!**/node_modules/**"
101+
],
102+
"preLaunchTask": "npm: watch - integration/vscode/ada"
96103
}
97104
}

.vscode/tasks.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@
4545
"clear": true
4646
}
4747
},
48-
{
49-
"type": "npm",
50-
"script": "watch",
51-
"path": "integration/vscode/ada",
52-
"group": "build",
53-
"problemMatcher": ["$tsc-watch"],
54-
"label": "npm: watch - integration/vscode/ada",
55-
"detail": "node ./node_modules/typescript/bin/tsc -watch",
56-
"isBackground": true
57-
},
5848
{
5949
"type": "ada",
6050
"configuration": {

doc/HACKING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ Run `make vscode-test` to run the VS Code testsuite.
144144
If you open the ALS repository in VS Code, it is also possible to run VS Code
145145
integration tests using the Testing view.
146146
The `integration/vscode/ada/.vscode-test.mjs` contains a configuration allowing to load the tests in the Testing view.
147-
The UI offers ways to run all or a subset of the tests.
147+
The UI offers ways to run or debug one test, a subset of tests or all tests.
148148
149149
### Other tests
150150

integration/vscode/ada/.vscode-test.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ export default defineConfig(
7878
// now. A workaround is to remove this line.
7979
DISPLAY: ':99',
8080
},
81-
launchArgs: ['--user-data-dir', tmpdir],
81+
launchArgs: [
82+
// It's important to use the --user-data-dir=<path> form. The
83+
// --user-data-dir <path> form sometimes gets <path> considered
84+
// as another workspace root directory.
85+
`--user-data-dir=${tmpdir}`,
86+
],
8287
// Use external installation if provided in the VSCODE env variable
8388
useInstallation: process.env.VSCODE ? { fromPath: process.env.VSCODE } : undefined,
8489
};

integration/vscode/ada/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,8 @@
881881
"compile": "node ./node_modules/typescript/bin/tsc",
882882
"watch": "node ./node_modules/typescript/bin/tsc -watch",
883883
"pretest": "npm run compile",
884-
"lint": "eslint \"./src/**/*.{js,ts,tsx}\" --quiet --fix",
885-
"cilint": "eslint \"./src/**/*.{js,ts,tsx}\"",
884+
"lint": "eslint \"./src/**/*.{js,ts,tsx}\" \"./test/**/*.{js,ts,tsx}\" --quiet --fix",
885+
"cilint": "eslint \"./src/**/*.{js,ts,tsx}\" \"./test/**/*.{js,ts,tsx}\"",
886886
"test": "vscode-test",
887887
"resolve-backtrace": "npx stacktracify",
888888
"clean": "node -e \"fs.rmSync('out',{force:true,recursive:true})\""

integration/vscode/ada/src/ExtensionState.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { initializeTesting } from './gnattest';
88
import { GprTaskProvider } from './gprTaskProvider';
99
import { TERMINAL_ENV_SETTING_NAME } from './helpers';
1010
import { registerTaskProviders } from './taskProviders';
11+
import { logger } from './extension';
1112

1213
/**
1314
* This class encapsulates all state that should be maintained throughout the
@@ -125,10 +126,13 @@ export class ExtensionState {
125126
// React to changes in configuration to recompute predefined tasks if the user
126127
// changes scenario variables' values.
127128
public configChanged = (e: vscode.ConfigurationChangeEvent) => {
129+
logger.info('didChangeConfiguration event received');
130+
128131
if (
129132
e.affectsConfiguration('ada.scenarioVariables') ||
130133
e.affectsConfiguration('ada.projectFile')
131134
) {
135+
logger.info('project related settings have changed: clearing caches for tasks');
132136
this.clearALSCache();
133137
this.unregisterTaskProviders();
134138
this.registerTaskProviders();
@@ -138,6 +142,10 @@ export class ExtensionState {
138142
// a popup to reload the VS Code window and thus restart the
139143
// Ada extension.
140144
if (e.affectsConfiguration(TERMINAL_ENV_SETTING_NAME)) {
145+
const new_value = vscode.workspace.getConfiguration().get(TERMINAL_ENV_SETTING_NAME);
146+
logger.info(`${TERMINAL_ENV_SETTING_NAME} has changed: show reload popup`);
147+
logger.info(`${TERMINAL_ENV_SETTING_NAME}: ${JSON.stringify(new_value, undefined, 2)}`);
148+
141149
void this.showReloadWindowPopup();
142150
}
143151
};

integration/vscode/ada/src/extension.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ async function activateExtension(context: vscode.ExtensionContext) {
140140
adaExtState = new ExtensionState(context);
141141
context.subscriptions.push(adaExtState);
142142

143+
// Subscribe to the didChangeConfiguration event
144+
context.subscriptions.push(
145+
vscode.workspace.onDidChangeConfiguration(adaExtState.configChanged)
146+
);
147+
143148
const alsMiddleware: Middleware = {
144149
executeCommand: alsCommandExecutor(adaExtState.adaClient),
145150
};
@@ -148,10 +153,6 @@ async function activateExtension(context: vscode.ExtensionContext) {
148153

149154
await adaExtState.start();
150155

151-
context.subscriptions.push(
152-
vscode.workspace.onDidChangeConfiguration(adaExtState.configChanged)
153-
);
154-
155156
/**
156157
* Register commands first so that commands such as displaying the extension
157158
* Output become available even if the language servers fail to start.

integration/vscode/ada/src/gnattest.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export function initializeTesting(context: vscode.ExtensionContext): vscode.Test
123123
/**
124124
* Reset and recreate the tree of TestItems based on the GNATtest XML.
125125
*/
126-
async function refreshTestItemTree() {
126+
export async function refreshTestItemTree() {
127127
controller.items.replace([]);
128128
testData.clear();
129129
await addTestsRootLevel();
@@ -142,7 +142,7 @@ async function getGnatTestXmlPath(): Promise<string> {
142142
*
143143
* @returns the full path to the GNATtest test driver GPR project.
144144
*/
145-
async function getGnatTestDriverProjectPath(): Promise<string> {
145+
export async function getGnatTestDriverProjectPath(): Promise<string> {
146146
const objDir = await getObjectDir();
147147
const testDriverPath = path.join(objDir, 'gnattest', 'harness', 'test_driver.gpr');
148148
return testDriverPath;
@@ -152,7 +152,7 @@ async function getGnatTestDriverProjectPath(): Promise<string> {
152152
*
153153
* @returns the full path to the GNATtest test driver executable.
154154
*/
155-
async function getGnatTestDriverExecPath(): Promise<string> {
155+
export async function getGnatTestDriverExecPath(): Promise<string> {
156156
const objDir = await getObjectDir();
157157
const testDriverPath = path.join(objDir, 'gnattest', 'harness', 'test_runner' + exe);
158158
return testDriverPath;
@@ -399,7 +399,7 @@ export function pathIsReadable(p: string): boolean {
399399
* @param item - the TestItem whose children must be computed, or `undefined` if
400400
* we should compute the root items of the tree.
401401
*/
402-
async function resolveHandler(
402+
export async function resolveHandler(
403403
item: TestItem | undefined,
404404
recursive = false,
405405
token?: CancellationToken
@@ -470,7 +470,7 @@ function configureTestExecution(controller: vscode.TestController) {
470470
* @param request - the request based on the User selections
471471
* @param token - a cancellation token
472472
*/
473-
async function runHandler(request: vscode.TestRunRequest, token: vscode.CancellationToken) {
473+
export async function runHandler(request: vscode.TestRunRequest, token?: vscode.CancellationToken) {
474474
if ((request.include?.length ?? 0) === 0 && (request.exclude?.length ?? 0) === 0) {
475475
/**
476476
* Run all tests. This ignores request.exclude which is why we only use
@@ -490,7 +490,7 @@ async function runHandler(request: vscode.TestRunRequest, token: vscode.Cancella
490490
* controller.items) and request.exclude. It then runs the test driver for each
491491
* test, using the --routines argument at each run to select a specific test.
492492
*/
493-
async function handleRunRequestedTests(request: vscode.TestRunRequest, token: CancellationToken) {
493+
async function handleRunRequestedTests(request: vscode.TestRunRequest, token?: CancellationToken) {
494494
const run = controller.createTestRun(request, undefined, false);
495495
try {
496496
const requestedRootTests = [];
@@ -580,7 +580,7 @@ function prepareAndAppendOutput(run: vscode.TestRun, out: string) {
580580
* in {@link handleRunRequestedTests} fails because of GNATtest shortcomings, we
581581
* still have this approach of running all tests as a backup.
582582
*/
583-
async function handleRunAll(request: vscode.TestRunRequest, token: CancellationToken) {
583+
async function handleRunAll(request: vscode.TestRunRequest, token?: CancellationToken) {
584584
const run = controller.createTestRun(request, undefined, false);
585585
try {
586586
/**
@@ -687,7 +687,7 @@ async function buildTestDriver(run: vscode.TestRun) {
687687
* @param duration - the duration of execution of the test to be reported along
688688
* with the outcome, if the information is available.
689689
*/
690-
function determineTestOutcome(
690+
export function determineTestOutcome(
691691
test: vscode.TestItem,
692692
driverOutput: string,
693693
run: vscode.TestRun,
@@ -763,7 +763,7 @@ function determineTestOutcome(
763763
* @param token - a cancellation token to stop the traversal
764764
* @returns the array of leaf TestItems reachable from the given collection.
765765
*/
766-
function collectLeafsFromCollection(
766+
export function collectLeafsFromCollection(
767767
items: vscode.TestItemCollection,
768768
token?: CancellationToken
769769
): vscode.TestItem[] {
@@ -783,7 +783,7 @@ function collectLeafsFromCollection(
783783
* @param token - a cancellation token to stop the traversal
784784
* @returns the array of leaf TestItems reachable from the given TestItem
785785
*/
786-
function collectLeafItems(item: TestItem, token?: CancellationToken): vscode.TestItem[] {
786+
export function collectLeafItems(item: TestItem, token?: CancellationToken): vscode.TestItem[] {
787787
if (item.children.size > 0) {
788788
const res: vscode.TestItem[] = [];
789789
item.children.forEach((i) => {

integration/vscode/ada/src/taskProviders.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
import assert from 'assert';
1919
import commandExists from 'command-exists';
2020
import * as vscode from 'vscode';
21-
import { adaExtState, logger } from './extension';
22-
import { AdaMain, getAdaMains, getProjectFile, getSymbols } from './helpers';
2321
import { SymbolKind } from 'vscode';
22+
import { adaExtState } from './extension';
23+
import { AdaMain, getAdaMains, getProjectFile, getSymbols } from './helpers';
24+
import path from 'path';
2425

2526
export const ADA_TASK_TYPE = 'ada';
2627

@@ -691,8 +692,15 @@ async function buildFullCommandLine(
691692

692693
if (taskDef.configuration.kind == 'runMain') {
693694
if (adaMain) {
694-
// Append the run of the main executable
695-
cmd.push(adaMain.execRelPath());
695+
// Append the main executable's relative path, prepending './'
696+
// (or '.\\' on Windows) when needed, to make sure it's executable from
697+
// a shell.
698+
let execRelPath = adaMain.execRelPath();
699+
if (!execRelPath.includes(path.sep)) {
700+
execRelPath = '.' + path.sep + execRelPath;
701+
}
702+
703+
cmd.push(execRelPath);
696704
if (taskDef.configuration.mainArgs) {
697705
cmd = cmd.concat(taskDef.configuration.mainArgs);
698706
}

0 commit comments

Comments
 (0)