-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LLDB][SBProgress] Fix bad optional in sbprogress #128971
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
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 |
---|---|---|
|
@@ -33,3 +33,35 @@ def test_without_external_bit_set(self): | |
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.""" | ||
|
||
progress = lldb.SBProgress("Test SBProgress", "Test progress", 3, self.dbg) | ||
listener = lldb.SBListener("Test listener") | ||
broadcaster = self.dbg.GetBroadcaster() | ||
broadcaster.AddListener(listener, lldb.eBroadcastBitExternalProgress) | ||
event = lldb.SBEvent() | ||
# Sample JSON we're expecting: | ||
# { id = 2, title = "Test SBProgress", details = "Test progress", type = update, progress = 1 of 3} | ||
# details remains the same as specified in the constructor of the progress | ||
# until we update it in the increment function, so we check for the Null and empty string case | ||
# that details hasn't changed, but progress x of 3 has. | ||
progress.Increment(1, None) | ||
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. Would 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. Good callout, I expanded the test case. |
||
self.assertTrue(listener.GetNextEvent(event)) | ||
stream = lldb.SBStream() | ||
event.GetDescription(stream) | ||
self.assertIn("Test progress", stream.GetData()) | ||
self.assertIn("1 of 3", stream.GetData()) | ||
|
||
progress.Increment(1, "") | ||
self.assertTrue(listener.GetNextEvent(event)) | ||
event.GetDescription(stream) | ||
self.assertIn("Test progress", stream.GetData()) | ||
self.assertIn("2 of 3", stream.GetData()) | ||
|
||
progress.Increment(1, "Step 3") | ||
self.assertTrue(listener.GetNextEvent(event)) | ||
stream = lldb.SBStream() | ||
event.GetDescription(stream) | ||
self.assertIn("Step 3", stream.GetData()) | ||
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. can we test that we receive these events with the correct data here? (get the start event, the 3 increment events with no detail for the first two and then "Step 3" for the 3rd increment, though right now that might come through as an end event? |
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.
So this only calls increment if there is a non-null and non-empty description. Is that the correct behavior? Or should we still be calling increment with a
nullopt
in that case?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.
No we only set the value of the description optional if non-null, non-empty description. So
Increment(1, NULL/None in Python)
will bump the count by one but send no message.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.
Ah yeah, I read that wrong. Thanks for confirming.