aboutsummaryrefslogtreecommitdiff
path: root/bindings/python/tests/cindex/test_cdb.py
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/python/tests/cindex/test_cdb.py')
-rw-r--r--bindings/python/tests/cindex/test_cdb.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/bindings/python/tests/cindex/test_cdb.py b/bindings/python/tests/cindex/test_cdb.py
index 64651af31732..589fc72856bd 100644
--- a/bindings/python/tests/cindex/test_cdb.py
+++ b/bindings/python/tests/cindex/test_cdb.py
@@ -1,3 +1,8 @@
+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 CompilationDatabase
from clang.cindex import CompilationDatabaseError
from clang.cindex import CompileCommands
@@ -6,6 +11,8 @@ import os
import gc
import unittest
import sys
+from .util import skip_if_no_fspath
+from .util import str_to_path
kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS')
@@ -26,17 +33,19 @@ class TestCDB(unittest.TestCase):
"""Check we can load a compilation database"""
cdb = CompilationDatabase.fromDirectory(kInputsDir)
- def test_lookup_fail(self):
- """Check file lookup failure"""
- cdb = CompilationDatabase.fromDirectory(kInputsDir)
- self.assertIsNone(cdb.getCompileCommands('file_do_not_exist.cpp'))
-
def test_lookup_succeed(self):
"""Check we get some results if the file exists in the db"""
cdb = CompilationDatabase.fromDirectory(kInputsDir)
cmds = cdb.getCompileCommands('/home/john.doe/MyProject/project.cpp')
self.assertNotEqual(len(cmds), 0)
+ @skip_if_no_fspath
+ def test_lookup_succeed_pathlike(self):
+ """Same as test_lookup_succeed, but with PathLikes"""
+ cdb = CompilationDatabase.fromDirectory(str_to_path(kInputsDir))
+ cmds = cdb.getCompileCommands(str_to_path('/home/john.doe/MyProject/project.cpp'))
+ self.assertNotEqual(len(cmds), 0)
+
def test_all_compilecommand(self):
"""Check we get all results from the db"""
cdb = CompilationDatabase.fromDirectory(kInputsDir)