Skip to content

Commit 9e2a69c

Browse files
committed
[lldb-dap] Make TestDAP_Progress more resilient (again)
Before llvm#134048, TestDAP_Progress would wait up to 15 seconds before checking whether the events came in. Now the test is a lot faster, but we risk checking the events before they've all arrived. Make up to 10 attempts to find the end event, with a 100ms sleep in between, giving the test up to a second for the event to arrive after it has been broadcast.
1 parent 4b67c53 commit 9e2a69c

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

lldb/test/API/tools/lldb-dap/progress/TestDAP_Progress.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,31 @@
1212

1313

1414
class TestDAP_progress(lldbdap_testcase.DAPTestCaseBase):
15+
MAX_ATTEMPS = 10
16+
1517
def verify_progress_events(
1618
self,
1719
expected_title,
1820
expected_message=None,
1921
expected_not_in_message=None,
2022
only_verify_first_update=False,
2123
):
22-
self.assertTrue(len(self.dap_server.progress_events) > 0)
24+
# Make up to 10 attempts (= 1 second) for the end event to arrive.
25+
end_found = False
26+
for _ in range(self.MAX_ATTEMPS):
27+
for event in self.dap_server.progress_events:
28+
event_type = event["event"]
29+
if "progressEnd" in event_type:
30+
end_found = True
31+
break
32+
# Wait 100ms before checking again.
33+
time.sleep(0.10)
34+
self.assertTrue(end_found)
35+
36+
# Make sure we found the start and update event. If we got this far, we
37+
# already know we got an end event.
2338
start_found = False
2439
update_found = False
25-
end_found = False
2640
for event in self.dap_server.progress_events:
2741
event_type = event["event"]
2842
if "progressStart" in event_type:
@@ -38,12 +52,11 @@ def verify_progress_events(
3852
if expected_not_in_message is not None:
3953
self.assertNotIn(expected_not_in_message, message)
4054
update_found = True
41-
if "progressEnd" in event_type:
42-
end_found = True
4355

4456
self.assertTrue(start_found)
4557
self.assertTrue(update_found)
46-
self.assertTrue(end_found)
58+
59+
# Clear the progress events.
4760
self.dap_server.progress_events.clear()
4861

4962
@skipIfWindows

0 commit comments

Comments
 (0)