48 lines · python
1"""Test that importing modules in C++ works as expected."""2 3 4import lldb5import shutil6 7from lldbsuite.test.decorators import *8from lldbsuite.test.lldbtest import *9from lldbsuite.test import lldbutil10 11 12class CXXModulesImportTestCase(TestBase):13 def build(self):14 include = self.getBuildArtifact("include")15 lldbutil.mkdir_p(include)16 for f in ["Foo.h", "Bar.h", "module.modulemap"]:17 shutil.copyfile(18 self.getSourcePath(os.path.join("Inputs", f)), os.path.join(include, f)19 )20 super(CXXModulesImportTestCase, self).build()21 22 @skipUnlessDarwin23 @skipIf(macos_version=["<", "10.12"])24 @skipIf(compiler="clang", compiler_version=["<", "14.0"])25 def test_expr(self):26 self.build()27 target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(28 self, "break here", lldb.SBFileSpec("main.cpp")29 )30 31 self.expect("expr -l Objective-C++ -- @import Bar")32 self.expect("expr -- Bar()", substrs=["success"])33 self.expect(34 "expr -l Objective-C++ -- @import THIS_MODULE_DOES_NOT_EXIST", error=True35 )36 37 @skipUnlessDarwin38 @skipIf(macos_version=["<", "10.12"])39 @skipIf(compiler="clang", compiler_version=["<", "14.0"])40 def test_expr_failing_import(self):41 self.build()42 shutil.rmtree(self.getBuildArtifact("include"))43 target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(44 self, "break here", lldb.SBFileSpec("main.cpp")45 )46 47 self.expect("expr -l Objective-C++ -- @import Bar", error=True)48