xref: /llvm-project/lldb/test/API/lang/objc/modules-cache/TestClangModulesCache.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
199451b44SJordan Rupprecht"""Test that the clang modules cache directory can be controlled."""
299451b44SJordan Rupprecht
399451b44SJordan Rupprecht
499451b44SJordan Rupprechtimport os
599451b44SJordan Rupprechtimport shutil
699451b44SJordan Rupprecht
799451b44SJordan Rupprechtimport lldb
899451b44SJordan Rupprechtfrom lldbsuite.test.decorators import *
999451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import *
1099451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil
1199451b44SJordan Rupprecht
1299451b44SJordan Rupprecht
1399451b44SJordan Rupprechtclass ObjCModulesTestCase(TestBase):
1499451b44SJordan Rupprecht    NO_DEBUG_INFO_TESTCASE = True
1599451b44SJordan Rupprecht
1699451b44SJordan Rupprecht    def test_expr(self):
1799451b44SJordan Rupprecht        self.build()
1899451b44SJordan Rupprecht        self.main_source_file = lldb.SBFileSpec("main.m")
1999451b44SJordan Rupprecht        self.runCmd("settings set target.auto-import-clang-modules true")
2099451b44SJordan Rupprecht        mod_cache = self.getBuildArtifact("my-clang-modules-cache")
2199451b44SJordan Rupprecht        if os.path.isdir(mod_cache):
2299451b44SJordan Rupprecht            shutil.rmtree(mod_cache)
23*2238dcc3SJonas Devlieghere        self.assertFalse(os.path.isdir(mod_cache), "module cache should not exist")
2499451b44SJordan Rupprecht        self.runCmd('settings set symbols.clang-modules-cache-path "%s"' % mod_cache)
25*2238dcc3SJonas Devlieghere        self.runCmd(
26*2238dcc3SJonas Devlieghere            'settings set target.clang-module-search-paths "%s"' % self.getSourceDir()
27*2238dcc3SJonas Devlieghere        )
2899451b44SJordan Rupprecht        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
29*2238dcc3SJonas Devlieghere            self, "Set breakpoint here", self.main_source_file
30*2238dcc3SJonas Devlieghere        )
3199451b44SJordan Rupprecht        self.runCmd("expr @import Foo")
3299451b44SJordan Rupprecht        self.assertTrue(os.path.isdir(mod_cache), "module cache exists")
33