Skip to content

Commit f4e4c38

Browse files
committed
[lldb] Update TestSwiftProgressReporting.py to use lldbutil event helper functions
This patch updates TestSwiftProgressReporting.py to use the new event listener helper function `start_listening_from` and `fetch_next_event`. It keeps fetching new events until it have matched all the expected swift type-system progress events message. If the we're missing one of the expected event, the test will error out, because of `fetch_next_event` won't be getting any new event. Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 97d41b2 commit f4e4c38

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

lldb/test/API/functionalities/progress_reporting/swift_progress_reporting/TestSwiftProgressReporting.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77

88
from lldbsuite.test.lldbtest import *
99
from lldbsuite.test.decorators import *
10-
from lldbsuite.test.eventlistener import EventListenerTestBase
1110

12-
class TestSwiftProgressReporting(EventListenerTestBase):
11+
class TestSwiftProgressReporting(TestBase):
1312

1413
mydir = TestBase.compute_mydir(__file__)
15-
event_mask = lldb.SBDebugger.eBroadcastBitProgress
16-
event_data_extractor = lldb.SBDebugger.GetProgressFromEvent
1714

15+
def setUp(self):
16+
TestBase.setUp(self)
17+
self.broadcaster = self.dbg.GetBroadcaster()
18+
self.listener = lldbutil.start_listening_from(self.broadcaster,
19+
lldb.SBDebugger.eBroadcastBitProgress)
1820
@swiftTest
1921
@skipIf(oslist=no_match(["macosx"]))
2022
def test_swift_progress_report(self):
@@ -31,14 +33,15 @@ def test_swift_progress_report(self):
3133
# Resolve variable to exercise the type-system
3234
self.runCmd("expr boo")
3335

34-
self.assertGreater(len(self.events), 0)
35-
3636
beacons = [ "Loading Swift module",
3737
"Caching Swift user imports from",
3838
"Setting up Swift reflection for",
3939
"Getting Swift compile unit imports for"]
4040

41-
for beacon in beacons:
42-
filtered_events = list(filter(lambda event: beacon in event[0],
43-
self.events))
44-
self.assertGreater(len(filtered_events), 0)
41+
while len(beacons):
42+
event = lldbutil.fetch_next_event(self, self.listener, self.broadcaster)
43+
ret_args = lldb.SBDebugger.GetProgressFromEvent(event)
44+
45+
for beacon in beacons:
46+
if beacon in ret_args[0]:
47+
beacons.remove(beacon)

0 commit comments

Comments
 (0)