@@ -426,20 +426,22 @@ const testAll = (isDlvDap: boolean) => {
426
426
* 3. scopesRequest
427
427
* 4. variablesRequest
428
428
*/
429
- async function assertVariableValue ( name : string , val : string ) : Promise < void > {
429
+ async function assertLocalVariableValue ( name : string , val : string ) : Promise < void > {
430
430
const threadsResponse = await dc . threadsRequest ( ) ;
431
431
assert ( threadsResponse . success ) ;
432
432
const stackTraceResponse = await dc . stackTraceRequest ( { threadId : threadsResponse . body . threads [ 0 ] . id } ) ;
433
433
assert ( stackTraceResponse . success ) ;
434
434
const scopesResponse = await dc . scopesRequest ( { frameId : stackTraceResponse . body . stackFrames [ 0 ] . id } ) ;
435
435
assert ( scopesResponse . success ) ;
436
+ const localScopeIndex = scopesResponse . body . scopes . findIndex ( ( v ) => v . name === 'Local' || v . name === 'Locals' ) ;
437
+ assert ( localScopeIndex >= 0 , "no scope named 'Local':" ) ;
436
438
const variablesResponse = await dc . variablesRequest ( {
437
- variablesReference : scopesResponse . body . scopes [ 0 ] . variablesReference
439
+ variablesReference : scopesResponse . body . scopes [ localScopeIndex ] . variablesReference
438
440
} ) ;
439
441
assert ( variablesResponse . success ) ;
440
442
// Locate the variable with the matching name.
441
443
const i = variablesResponse . body . variables . findIndex ( ( v ) => v . name === name ) ;
442
- assert ( i >= 0 ) ;
444
+ assert ( i >= 0 , `no variable in scope named ${ name } ` ) ;
443
445
// Check that the value of name is val.
444
446
assert . strictEqual ( variablesResponse . body . variables [ i ] . value , val ) ;
445
447
}
@@ -698,7 +700,7 @@ const testAll = (isDlvDap: boolean) => {
698
700
const debugConfig = await initializeDebugConfig ( config ) ;
699
701
await dc . hitBreakpoint ( debugConfig , getBreakpointLocation ( FILE , BREAKPOINT_LINE ) ) ;
700
702
701
- await assertVariableValue ( 'strdat' , '"Hello, World!"' ) ;
703
+ await assertLocalVariableValue ( 'strdat' , '"Hello, World!"' ) ;
702
704
} ) ;
703
705
704
706
test ( 'should debug program without cwd set' , async function ( ) {
@@ -721,7 +723,7 @@ const testAll = (isDlvDap: boolean) => {
721
723
const debugConfig = await initializeDebugConfig ( config ) ;
722
724
await dc . hitBreakpoint ( debugConfig , getBreakpointLocation ( FILE , BREAKPOINT_LINE ) ) ;
723
725
724
- await assertVariableValue ( 'strdat' , '"Goodbye, World."' ) ;
726
+ await assertLocalVariableValue ( 'strdat' , '"Goodbye, World."' ) ;
725
727
} ) ;
726
728
727
729
test ( 'should debug file program with cwd set' , async function ( ) {
@@ -745,7 +747,7 @@ const testAll = (isDlvDap: boolean) => {
745
747
const debugConfig = await initializeDebugConfig ( config ) ;
746
748
await dc . hitBreakpoint ( debugConfig , getBreakpointLocation ( FILE , BREAKPOINT_LINE ) ) ;
747
749
748
- await assertVariableValue ( 'strdat' , '"Hello, World!"' ) ;
750
+ await assertLocalVariableValue ( 'strdat' , '"Hello, World!"' ) ;
749
751
} ) ;
750
752
751
753
test ( 'should debug file program without cwd set' , async function ( ) {
@@ -769,7 +771,7 @@ const testAll = (isDlvDap: boolean) => {
769
771
770
772
await dc . hitBreakpoint ( debugConfig , getBreakpointLocation ( FILE , BREAKPOINT_LINE ) ) ;
771
773
772
- await assertVariableValue ( 'strdat' , '"Goodbye, World."' ) ;
774
+ await assertLocalVariableValue ( 'strdat' , '"Goodbye, World."' ) ;
773
775
} ) ;
774
776
775
777
test ( 'should run program with cwd set (noDebug)' , async function ( ) {
@@ -1146,11 +1148,7 @@ const testAll = (isDlvDap: boolean) => {
1146
1148
} ) ;
1147
1149
1148
1150
suite ( 'conditionalBreakpoints' , ( ) => {
1149
- test ( 'should stop on conditional breakpoint' , async function ( ) {
1150
- if ( isDlvDap && dlvDapSkipsEnabled ) {
1151
- this . skip ( ) ; // not working in dlv-dap.
1152
- }
1153
-
1151
+ test ( 'should stop on conditional breakpoint' , async ( ) => {
1154
1152
const PROGRAM = path . join ( DATA_ROOT , 'condbp' ) ;
1155
1153
const FILE = path . join ( DATA_ROOT , 'condbp' , 'condbp.go' ) ;
1156
1154
const BREAKPOINT_LINE = 7 ;
@@ -1183,15 +1181,11 @@ const testAll = (isDlvDap: boolean) => {
1183
1181
dc . assertStoppedLocation ( 'breakpoint' , location )
1184
1182
] ) . then ( ( ) =>
1185
1183
// The program is stopped at the breakpoint, check to make sure 'i == 1'.
1186
- assertVariableValue ( 'i' , '2' )
1184
+ assertLocalVariableValue ( 'i' , '2' )
1187
1185
) ;
1188
1186
} ) ;
1189
1187
1190
- test ( 'should add breakpoint condition' , async function ( ) {
1191
- if ( isDlvDap && dlvDapSkipsEnabled ) {
1192
- this . skip ( ) ; // not working in dlv-dap.
1193
- }
1194
-
1188
+ test ( 'should add breakpoint condition' , async ( ) => {
1195
1189
const PROGRAM = path . join ( DATA_ROOT , 'condbp' ) ;
1196
1190
const FILE = path . join ( DATA_ROOT , 'condbp' , 'condbp.go' ) ;
1197
1191
const BREAKPOINT_LINE = 7 ;
@@ -1209,7 +1203,7 @@ const testAll = (isDlvDap: boolean) => {
1209
1203
. hitBreakpoint ( debugConfig , location )
1210
1204
. then ( ( ) =>
1211
1205
// The program is stopped at the breakpoint, check to make sure 'i == 0'.
1212
- assertVariableValue ( 'i' , '0' )
1206
+ assertLocalVariableValue ( 'i' , '0' )
1213
1207
)
1214
1208
. then ( ( ) =>
1215
1209
// Add a condition to the breakpoint, and make sure it runs until 'i == 2'.
@@ -1225,17 +1219,13 @@ const testAll = (isDlvDap: boolean) => {
1225
1219
dc . assertStoppedLocation ( 'breakpoint' , location )
1226
1220
] ) . then ( ( ) =>
1227
1221
// The program is stopped at the breakpoint, check to make sure 'i == 2'.
1228
- assertVariableValue ( 'i' , '2' )
1222
+ assertLocalVariableValue ( 'i' , '2' )
1229
1223
)
1230
1224
)
1231
1225
) ;
1232
1226
} ) ;
1233
1227
1234
- test ( 'should remove breakpoint condition' , async function ( ) {
1235
- if ( isDlvDap && dlvDapSkipsEnabled ) {
1236
- this . skip ( ) ; // not working in dlv-dap.
1237
- }
1238
-
1228
+ test ( 'should remove breakpoint condition' , async ( ) => {
1239
1229
const PROGRAM = path . join ( DATA_ROOT , 'condbp' ) ;
1240
1230
const FILE = path . join ( DATA_ROOT , 'condbp' , 'condbp.go' ) ;
1241
1231
const BREAKPOINT_LINE = 7 ;
@@ -1269,7 +1259,7 @@ const testAll = (isDlvDap: boolean) => {
1269
1259
] )
1270
1260
. then ( ( ) =>
1271
1261
// The program is stopped at the breakpoint, check to make sure 'i == 2'.
1272
- assertVariableValue ( 'i' , '2' )
1262
+ assertLocalVariableValue ( 'i' , '2' )
1273
1263
)
1274
1264
. then ( ( ) =>
1275
1265
// Remove the breakpoint condition, and make sure the program runs until 'i == 3'.
@@ -1285,7 +1275,7 @@ const testAll = (isDlvDap: boolean) => {
1285
1275
dc . assertStoppedLocation ( 'breakpoint' , location )
1286
1276
] ) . then ( ( ) =>
1287
1277
// The program is stopped at the breakpoint, check to make sure 'i == 3'.
1288
- assertVariableValue ( 'i' , '3' )
1278
+ assertLocalVariableValue ( 'i' , '3' )
1289
1279
)
1290
1280
)
1291
1281
) ;
@@ -1608,7 +1598,7 @@ const testAll = (isDlvDap: boolean) => {
1608
1598
}
1609
1599
1610
1600
test ( 'should stop on a breakpoint set in file with substituted path' , async function ( ) {
1611
- if ( isDlvDap ) {
1601
+ if ( isDlvDap && dlvDapSkipsEnabled ) {
1612
1602
this . skip ( ) ; // not working in dlv-dap.
1613
1603
}
1614
1604
@@ -1656,7 +1646,7 @@ const testAll = (isDlvDap: boolean) => {
1656
1646
} ) ;
1657
1647
1658
1648
test ( 'stopped for a breakpoint set during initialization using substitutePath (remote attach)' , async function ( ) {
1659
- if ( isDlvDap ) {
1649
+ if ( isDlvDap && dlvDapSkipsEnabled ) {
1660
1650
this . skip ( ) ; // not working in dlv-dap.
1661
1651
}
1662
1652
0 commit comments