@@ -125,18 +125,20 @@ def test_set_and_clear(self):
125
125
# Set 3 breakpoints and verify that they got set correctly
126
126
response = self .dap_server .request_setBreakpoints (self .main_path , lines )
127
127
line_to_id = {}
128
- breakpoints = response ["body" ]["breakpoints" ]
129
- self .assertEqual (
130
- len (breakpoints ),
131
- len (lines ),
132
- "expect %u source breakpoints" % (len (lines )),
133
- )
134
- for index , breakpoint in enumerate (breakpoints ):
135
- line = breakpoint ["line" ]
136
- self .assertEqual (line , lines [index ])
137
- # Store the "id" of the breakpoint that was set for later
138
- line_to_id [line ] = breakpoint ["id" ]
139
- self .assertTrue (breakpoint ["verified" ], "expect breakpoint verified" )
128
+ if response :
129
+ breakpoints = response ["body" ]["breakpoints" ]
130
+ self .assertEqual (
131
+ len (breakpoints ),
132
+ len (lines ),
133
+ "expect %u source breakpoints" % (len (lines )),
134
+ )
135
+ for breakpoint , index in zip (breakpoints , range (len (lines ))):
136
+ line = breakpoint ["line" ]
137
+ self .assertTrue (line , lines [index ])
138
+ # Store the "id" of the breakpoint that was set for later
139
+ line_to_id [line ] = breakpoint ["id" ]
140
+ self .assertIn (line , lines , "line expected in lines array" )
141
+ self .assertTrue (breakpoint ["verified" ], "expect breakpoint verified" )
140
142
141
143
# There is no breakpoint delete packet, clients just send another
142
144
# setBreakpoints packet with the same source file with fewer lines.
@@ -149,66 +151,75 @@ def test_set_and_clear(self):
149
151
# Set 2 breakpoints and verify that the previous breakpoints that were
150
152
# set above are still set.
151
153
response = self .dap_server .request_setBreakpoints (self .main_path , lines )
152
- breakpoints = response ["body" ]["breakpoints" ]
153
- self .assertEqual (
154
- len (breakpoints ),
155
- len (lines ),
156
- "expect %u source breakpoints" % (len (lines )),
157
- )
158
- for index , breakpoint in enumerate (breakpoints ):
159
- line = breakpoint ["line" ]
160
- self .assertEqual (line , lines [index ])
161
- # Verify the same breakpoints are still set within LLDB by
162
- # making sure the breakpoint ID didn't change
154
+ if response :
155
+ breakpoints = response ["body" ]["breakpoints" ]
163
156
self .assertEqual (
164
- line_to_id [ line ] ,
165
- breakpoint [ "id" ] ,
166
- "verify previous breakpoints stayed the same" ,
157
+ len ( breakpoints ) ,
158
+ len ( lines ) ,
159
+ "expect %u source breakpoints" % ( len ( lines )) ,
167
160
)
168
- self .assertTrue (breakpoint ["verified" ], "expect breakpoint still verified" )
161
+ for breakpoint , index in zip (breakpoints , range (len (lines ))):
162
+ line = breakpoint ["line" ]
163
+ self .assertTrue (line , lines [index ])
164
+ # Verify the same breakpoints are still set within LLDB by
165
+ # making sure the breakpoint ID didn't change
166
+ self .assertEqual (
167
+ line_to_id [line ],
168
+ breakpoint ["id" ],
169
+ "verify previous breakpoints stayed the same" ,
170
+ )
171
+ self .assertIn (line , lines , "line expected in lines array" )
172
+ self .assertTrue (
173
+ breakpoint ["verified" ], "expect breakpoint still verified"
174
+ )
169
175
170
176
# Now get the full list of breakpoints set in the target and verify
171
177
# we have only 2 breakpoints set. The response above could have told
172
178
# us about 2 breakpoints, but we want to make sure we don't have the
173
179
# third one still set in the target
174
180
response = self .dap_server .request_testGetTargetBreakpoints ()
175
- breakpoints = response ["body" ]["breakpoints" ]
176
- self .assertEqual (
177
- len (breakpoints ),
178
- len (lines ),
179
- "expect %u source breakpoints" % (len (lines )),
180
- )
181
- for breakpoint in breakpoints :
182
- line = breakpoint ["line" ]
183
- # Verify the same breakpoints are still set within LLDB by
184
- # making sure the breakpoint ID didn't change
181
+ if response :
182
+ breakpoints = response ["body" ]["breakpoints" ]
185
183
self .assertEqual (
186
- line_to_id [ line ] ,
187
- breakpoint [ "id" ] ,
188
- "verify previous breakpoints stayed the same" ,
184
+ len ( breakpoints ) ,
185
+ len ( lines ) ,
186
+ "expect %u source breakpoints" % ( len ( lines )) ,
189
187
)
190
- self .assertIn (line , lines , "line expected in lines array" )
191
- self .assertTrue (breakpoint ["verified" ], "expect breakpoint still verified" )
188
+ for breakpoint in breakpoints :
189
+ line = breakpoint ["line" ]
190
+ # Verify the same breakpoints are still set within LLDB by
191
+ # making sure the breakpoint ID didn't change
192
+ self .assertEqual (
193
+ line_to_id [line ],
194
+ breakpoint ["id" ],
195
+ "verify previous breakpoints stayed the same" ,
196
+ )
197
+ self .assertIn (line , lines , "line expected in lines array" )
198
+ self .assertTrue (
199
+ breakpoint ["verified" ], "expect breakpoint still verified"
200
+ )
192
201
193
202
# Now clear all breakpoints for the source file by passing down an
194
203
# empty lines array
195
204
lines = []
196
205
response = self .dap_server .request_setBreakpoints (self .main_path , lines )
197
- breakpoints = response ["body" ]["breakpoints" ]
198
- self .assertEqual (
199
- len (breakpoints ),
200
- len (lines ),
201
- "expect %u source breakpoints" % (len (lines )),
202
- )
206
+ if response :
207
+ breakpoints = response ["body" ]["breakpoints" ]
208
+ self .assertEqual (
209
+ len (breakpoints ),
210
+ len (lines ),
211
+ "expect %u source breakpoints" % (len (lines )),
212
+ )
203
213
204
214
# Verify with the target that all breakpoints have been cleared
205
215
response = self .dap_server .request_testGetTargetBreakpoints ()
206
- breakpoints = response ["body" ]["breakpoints" ]
207
- self .assertEqual (
208
- len (breakpoints ),
209
- len (lines ),
210
- "expect %u source breakpoints" % (len (lines )),
211
- )
216
+ if response :
217
+ breakpoints = response ["body" ]["breakpoints" ]
218
+ self .assertEqual (
219
+ len (breakpoints ),
220
+ len (lines ),
221
+ "expect %u source breakpoints" % (len (lines )),
222
+ )
212
223
213
224
# Now set a breakpoint again in the same source file and verify it
214
225
# was added.
@@ -270,11 +281,12 @@ def test_clear_breakpoints_unset_breakpoints(self):
270
281
self .assertEqual (
271
282
len (breakpoints ), len (lines ), "expect %u source breakpoints" % (len (lines ))
272
283
)
273
- for index , breakpoint in enumerate (breakpoints ):
284
+ for breakpoint , index in zip (breakpoints , range ( len ( lines )) ):
274
285
line = breakpoint ["line" ]
275
- self .assertEqual (line , lines [index ])
286
+ self .assertTrue (line , lines [index ])
276
287
# Store the "id" of the breakpoint that was set for later
277
288
line_to_id [line ] = breakpoint ["id" ]
289
+ self .assertIn (line , lines , "line expected in lines array" )
278
290
self .assertTrue (breakpoint ["verified" ], "expect breakpoint verified" )
279
291
280
292
# Now clear all breakpoints for the source file by not setting the
@@ -344,49 +356,3 @@ def test_functionality(self):
344
356
self .continue_to_breakpoints (breakpoint_ids )
345
357
i = int (self .dap_server .get_local_variable_value ("i" ))
346
358
self .assertEqual (i , 7 , "i != 7 showing post hitCondition hits every time" )
347
-
348
- @skipIfWindows
349
- def test_column_breakpoints (self ):
350
- """Test setting multiple breakpoints in the same line at different columns."""
351
- loop_line = line_number ("main.cpp" , "// break loop" )
352
-
353
- program = self .getBuildArtifact ("a.out" )
354
- self .build_and_launch (program )
355
-
356
- # Set two breakpoints on the loop line at different columns.
357
- columns = [13 , 39 ]
358
- response = self .dap_server .request_setBreakpoints (
359
- self .main_path , [loop_line , loop_line ], list ({"column" : c } for c in columns )
360
- )
361
-
362
- # Verify the breakpoints were set correctly
363
- breakpoints = response ["body" ]["breakpoints" ]
364
- breakpoint_ids = []
365
- self .assertEqual (
366
- len (breakpoints ),
367
- len (columns ),
368
- "expect %u source breakpoints" % (len (columns )),
369
- )
370
- for index , breakpoint in enumerate (breakpoints ):
371
- self .assertEqual (breakpoint ["line" ], loop_line )
372
- self .assertEqual (breakpoint ["column" ], columns [index ])
373
- self .assertTrue (breakpoint ["verified" ], "expect breakpoint verified" )
374
- breakpoint_ids .append (breakpoint ["id" ])
375
-
376
- # Continue to the first breakpoint,
377
- self .continue_to_breakpoints ([breakpoint_ids [0 ]])
378
-
379
- # We should have stopped right before the call to `twelve`.
380
- # Step into and check we are inside `twelve`.
381
- self .stepIn ()
382
- func_name = self .get_stackFrames ()[0 ]["name" ]
383
- self .assertEqual (func_name , "twelve(int)" )
384
-
385
- # Continue to the second breakpoint.
386
- self .continue_to_breakpoints ([breakpoint_ids [1 ]])
387
-
388
- # We should have stopped right before the call to `fourteen`.
389
- # Step into and check we are inside `fourteen`.
390
- self .stepIn ()
391
- func_name = self .get_stackFrames ()[0 ]["name" ]
392
- self .assertEqual (func_name , "a::fourteen(int)" )
0 commit comments