47 lines · python
1"""2Test clang module build progress events.3"""4import os5import shutil6 7import lldb8import lldbsuite.test.lldbutil as lldbutil9from lldbsuite.test.decorators import *10from lldbsuite.test.lldbtest import *11 12 13class TestCase(TestBase):14 @skipUnlessDarwin15 def test_clang_module_build_progress_report(self):16 """Test receipt of progress events for clang module builds"""17 self.build()18 19 # Ensure an empty module cache.20 mod_cache = self.getBuildArtifact("new-modules")21 if os.path.isdir(mod_cache):22 shutil.rmtree(mod_cache)23 self.runCmd(f"settings set symbols.clang-modules-cache-path '{mod_cache}'")24 25 # TODO: The need for this seems like a bug.26 self.runCmd(27 f"settings set target.clang-module-search-paths '{self.getSourceDir()}'"28 )29 30 lldbutil.run_to_name_breakpoint(self, "main")31 32 # Just before triggering module builds, start listening for progress33 # events. Listening any earlier would result in a queue filled with34 # other unrelated progress events.35 broadcaster = self.dbg.GetBroadcaster()36 listener = lldbutil.start_listening_from(37 broadcaster, lldb.SBDebugger.eBroadcastBitProgress38 )39 40 # Trigger module builds.41 self.expect("expression @import MyModule")42 43 event = lldbutil.fetch_next_event(self, listener, broadcaster)44 payload = lldb.SBDebugger.GetProgressFromEvent(event)45 message = payload[0]46 self.assertEqual(message, "Building Clang modules")47