diff options
| author | Jacob Lalonde <jalalonde@fb.com> | 2025-01-17 12:00:31 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-17 12:00:31 -0800 |
| commit | 6b048aeaf837e0e16fece94610f0871d17cefe4c (patch) | |
| tree | f7d81657a79f07bcf2ba2c7365243bf7ed9d0f74 /lldb/test/API/python_api | |
| parent | 128e2e446e90c3b1827cfc7d4d19e3c0976beff3 (diff) | |
| download | llvm-6b048aeaf837e0e16fece94610f0871d17cefe4c.zip llvm-6b048aeaf837e0e16fece94610f0871d17cefe4c.tar.gz llvm-6b048aeaf837e0e16fece94610f0871d17cefe4c.tar.bz2 | |
[LLDB] Add SBProgress so Python scripts can also report progress (#119052)
Recently I've been working on a lot of internal Python tooling, and in
certain cases I want to report async to the script over DAP. Progress.h
already handles this, so I've exposed Progress via the SB API so Python
scripts can also update progress objects.
I actually have no idea how to test this, so I just wrote a [toy command
to test
it](https://gist.github.com/Jlalond/48d85e75a91f7a137e3142e6a13d0947)

I also copied the first section of the extensive Progress.h class
documentation to the docstrings.
Diffstat (limited to 'lldb/test/API/python_api')
| -rw-r--r-- | lldb/test/API/python_api/sbprogress/TestSBProgress.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lldb/test/API/python_api/sbprogress/TestSBProgress.py b/lldb/test/API/python_api/sbprogress/TestSBProgress.py new file mode 100644 index 0000000..c456247 --- /dev/null +++ b/lldb/test/API/python_api/sbprogress/TestSBProgress.py @@ -0,0 +1,35 @@ +"""Test the SBProgress API.""" + +import lldb +from lldbsuite.test.lldbtest import * + + +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)) |
