brintos

brintos / llvm-project-archived public Read only

0
0
Text · 714 B · f3d3ac0 Raw
26 lines · python
1import os2 3from clang.cindex import Config, Index, TranslationUnit4 5if "CLANG_LIBRARY_PATH" in os.environ:6    Config.set_library_path(os.environ["CLANG_LIBRARY_PATH"])7 8import unittest9 10INPUTS_DIR = os.path.join(os.path.dirname(__file__), "INPUTS")11 12 13class TestIndex(unittest.TestCase):14    def test_create(self):15        Index.create()16 17    # FIXME: test Index.read18 19    def test_parse(self):20        index = Index.create()21        self.assertIsInstance(index, Index)22        tu = index.parse(os.path.join(INPUTS_DIR, "hello.cpp"))23        self.assertIsInstance(tu, TranslationUnit)24        tu = index.parse(None, ["-c", os.path.join(INPUTS_DIR, "hello.cpp")])25        self.assertIsInstance(tu, TranslationUnit)26