1818class DAPTestCaseBase (TestBase ):
1919 # set timeout based on whether ASAN was enabled or not. Increase
2020 # timeout by a factor of 10 if ASAN is enabled.
21- DEFAULT_TIMEOUT = 10 * ( 10 if ( "ASAN_OPTIONS" in os . environ ) else 1 )
21+ DEFAULT_TIMEOUT = dap_server . DEFAULT_TIMEOUT
2222 NO_DEBUG_INFO_TESTCASE = True
2323
2424 def create_debug_adapter (
@@ -118,11 +118,9 @@ def set_function_breakpoints(
118118 self .wait_for_breakpoints_to_resolve (breakpoint_ids )
119119 return breakpoint_ids
120120
121- def wait_for_breakpoints_to_resolve (
122- self , breakpoint_ids : list [str ], timeout : Optional [float ] = DEFAULT_TIMEOUT
123- ):
121+ def wait_for_breakpoints_to_resolve (self , breakpoint_ids : list [str ]):
124122 unresolved_breakpoints = self .dap_server .wait_for_breakpoints_to_be_verified (
125- breakpoint_ids , timeout
123+ breakpoint_ids
126124 )
127125 self .assertEqual (
128126 len (unresolved_breakpoints ),
@@ -134,11 +132,10 @@ def wait_until(
134132 self ,
135133 predicate : Callable [[], bool ],
136134 delay : float = 0.5 ,
137- timeout : float = DEFAULT_TIMEOUT ,
138135 ) -> bool :
139136 """Repeatedly run the predicate until either the predicate returns True
140137 or a timeout has occurred."""
141- deadline = time .monotonic () + timeout
138+ deadline = time .monotonic () + self . DEFAULT_TIMEOUT
142139 while deadline > time .monotonic ():
143140 if predicate ():
144141 return True
@@ -155,15 +152,13 @@ def assertCapabilityIsNotSet(self, key: str, msg: Optional[str] = None) -> None:
155152 if key in self .dap_server .capabilities :
156153 self .assertEqual (self .dap_server .capabilities [key ], False , msg )
157154
158- def verify_breakpoint_hit (
159- self , breakpoint_ids : List [Union [int , str ]], timeout : float = DEFAULT_TIMEOUT
160- ):
155+ def verify_breakpoint_hit (self , breakpoint_ids : List [Union [int , str ]]):
161156 """Wait for the process we are debugging to stop, and verify we hit
162157 any breakpoint location in the "breakpoint_ids" array.
163158 "breakpoint_ids" should be a list of breakpoint ID strings
164159 (["1", "2"]). The return value from self.set_source_breakpoints()
165160 or self.set_function_breakpoints() can be passed to this function"""
166- stopped_events = self .dap_server .wait_for_stopped (timeout )
161+ stopped_events = self .dap_server .wait_for_stopped ()
167162 normalized_bp_ids = [str (b ) for b in breakpoint_ids ]
168163 for stopped_event in stopped_events :
169164 if "body" in stopped_event :
@@ -186,11 +181,11 @@ def verify_breakpoint_hit(
186181 f"breakpoint not hit, wanted breakpoint_ids { breakpoint_ids } in stopped_events { stopped_events } " ,
187182 )
188183
189- def verify_all_breakpoints_hit (self , breakpoint_ids , timeout = DEFAULT_TIMEOUT ):
184+ def verify_all_breakpoints_hit (self , breakpoint_ids ):
190185 """Wait for the process we are debugging to stop, and verify we hit
191186 all of the breakpoint locations in the "breakpoint_ids" array.
192187 "breakpoint_ids" should be a list of int breakpoint IDs ([1, 2])."""
193- stopped_events = self .dap_server .wait_for_stopped (timeout )
188+ stopped_events = self .dap_server .wait_for_stopped ()
194189 for stopped_event in stopped_events :
195190 if "body" in stopped_event :
196191 body = stopped_event ["body" ]
@@ -208,12 +203,12 @@ def verify_all_breakpoints_hit(self, breakpoint_ids, timeout=DEFAULT_TIMEOUT):
208203 return
209204 self .assertTrue (False , f"breakpoints not hit, stopped_events={ stopped_events } " )
210205
211- def verify_stop_exception_info (self , expected_description , timeout = DEFAULT_TIMEOUT ):
206+ def verify_stop_exception_info (self , expected_description ):
212207 """Wait for the process we are debugging to stop, and verify the stop
213208 reason is 'exception' and that the description matches
214209 'expected_description'
215210 """
216- stopped_events = self .dap_server .wait_for_stopped (timeout )
211+ stopped_events = self .dap_server .wait_for_stopped ()
217212 for stopped_event in stopped_events :
218213 if "body" in stopped_event :
219214 body = stopped_event ["body" ]
@@ -338,26 +333,14 @@ def get_console(self):
338333 def get_important (self ):
339334 return self .dap_server .get_output ("important" )
340335
341- def collect_stdout (
342- self , timeout : float = DEFAULT_TIMEOUT , pattern : Optional [str ] = None
343- ) -> str :
344- return self .dap_server .collect_output (
345- "stdout" , timeout = timeout , pattern = pattern
346- )
336+ def collect_stdout (self , pattern : Optional [str ] = None ) -> str :
337+ return self .dap_server .collect_output ("stdout" , pattern = pattern )
347338
348- def collect_console (
349- self , timeout : float = DEFAULT_TIMEOUT , pattern : Optional [str ] = None
350- ) -> str :
351- return self .dap_server .collect_output (
352- "console" , timeout = timeout , pattern = pattern
353- )
339+ def collect_console (self , pattern : Optional [str ] = None ) -> str :
340+ return self .dap_server .collect_output ("console" , pattern = pattern )
354341
355- def collect_important (
356- self , timeout : float = DEFAULT_TIMEOUT , pattern : Optional [str ] = None
357- ) -> str :
358- return self .dap_server .collect_output (
359- "important" , timeout = timeout , pattern = pattern
360- )
342+ def collect_important (self , pattern : Optional [str ] = None ) -> str :
343+ return self .dap_server .collect_output ("important" , pattern = pattern )
361344
362345 def get_local_as_int (self , name , threadId = None ):
363346 value = self .dap_server .get_local_variable_value (name , threadId = threadId )
@@ -393,22 +376,20 @@ def stepIn(
393376 targetId = None ,
394377 waitForStop = True ,
395378 granularity = "statement" ,
396- timeout = DEFAULT_TIMEOUT ,
397379 ):
398380 response = self .dap_server .request_stepIn (
399381 threadId = threadId , targetId = targetId , granularity = granularity
400382 )
401383 self .assertTrue (response ["success" ])
402384 if waitForStop :
403- return self .dap_server .wait_for_stopped (timeout )
385+ return self .dap_server .wait_for_stopped ()
404386 return None
405387
406388 def stepOver (
407389 self ,
408390 threadId = None ,
409391 waitForStop = True ,
410392 granularity = "statement" ,
411- timeout = DEFAULT_TIMEOUT ,
412393 ):
413394 response = self .dap_server .request_next (
414395 threadId = threadId , granularity = granularity
@@ -417,40 +398,40 @@ def stepOver(
417398 response ["success" ], f"next request failed: response { response } "
418399 )
419400 if waitForStop :
420- return self .dap_server .wait_for_stopped (timeout )
401+ return self .dap_server .wait_for_stopped ()
421402 return None
422403
423- def stepOut (self , threadId = None , waitForStop = True , timeout = DEFAULT_TIMEOUT ):
404+ def stepOut (self , threadId = None , waitForStop = True ):
424405 self .dap_server .request_stepOut (threadId = threadId )
425406 if waitForStop :
426- return self .dap_server .wait_for_stopped (timeout )
407+ return self .dap_server .wait_for_stopped ()
427408 return None
428409
429410 def do_continue (self ): # `continue` is a keyword.
430411 resp = self .dap_server .request_continue ()
431412 self .assertTrue (resp ["success" ], f"continue request failed: { resp } " )
432413
433- def continue_to_next_stop (self , timeout = DEFAULT_TIMEOUT ):
414+ def continue_to_next_stop (self ):
434415 self .do_continue ()
435- return self .dap_server .wait_for_stopped (timeout )
416+ return self .dap_server .wait_for_stopped ()
436417
437- def continue_to_breakpoint (self , breakpoint_id : str , timeout = DEFAULT_TIMEOUT ):
438- self .continue_to_breakpoints ((breakpoint_id ), timeout )
418+ def continue_to_breakpoint (self , breakpoint_id : str ):
419+ self .continue_to_breakpoints ((breakpoint_id ))
439420
440- def continue_to_breakpoints (self , breakpoint_ids , timeout = DEFAULT_TIMEOUT ):
421+ def continue_to_breakpoints (self , breakpoint_ids ):
441422 self .do_continue ()
442- self .verify_breakpoint_hit (breakpoint_ids , timeout )
423+ self .verify_breakpoint_hit (breakpoint_ids )
443424
444- def continue_to_exception_breakpoint (self , filter_label , timeout = DEFAULT_TIMEOUT ):
425+ def continue_to_exception_breakpoint (self , filter_label ):
445426 self .do_continue ()
446427 self .assertTrue (
447- self .verify_stop_exception_info (filter_label , timeout ),
428+ self .verify_stop_exception_info (filter_label ),
448429 'verify we got "%s"' % (filter_label ),
449430 )
450431
451- def continue_to_exit (self , exitCode = 0 , timeout = DEFAULT_TIMEOUT ):
432+ def continue_to_exit (self , exitCode = 0 ):
452433 self .do_continue ()
453- stopped_events = self .dap_server .wait_for_stopped (timeout )
434+ stopped_events = self .dap_server .wait_for_stopped ()
454435 self .assertEqual (
455436 len (stopped_events ), 1 , "stopped_events = {}" .format (stopped_events )
456437 )
0 commit comments