| 1 | import os |
| 2 | from clang.cindex import Config |
| 3 | if 'CLANG_LIBRARY_PATH' in os.environ: |
| 4 | Config.set_library_path(os.environ['CLANG_LIBRARY_PATH']) |
| 5 | |
| 6 | from clang.cindex import * |
| 7 | import os |
| 8 | import unittest |
| 9 | |
| 10 | |
| 11 | kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS') |
| 12 | |
| 13 | |
| 14 | class TestIndex(unittest.TestCase): |
| 15 | def test_create(self): |
| 16 | index = Index.create() |
| 17 | |
| 18 | # FIXME: test Index.read |
| 19 | |
| 20 | def test_parse(self): |
| 21 | index = Index.create() |
| 22 | self.assertIsInstance(index, Index) |
| 23 | tu = index.parse(os.path.join(kInputsDir, 'hello.cpp')) |
| 24 | self.assertIsInstance(tu, TranslationUnit) |
| 25 | tu = index.parse(None, ['-c', os.path.join(kInputsDir, 'hello.cpp')]) |
| 26 | self.assertIsInstance(tu, TranslationUnit) |
| 27 | |