Skip to content

Commit 6d76072

Browse files
author
automatic-merge
committed
Merge remote branch 'origin/master' into edge
2 parents b185869 + 0b7fb1d commit 6d76072

File tree

12 files changed

+251
-35
lines changed

12 files changed

+251
-35
lines changed

.gitlab-ci.plan

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def build_(qualifier={}):
22
with defaults(qualifier=qualifier):
33
anod_build("als")
4-
anod_build("vscode-extension")
4+
anod_build("vscode-extension", qualifier={"mono-plat": True})
55

66

77
def test_als_(qualifier={}):
@@ -19,10 +19,10 @@ def test_als_cov_(qualifier={}):
1919

2020

2121
def test_vscode_extension_(qualifier={}):
22-
with defaults(qualifier=qualifier):
23-
# Install the component built in the preceding CI build job
24-
anod_install("vscode-extension")
25-
anod_test("vscode-extension", qualifier=qualifier | {"coverage": True})
22+
component_qual = qualifier | {"mono-plat": True}
23+
# Install the component built in the preceding CI build job
24+
anod_install("vscode-extension", qualifier=component_qual)
25+
anod_test("vscode-extension", qualifier=component_qual | {"coverage": True})
2626

2727

2828
def build_test_gs_(qualifier={}):
@@ -62,14 +62,29 @@ def build_test_gs_edge():
6262

6363

6464
def test_integration_testsuite():
65-
# The two components below have been built by the build job of the CI
65+
# These two components have been built by the build job of the CI, install them.
6666
anod_install("als")
67-
anod_install("vscode-extension")
68-
# Install gps component to avoid it getting rebuilt. We are only interested in
69-
# vscode tests in the integration-testsuite, not gps.
70-
anod_install("gps")
67+
anod_install("vscode-extension", qualifier={"mono-plat": True})
68+
69+
# For the following components, we'd like to install with latest=True to be
70+
# resilient to failures in nightly builds.
71+
#
72+
# We need to do this instead of running the whole plan with --latest because
73+
# currently --latest bypasses the local offline Cathod component cache and prevents
74+
# installing components built in the same CI pipeline.
75+
for dep in (
76+
# Install gps component to avoid it getting rebuilt. Here we are only interested
77+
# in vscode tests in the integration-testsuite, not gps.
78+
"gps",
79+
"gnat",
80+
"gnatdas",
81+
"gnatsas",
82+
"spark2014",
83+
):
84+
anod_install(dep, latest=True)
85+
7186
# Run the subset of integration-testsuite that uses VS Code
7287
anod_test(
7388
"integration-testsuite",
74-
qualifier={"run-tools": "vscode", "cleanup-mode": "none"},
89+
qualifier={"run-tools": "vscode", "cleanup-mode": "none", "mono-plat": True},
7590
)

.gitlab-ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ include:
2121
cpus: 16
2222
disk: 80
2323
image: systemgtk
24+
windows: true
25+
windows-cpus: 8
26+
# 8GB of memory leads to heap exhaustion during compilation. We need more.
27+
windows-mem: 16
2428
save-component: true
2529

2630
# Testing of the ALS
@@ -30,6 +34,7 @@ include:
3034
anod-args: run test_als_$ACI_TRACK
3135
image: systemgtk
3236
disk: 80
37+
windows: true
3338

3439
# Testing of the ALS with coverage
3540
- component: $CI_SERVER_FQDN/eng/gitlab-templates/test@~latest
@@ -50,6 +55,7 @@ include:
5055
job-name: vscode-extension
5156
anod-args: run test_vscode_extension_$ACI_TRACK
5257
image: systemgtk
58+
windows: true
5359

