Skip to content

Commit cac3634

Browse files
committed
Merge branch 'topic/gnattest-doc' into 'master'
Document how to work with multiple projects in the same workspace Closes #1660 See merge request eng/ide/ada_language_server!2029
2 parents 49a248a + ad598e6 commit cac3634

File tree

1 file changed

+64
-4
lines changed

1 file changed

+64
-4
lines changed

README.md

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,16 @@ extension at
5252
- [Tasks](#tasks)
5353
- [Task Customization](#task-customization)
5454
- [Tasks for Project Mains](#tasks-for-project-mains)
55+
- [Status Bar](#status-bar)
5556
- [Alire Support](#alire-support)
5657
- [GNATtest Support](#gnattest-support)
58+
- [Using multi-root workspaces for test development](#using-multi-root-workspaces-for-test-development)
59+
- [Limitations](#limitations)
5760
- [GNATcoverage Support](#gnatcoverage-support)
61+
- [Cross and Embedded Support](#cross-and-embedded-support)
62+
- [GNATemulator Support](#gnatemulator-support)
63+
- [Remote Debugging](#remote-debugging)
64+
- [Working with Multiple Projects in the Same VS Code Workspace](#working-with-multiple-projects-in-the-same-vs-code-workspace)
5865
- [Commands and Shortcuts](#commands-and-shortcuts)
5966
- [Ada: Go to other file](#ada-go-to-other-file)
6067
- [Ada: Add subprogram box](#ada-add-subprogram-box)
@@ -300,12 +307,17 @@ If you install GNATtest, the Ada & SPARK extension for VS Code will provide the
300307

301308
<img src="doc/gnattest-results.png" width="500" alt="GNATtest Test Results"/>
302309

303-
GNATtest support has the following known limitations:
310+
#### Using multi-root workspaces for test development
304311

305-
* The extension relies on the default conventions of GNATtest such as the naming, location and object directory of the test harness project.
306-
If those aspects are configured or altered manually, the features may no longer work.
312+
When developing tests, it is recommended to use the test harness project auto-generated by GNATtest.
313+
You can do so by editing the `ada.projectFile` setting to point to the test harness project.
314+
However to avoid switching back and forth between the main application project and the test harness project,
315+
see [Working with Multiple Projects in the Same VS Code Workspace](#working-with-multiple-projects-in-the-same-vs-code-workspace) for instructions on opening the test harness project in a separate VS Code window.
307316

308-
* Language support such as navigation and auto-completion is limited when editing test sources. A workaround is to modify the `ada.projectFile` setting to point to the test harness project created by GNATtest. That should restore language support when developing tests.
317+
#### Limitations
318+
319+
* If you use a separate window to load the test harness project and edit tests, you have to go back to the main application project to benefit from the integration with the Test Explorer view (e.g. listing and searching for tests, running tests, etc...).
320+
This limitation is planned to be lifted.
309321

310322
* Sections of test sources delimited by `begin read only` and `end read only` comments are not really protected from inadvertant edits.
311323
To ensure proper interactions with GNATtest, you must refrain from making edits in those sections.
@@ -375,6 +387,54 @@ Once your project is setup, just open the VS Code
375387

376388
For more advanced use cases or if your program cannot be debugged remotely via GDB, you can try creating your custom VS Code debug launch configuration following [VS Code User's Guide for Launch Configurations](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations).
377389

390+
### Working with Multiple Projects in the Same VS Code Workspace
391+
392+
It is a possible for a workspace to contain multiple GPR projects.
393+
For example, this is a typical scenario when working with GNATtest which generates (potentially multiple) test harness projects that contain test and stub sources that interface with the application code.
394+
However, only one project can be loaded at a time with the `ada.projectFile` setting.
395+
So you may find yourself switching back and forth between projects which can quickly become cumbersome.
396+
397+
This situation can be improved with [VS Code multi-root workspaces](https://code.visualstudio.com/docs/editing/workspaces/multi-root-workspaces). For example, in a workspace containing `prj1.gpr` and `prj2.gpr` it is possible to define the following two multi-root workspace files:
398+
399+
* `prj1.code-workspace`
400+
401+
```json
402+
{
403+
"folders": [
404+
{
405+
"path": "."
406+
}
407+
],
408+
"settings": {
409+
"ada.projectFile": "prj1.gpr"
410+
}
411+
}
412+
```
413+
414+
* `prj2.code-workspace`
415+
416+
```json
417+
{
418+
"folders": [
419+
{
420+
"path": "."
421+
}
422+
],
423+
"settings": {
424+
"ada.projectFile": "prj2.gpr"
425+
}
426+
}
427+
```
428+
429+
(while the name indicates _multi-root_, we are using a single root folder in each workspace)
430+
431+
Each of these workspaces can be opened in a different VS Code window, allowing to work on both projects side by side.
432+
Alternatively, the root workspace materialized by `.vscode/settings.json` can be kept as the main workspace with `prj1.gpr`, and the other multi-root workspace is created as `prj2.code-workspace` for working with `prj2.gpr`.
433+
434+
In the use case of GNATtest, this allows us to load the main application project in a window and the test harness project in another window, and work on both simultaneously.
435+
436+
Note that a separate Ada Language Server instance is used for each VS Code window, so you might observe high memory consumption in this situation.
437+
378438
### Commands and Shortcuts
379439

380440
The extension contributes commands and a few default key bindings.

0 commit comments

Comments
 (0)