Support a new CLANG_LIBRARY_PATH environment variable for the Python binding tests. This variable can be used to force the bindings to load libclang.* from a specific directory. I plan to use this when integrating Python binding tests with the CMake build system. Currently, those tests load libclang.so from default search paths, so I would have to rely on platform-specific mechanics such as LD_LIBRARY_PATH. Instead of copying the whole logic necessary to handle platform differences into yet another place, it's easier to just add a dedicated variable for this purpose. Differential Revision: https://reviews.llvm.org/D52806 llvm-svn: 344240
19 lines
533 B
Python
19 lines
533 B
Python
import os
|
|
from clang.cindex import Config
|
|
if 'CLANG_LIBRARY_PATH' in os.environ:
|
|
Config.set_library_path(os.environ['CLANG_LIBRARY_PATH'])
|
|
|
|
from clang.cindex import Index, File
|
|
|
|
import unittest
|
|
|
|
|
|
class TestFile(unittest.TestCase):
|
|
def test_file(self):
|
|
index = Index.create()
|
|
tu = index.parse('t.c', unsaved_files = [('t.c', "")])
|
|
file = File.from_name(tu, "t.c")
|
|
self.assertEqual(str(file), "t.c")
|
|
self.assertEqual(file.name, "t.c")
|
|
self.assertEqual(repr(file), "<File: t.c>")
|