5460
# Integration testsuite
5561
- component: $CI_SERVER_FQDN/eng/gitlab-templates/test@~latest
@@ -62,6 +68,7 @@ include:
6268
image: systemgtk
6369
cpus: 4
6470
disk: 80
71+
windows: true
6572
rules:
6673
# Does not work on edge
6774
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_TARGET_BRANCH_NAME != 'edge'
@@ -75,6 +82,7 @@ include:
7582
image: systemgtk
7683
disk: 80
7784
stage: optional
85+
windows: true
7886
rules:
7987
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
8088
when: manual
@@ -180,3 +188,13 @@ vscode-extension:linux:
180188
paths:
181189
- anod-logs/
182190
- coverage/cobertura-coverage.xml
191+
192+
als:windows:
193+
variables:
194+
# In GitLab CI tests timeout more often on Windows, so we multiply
195+
# testsuite timeouts by the following factor
196+
ALS_WAIT_FACTOR: "2"
197+
198+
vscode-extension:windows:
199+
variables:
200+
MOCHA_TIMEOUT: "30000"

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repos:
44
hooks:
55
- id: flake8
66
types: [file]
7-
files: \.(py|anod|plan)$
7+
files: \.(py)$
88
additional_dependencies:
99
- flake8-bugbear
1010
- flake8-builtins
@@ -16,7 +16,7 @@ repos:
1616
hooks:
1717
- id: black
1818
types_or: [file]
19-
files: \.(py|plan)$
19+
files: \.(py)$
2020
- repo: https://github.com/pre-commit/mirrors-mypy
2121
rev: v1.8.0
2222
hooks:

