-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LLDB][SBProgress] Add a finalize method #128966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7597ee0
143e4da
213d685
ae9e91f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,35 +5,6 @@ | |
|
||
|
||
class SBProgressTestCase(TestBase): | ||
def test_with_external_bit_set(self): | ||
"""Test SBProgress events are listened to when the external bit is set.""" | ||
|
||
progress = lldb.SBProgress("Test SBProgress", "Test progress", self.dbg) | ||
listener = lldb.SBListener("Test listener") | ||
broadcaster = self.dbg.GetBroadcaster() | ||
broadcaster.AddListener(listener, lldb.eBroadcastBitExternalProgress) | ||
event = lldb.SBEvent() | ||
|
||
expected_string = "Test progress first increment" | ||
progress.Increment(1, expected_string) | ||
self.assertTrue(listener.PeekAtNextEvent(event)) | ||
stream = lldb.SBStream() | ||
event.GetDescription(stream) | ||
self.assertIn(expected_string, stream.GetData()) | ||
|
||
def test_without_external_bit_set(self): | ||
"""Test SBProgress events are not listened to on the internal progress bit.""" | ||
|
||
progress = lldb.SBProgress("Test SBProgress", "Test progress", self.dbg) | ||
listener = lldb.SBListener("Test listener") | ||
broadcaster = self.dbg.GetBroadcaster() | ||
broadcaster.AddListener(listener, lldb.eBroadcastBitProgress) | ||
event = lldb.SBEvent() | ||
|
||
expected_string = "Test progress first increment" | ||
progress.Increment(1, expected_string) | ||
self.assertFalse(listener.PeekAtNextEvent(event)) | ||
|
||
def test_with_external_bit_set(self): | ||
"""Test SBProgress can handle null events.""" | ||
|
||
|
@@ -65,3 +36,33 @@ def test_with_external_bit_set(self): | |
stream = lldb.SBStream() | ||
event.GetDescription(stream) | ||
self.assertIn("Step 3", stream.GetData()) | ||
|
||
def test_progress_finalize_non_deterministic_progress(self): | ||
"""Test SBProgress finalize sends the progressEnd event""" | ||
|
||
progress = lldb.SBProgress("Test SBProgress", "Test finalize", self.dbg) | ||
listener = lldb.SBListener("Test listener") | ||
broadcaster = self.dbg.GetBroadcaster() | ||
broadcaster.AddListener(listener, lldb.eBroadcastBitExternalProgressCategory) | ||
event = lldb.SBEvent() | ||
progress.Finalize() | ||
self.assertTrue(listener.WaitForEvent(5, event)) | ||
stream = lldb.SBStream() | ||
event.GetDescription(stream) | ||
self.assertIn("type = end", stream.GetData()) | ||
|
||
def test_progress_finalize_deterministic_progress(self): | ||
"""Test SBProgress finalize sends the progressEnd event""" | ||
|
||
progress = lldb.SBProgress("Test SBProgress", "Test finalize", 13, self.dbg) | ||
listener = lldb.SBListener("Test listener") | ||
broadcaster = self.dbg.GetBroadcaster() | ||
broadcaster.AddListener(listener, lldb.eBroadcastBitExternalProgressCategory) | ||
event = lldb.SBEvent() | ||
progress.Finalize() | ||
self.assertTrue(listener.WaitForEvent(5, event)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't you have to wait for the first progress start event and also the end event here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope! Because we create the progress event before wiring up the listener we only listen for the end message. |
||
stream = lldb.SBStream() | ||
event.GetDescription(stream) | ||
# Note even for progresses with a total, the total isn't | ||
# sent in the end message. | ||
self.assertIn("type = end", stream.GetData()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add some usage documentation here for both non-determinisitic and deterministic progress class usage in python here. That way people can see this and use the class as intended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember this being 1:1 with Progress and not being changed so I would think we should add a new doc string to Increment. Is there anything in particular you want to call out? Many of the deterministic/non-deterministic are predominantly relevant to DAP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made an attempt at summarizing this in increment in manner that doesn't expose too much about the externals. Specifically so that it doesn't go out of date instantly.