r344240 - [python] [tests] Support overriding library path via environment
Michal Gorny via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 11 04:58:07 PDT 2018
Author: mgorny
Date: Thu Oct 11 04:58:07 2018
New Revision: 344240
URL: http://llvm.org/viewvc/llvm-project?rev=344240&view=rev
Log:
[python] [tests] Support overriding library path via environment
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
Modified:
cfe/trunk/bindings/python/README.txt
cfe/trunk/bindings/python/tests/cindex/test_access_specifiers.py
cfe/trunk/bindings/python/tests/cindex/test_cdb.py
cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
cfe/trunk/bindings/python/tests/cindex/test_comment.py
cfe/trunk/bindings/python/tests/cindex/test_cursor.py
cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
cfe/trunk/bindings/python/tests/cindex/test_diagnostics.py
cfe/trunk/bindings/python/tests/cindex/test_exception_specification_kind.py
cfe/trunk/bindings/python/tests/cindex/test_file.py
cfe/trunk/bindings/python/tests/cindex/test_index.py
cfe/trunk/bindings/python/tests/cindex/test_linkage.py
cfe/trunk/bindings/python/tests/cindex/test_location.py
cfe/trunk/bindings/python/tests/cindex/test_tls_kind.py
cfe/trunk/bindings/python/tests/cindex/test_token_kind.py
cfe/trunk/bindings/python/tests/cindex/test_tokens.py
cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py
cfe/trunk/bindings/python/tests/cindex/test_type.py
Modified: cfe/trunk/bindings/python/README.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/README.txt?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/README.txt (original)
+++ cfe/trunk/bindings/python/README.txt Thu Oct 11 04:58:07 2018
@@ -4,12 +4,12 @@
This directory implements Python bindings for Clang.
-You may need to alter LD_LIBRARY_PATH so that the Clang library can be
+You may need to set CLANG_LIBRARY_PATH so that the Clang library can be
found. The unit tests are designed to be run with any standard test
runner. For example:
--
$ env PYTHONPATH=$(echo ~/llvm/tools/clang/bindings/python/) \
- LD_LIBRARY_PATH=$(llvm-config --libdir) \
+ CLANG_LIBRARY_PATH=$(llvm-config --libdir) \
python -m unittest discover -v
tests.cindex.test_index.test_create ... ok
...
Modified: cfe/trunk/bindings/python/tests/cindex/test_access_specifiers.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_access_specifiers.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_access_specifiers.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_access_specifiers.py Thu Oct 11 04:58:07 2018
@@ -1,3 +1,7 @@
+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 AccessSpecifier
from clang.cindex import Cursor
Modified: cfe/trunk/bindings/python/tests/cindex/test_cdb.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cdb.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_cdb.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cdb.py Thu Oct 11 04:58:07 2018
@@ -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
Modified: cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_code_completion.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_code_completion.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_code_completion.py Thu Oct 11 04:58:07 2018
@@ -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 TranslationUnit
import unittest
Modified: cfe/trunk/bindings/python/tests/cindex/test_comment.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_comment.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_comment.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_comment.py Thu Oct 11 04:58:07 2018
@@ -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 TranslationUnit
from tests.cindex.util import get_cursor
Modified: cfe/trunk/bindings/python/tests/cindex/test_cursor.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cursor.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_cursor.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor.py Thu Oct 11 04:58:07 2018
@@ -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'])
+
import ctypes
import gc
import unittest
Modified: cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py Thu Oct 11 04:58:07 2018
@@ -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 CursorKind
import unittest
Modified: cfe/trunk/bindings/python/tests/cindex/test_diagnostics.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_diagnostics.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_diagnostics.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_diagnostics.py Thu Oct 11 04:58:07 2018
@@ -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 *
from .util import get_tu
Modified: cfe/trunk/bindings/python/tests/cindex/test_exception_specification_kind.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_exception_specification_kind.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_exception_specification_kind.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_exception_specification_kind.py Thu Oct 11 04:58:07 2018
@@ -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'])
+
import clang.cindex
from clang.cindex import ExceptionSpecificationKind
from .util import get_tu
Modified: cfe/trunk/bindings/python/tests/cindex/test_file.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_file.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_file.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_file.py Thu Oct 11 04:58:07 2018
@@ -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 Index, File
import unittest
Modified: cfe/trunk/bindings/python/tests/cindex/test_index.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_index.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_index.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_index.py Thu Oct 11 04:58:07 2018
@@ -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 *
import os
import unittest
Modified: cfe/trunk/bindings/python/tests/cindex/test_linkage.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_linkage.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_linkage.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_linkage.py Thu Oct 11 04:58:07 2018
@@ -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 LinkageKind
from clang.cindex import Cursor
from clang.cindex import TranslationUnit
Modified: cfe/trunk/bindings/python/tests/cindex/test_location.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_location.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_location.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_location.py Thu Oct 11 04:58:07 2018
@@ -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 Cursor
from clang.cindex import File
from clang.cindex import SourceLocation
Modified: cfe/trunk/bindings/python/tests/cindex/test_tls_kind.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_tls_kind.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_tls_kind.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_tls_kind.py Thu Oct 11 04:58:07 2018
@@ -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 TLSKind
from clang.cindex import Cursor
from clang.cindex import TranslationUnit
Modified: cfe/trunk/bindings/python/tests/cindex/test_token_kind.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_token_kind.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_token_kind.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_token_kind.py Thu Oct 11 04:58:07 2018
@@ -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 TokenKind
import unittest
Modified: cfe/trunk/bindings/python/tests/cindex/test_tokens.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_tokens.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_tokens.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_tokens.py Thu Oct 11 04:58:07 2018
@@ -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 CursorKind
from clang.cindex import Index
from clang.cindex import SourceLocation
Modified: cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py Thu Oct 11 04:58:07 2018
@@ -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 contextlib import contextmanager
import gc
import os
Modified: cfe/trunk/bindings/python/tests/cindex/test_type.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_type.py?rev=344240&r1=344239&r2=344240&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_type.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_type.py Thu Oct 11 04:58:07 2018
@@ -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'])
+
import gc
import unittest
More information about the cfe-commits
mailing list