integration/vscode/ada/src/ExtensionState.ts

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export class ExtensionState {
5757
public readonly codelensProvider = new AdaCodeLensProvider();
5858
public readonly testController: vscode.TestController;
5959
public readonly testData: Map<vscode.TestItem, object> = new Map();
60+
public readonly statusBar: vscode.StatusBarItem;
6061

6162
/**
6263
* The following fields are caches for ALS requests or costly properties.
@@ -107,6 +108,8 @@ export class ExtensionState {
107108
this.initialDebugConfigProvider = result.providerInitial;
108109
this.dynamicDebugConfigProvider = result.providerDynamic;
109110
this.testController = initializeTesting(context);
111+
this.statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
112+
this.context.subscriptions.push(this.statusBar);
110113
}
111114

112115
public start = async () => {
@@ -115,6 +118,7 @@ export class ExtensionState {
115118
this.context.subscriptions.push(
116119
vscode.languages.registerCodeLensProvider('ada', this.codelensProvider),
117120
);
121+
this.updateStatusBarVisibility(undefined);
118122
};
119123

120124
public dispose = () => {
@@ -147,6 +151,139 @@ export class ExtensionState {
147151
];
148152
};
149153

154+
/**
155+
* Update the status bar item's visibility according to the current context.
156+
*/
157+
public updateStatusBarVisibility = (editor: vscode.TextEditor | undefined) => {
158+
const activeEditor = editor ?? vscode.window.activeTextEditor;
159+
160+
// Show the status bar if the active editor is on an Ada or a GPR source, or
161+
// if it's the Output view that is focused (i.e: when the active editor's
162+
// document scheme is set to 'output') and showing Ada & SPARK extension's logs.
163+
if (
164+
activeEditor &&
165+
((activeEditor.document.uri.scheme == 'output' &&
166+
activeEditor.document.fileName.includes('AdaCore')) ||
167+
['ada', 'gpr'].includes(activeEditor.document.languageId))
168+
) {
169+
this.statusBar.show();
170+
} else {
171+
this.statusBar.hide();
172+
}
173+
};
174+
175+
/**
176+
* Update the status bar item's content according to currently displayed
177+
* diagnostics.
178+
*/
179+
public updateStatusBarItem = () => {
180+
// Use markdown for the status bar item tiooltip. This allows to have
181+
// hyperlinks that run actual commands.
182+
this.statusBar.tooltip = new vscode.MarkdownString('', true);
183+
this.statusBar.tooltip.isTrusted = true;
184+
185+
// Show the Problems view by default when clicking on the status
186+
// bar item.
187+
this.statusBar.command = 'workbench.panel.markers.view.focus';
188+
let alireProjectLoaded = false;
189+
190+
// Monitor diagnostics related to project-loading in general, including
191+
// potential issues reported by Alire.
192+
const PROJECT_DIAGS_SOURCE = 'ada.project';
193+
const ALIRE_DIAGS_SOURCE = 'ada.alire';
194+
const diagnosticSources = [PROJECT_DIAGS_SOURCE, ALIRE_DIAGS_SOURCE];
195+
196+
// Gather all the diagnostics from the interesting ALS diagnostics' sources.
197+
// For the status bar we are interested only in project-related diagnostics.
198+
const alsDiagnostics: vscode.Diagnostic[] = vscode.languages
199+
.getDiagnostics()
200+
.flatMap(([, diagnostics]) => diagnostics)
201+
.filter((diag) => diagnosticSources.includes(diag.source ?? ''));
202+
203+
// Update the status bar according to the ALS project-related diagnostics
204+
if (alsDiagnostics.length > 0) {
205+
// Get the highest severity of the currently displayed project-diagnostics, to
206+
// update the status bar's colors accordingly.
207+
const statusBarSeverity: vscode.DiagnosticSeverity = alsDiagnostics
208+
.map((a) => a.severity)
209+
.reduce((a, b) => (a < b ? a : b));
210+
this.statusBar.text = 'Ada & SPARK';
211+
212+
switch (statusBarSeverity) {
213+
case vscode.DiagnosticSeverity.Error:
214+
this.statusBar.tooltip.appendMarkdown(
215+
'Project loading has issued errors, see the [Problems]' +
216+
'(command:workbench.panel.markers.view.focus) view' +
217+
' for more information.',
218+
);
219+
this.statusBar.backgroundColor = new vscode.ThemeColor(
220+
'statusBarItem.errorBackground',
221+
);
222+
this.statusBar.color = new vscode.ThemeColor('statusBarItem.errorForeground');
223+
break;
224+
225+
case vscode.DiagnosticSeverity.Warning:
226+
this.statusBar.tooltip.appendMarkdown(
227+
'Project loading has issued warnings, see the [Problems]' +
228+
'(command:workbench.panel.markers.view.focus) view' +
229+
' for more information.',
230+
);
231+
this.statusBar.backgroundColor = new vscode.ThemeColor(
232+
'statusBarItem.warningBackground',
233+
);
234+
this.statusBar.color = new vscode.ThemeColor('statusBarItem.warningForeground');
235+
break;
236+
237+
default:
238+
this.statusBar.backgroundColor = undefined;
239+
this.statusBar.color = undefined;
240+
241+
// Check if we have successfully loaded the project through Alire
242+
// and adapt the status bar item's text contents if it's the case, to
243+
// mention that Alire was used for project-loading.
244+
alireProjectLoaded = alsDiagnostics.some(
245+
(diagnostic) =>
246+
diagnostic.source == PROJECT_DIAGS_SOURCE &&
247+
diagnostic.message.includes('Alire'),
248+
);
249+
250+
if (alireProjectLoaded) {
251+
this.statusBar.text += ' (Alire)';
252+
this.statusBar.tooltip.appendMarkdown(
253+
'Project was loaded successfully through Alire',
254+
);
255+
} else {
256+
this.statusBar.tooltip.appendMarkdown('Project was loaded successfully.');
257+
}
258+
}
259+
} else {
260+
// We don't have any project-related diagnostics, just clear any color/background color
261+
// of the status bar.
262+
this.statusBar.tooltip.appendMarkdown('Project was loaded successfully.');
263+
this.statusBar.backgroundColor = undefined;
264+
this.statusBar.color = undefined;
265+
}
266+
267+
if (this.statusBar.tooltip.value) {
268+
this.statusBar.tooltip.appendMarkdown('\n\n---\n\n');
269+
}
270+
this.statusBar.tooltip.appendMarkdown(
271+
`[$(terminal) Open Extension Logs](command:ada.showExtensionOutput
272+
"Show Ada Extension Output")
273+
274+
[$(terminal) Open Logs for Ada & SPARK](command:ada.showAdaLSOutput
275+
"Show Ada Language Server for Ada & SPARK Output")
276+
277+
[$(terminal) Open Logs for GPR](command:ada.showGprLSOutput
278+
"Show Ada Language Server for GPR Output")
279+
280+
[$(refresh) Reload Project](command:als-reload-project "Reload Project")
281+
282+
[$(debug-restart) Restart Language Servers](command:ada.restartLanguageServers
283+
"Restart Ada Language Servers")`,
284+
);
285+
};
286+
150287
/**
151288
* Unregister all the task disposables needed by the extension (e.g: task providers,
152289
* listeners...).

integration/vscode/ada/src/extension.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,23 @@ async function activateExtension(context: vscode.ExtensionContext) {
145145
adaExtState = new ExtensionState(context);
146146
context.subscriptions.push(adaExtState);
147147

148-
// Subscribe to the didChangeConfiguration event
148+
// Subscribe to the didChangeConfiguration event to react to changes
149+
// in settings
149150
context.subscriptions.push(
150151
vscode.workspace.onDidChangeConfiguration(adaExtState.configChanged),
151152
);
152153

154+
// Subscribe to the didChangeActiveTextEditor event to update the status bar
155+
// item's visibility
156+
context.subscriptions.push(
157+
vscode.window.onDidChangeActiveTextEditor(adaExtState.updateStatusBarVisibility),
158+
);
159+
160+
// Subscribe to the didChangeDiagnostics event to update the status bar item's content
161+
context.subscriptions.push(
162+
vscode.languages.onDidChangeDiagnostics(adaExtState.updateStatusBarItem),
163+
);
164+
153165
const alsMiddleware: Middleware = {
154166
executeCommand: alsCommandExecutor(adaExtState.adaClient),
155167
};

integration/vscode/ada/test/general/helpers.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ suite('parallelize', function () {
290290
* overall the computation shouldn't take more than the
291291
* time needed to process one data item (with a margin).
292292
*/
293-
const margin = singleWorkDurationMs * 0.2;
293+
const margin = singleWorkDurationMs * 0.4;
294294
/**
295295
* When processing 4 items with 3 threads, the first parallel
296296
* batch processes 3 items and a second batch processes 1 item.
@@ -303,7 +303,7 @@ suite('parallelize', function () {
303303
assert.ok(
304304
duration < expectedTotalWorkDuration,
305305
`The computation took ${duration}ms when we expected` +
306-
` no more than ${expectedTotalWorkDuration}`,
306+
` no more than ${expectedTotalWorkDuration}ms`,
307307
);
308308
}
309309
});

integration/vscode/ada/test/general/tasks.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import {
2626
import { runTaskAndGetResult } from '../../src/taskProviders';
2727

2828
suite('Task Providers', function () {
29-
this.timeout('15s');
29+
// Set timeout to 15 seconds unless already configured to more
30+
this.timeout(Math.max(this.timeout(), 15000));
3031

3132
let projectPath: string;
3233

testsuite/ada_lsp/config_file/test.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,19 @@
2323
subprocess.check_call(["gprconfig", "--batch", "--config=Ada,,light,,GNAT"])
2424

2525

26-
@test()
26+
@test(
27+
als_settings={
28+
# Disable indexing to avoid wasting computation resources and risking test
29+
# timeouts
30+
"enableIndexing": False
31+
},
32+
timeout=30,
33+
)
2734
async def do_testing(lsp: ALSLanguageClient) -> None:
2835
# Set configuration file
2936
lsp.didChangeConfig(
3037
{"projectFile": URI("main.gpr"), "gprConfigurationFile": URI("default.cgpr")}
3138
)
32-
await lsp.awaitIndexingEnd()
3339

3440
# Send a didOpen for main.adb
3541
open_params, main_adb_uri = didOpenTextDocumentParams("main.adb")
@@ -49,7 +55,6 @@ async def do_testing(lsp: ALSLanguageClient) -> None:
4955
lsp.didChangeConfig(
5056
{"projectFile": "main1.gpr", "gprConfigurationFile": "default.cgpr"}
5157
)
52-
await lsp.awaitIndexingEnd()
5358

5459
# Send a didOpen for main.adb
5560
open_params, main_adb_uri = didOpenTextDocumentParams("main.adb")

0 commit comments

Comments
 (0)