1
1
import assert from 'assert' ;
2
2
import { suite , test } from 'mocha' ;
3
- import { AdaConfig , adaDynamicDebugConfigProvider } from '../../../src/debugConfigProvider' ;
3
+ import {
4
+ AdaConfig ,
5
+ adaDynamicDebugConfigProvider ,
6
+ createQuickPicksInitialLaunch ,
7
+ getOrFindGdb ,
8
+ } from '../../../src/debugConfigProvider' ;
9
+ import { exe } from '../../../src/helpers' ;
4
10
import { activate } from '../utils' ;
11
+ import { adaExtState } from '../../../src/extension' ;
5
12
6
13
suite ( 'Debug Configurations' , function ( ) {
14
+ let expectedConfigs : string ;
15
+
7
16
this . beforeAll ( async ( ) => {
8
17
await activate ( ) ;
18
+ expectedConfigs = `
19
+ [
20
+ {
21
+ "type": "cppdbg",
22
+ "name": "Ada: Debug main - src/main1.adb",
23
+ "request": "launch",
24
+ "targetArchitecture": "x64",
25
+ "cwd": "\${workspaceFolder}",
26
+ "program": "\${workspaceFolder}/obj/main1exec${ exe } ",
27
+ "stopAtEntry": false,
28
+ "externalConsole": false,
29
+ "args": [],
30
+ "MIMode": "gdb",
31
+ "preLaunchTask": "ada: Build main - src/main1.adb",
32
+ "setupCommands": [
33
+ {
34
+ "description": "Catch all Ada exceptions",
35
+ "text": "catch exception",
36
+ "ignoreFailures": true
37
+ },
38
+ {
39
+ "description": "Enable pretty-printing for gdb",
40
+ "text": "-enable-pretty-printing",
41
+ "ignoreFailures": true
42
+ }
43
+ ],
44
+ "miDebuggerPath": "${ getOrFindGdb ( ) ?? '<undefined>' } "
45
+ },
46
+ {
47
+ "name": "Ada: Attach debugger to running process - src/main1.adb",
48
+ "type": "cppdbg",
49
+ "request": "attach",
50
+ "program": "\${workspaceFolder}/obj/main1exec${ exe } ",
51
+ "processId": "\${command:pickProcess}",
52
+ "MIMode": "gdb",
53
+ "miDebuggerPath": "${ getOrFindGdb ( ) ?? '<undefined>' } "
54
+ },
55
+ {
56
+ "type": "cppdbg",
57
+ "name": "Ada: Debug main - src/test.adb",
58
+ "request": "launch",
59
+ "targetArchitecture": "x64",
60
+ "cwd": "\${workspaceFolder}",
61
+ "program": "\${workspaceFolder}/obj/test${ exe } ",
62
+ "stopAtEntry": false,
63
+ "externalConsole": false,
64
+ "args": [],
65
+ "MIMode": "gdb",
66
+ "preLaunchTask": "ada: Build main - src/test.adb",
67
+ "setupCommands": [
68
+ {
69
+ "description": "Catch all Ada exceptions",
70
+ "text": "catch exception",
71
+ "ignoreFailures": true
72
+ },
73
+ {
74
+ "description": "Enable pretty-printing for gdb",
75
+ "text": "-enable-pretty-printing",
76
+ "ignoreFailures": true
77
+ }
78
+ ],
79
+ "miDebuggerPath": "${ getOrFindGdb ( ) ?? '<undefined>' } "
80
+ },
81
+ {
82
+ "name": "Ada: Attach debugger to running process - src/test.adb",
83
+ "type": "cppdbg",
84
+ "request": "attach",
85
+ "program": "\${workspaceFolder}/obj/test${ exe } ",
86
+ "processId": "\${command:pickProcess}",
87
+ "MIMode": "gdb",
88
+ "miDebuggerPath": "${ getOrFindGdb ( ) ?? '<undefined>' } "
89
+ }
90
+ ]` ;
9
91
} ) ;
10
92
11
93
test ( 'GDB path is explicitely set in offered debug config' , async ( ) => {
@@ -17,8 +99,7 @@ suite('Debug Configurations', function () {
17
99
} ) ;
18
100
19
101
test ( 'GDB path is the same for all configs' , async ( ) => {
20
- const configs =
21
- ( await adaDynamicDebugConfigProvider . provideDebugConfigurations ( ) ) as AdaConfig [ ] ;
102
+ const configs = await adaDynamicDebugConfigProvider . provideDebugConfigurations ( ) ;
22
103
23
104
assert ( configs . length > 1 ) ;
24
105
const miDebuggerPath = configs . at ( 0 ) ?. miDebuggerPath ;
@@ -30,13 +111,50 @@ suite('Debug Configurations', function () {
30
111
} ) ;
31
112
32
113
test ( 'Two debug configs per main are proposed' , async ( ) => {
33
- const configs =
34
- ( await adaDynamicDebugConfigProvider . provideDebugConfigurations ( ) ) as AdaConfig [ ] ;
114
+ const configs = await adaDynamicDebugConfigProvider . provideDebugConfigurations ( ) ;
35
115
const expected = `
36
116
Ada: Debug main - src/main1.adb
37
117
Ada: Attach debugger to running process - src/main1.adb
38
118
Ada: Debug main - src/test.adb
39
119
Ada: Attach debugger to running process - src/test.adb` . trim ( ) ;
40
120
assert . equal ( configs . map ( ( v ) => `${ v . name } ` ) . join ( '\n' ) , expected ) ;
41
121
} ) ;
122
+
123
+ test ( 'Initial' , async ( ) => {
124
+ const { quickpick } = await createQuickPicksInitialLaunch ( ) ;
125
+
126
+ const expected = `
127
+ Ada: Debug main - src/main1.adb
128
+ Ada: Attach debugger to running process - src/main1.adb
129
+ Ada: Debug main - src/test.adb
130
+ Ada: Attach debugger to running process - src/test.adb
131
+
132
+ All of the above - Create all of the above configurations in the launch.json file` ;
133
+ assert . equal (
134
+ quickpick
135
+ . map ( ( e ) => `${ e . label } ${ e . description ? ' - ' + e . description : '' } ` )
136
+ . join ( '\n' ) ,
137
+ expected . trim ( )
138
+ ) ;
139
+
140
+ assert . equal (
141
+ JSON . stringify (
142
+ quickpick
143
+ . filter ( ( e ) => 'conf' in e )
144
+ . map ( ( e ) => {
145
+ assert ( 'conf' in e ) ;
146
+ return e . conf ;
147
+ } ) ,
148
+ null ,
149
+ 2
150
+ ) . trim ( ) ,
151
+ expectedConfigs . trim ( )
152
+ ) ;
153
+ } ) ;
154
+
155
+ test ( 'Dynamic' , async ( ) => {
156
+ const configs = await adaExtState . dynamicDebugConfigProvider . provideDebugConfigurations ( ) ;
157
+
158
+ assert . equal ( JSON . stringify ( configs , undefined , 2 ) . trim ( ) , expectedConfigs . trim ( ) ) ;
159
+ } ) ;
42
160
} ) ;
0 commit comments