Revert "Move python binding tests to lit framework" (#149012)
This reverts commit f8707f994af2582f6dc58190106946efeb43bf05. (cherry picked from commit 7a9bef0166951a61bc7094514a20471ae45f6090)
This commit is contained in:
parent
cbe68e5140
commit
0da291f8a6
4
.github/workflows/libclang-python-tests.yml
vendored
4
.github/workflows/libclang-python-tests.yml
vendored
@ -10,15 +10,15 @@ on:
|
||||
- 'main'
|
||||
paths:
|
||||
- 'clang/bindings/python/**'
|
||||
- 'clang/test/bindings/python/**'
|
||||
- 'clang/tools/libclang/**'
|
||||
- 'clang/CMakeList.txt'
|
||||
- '.github/workflows/libclang-python-tests.yml'
|
||||
- '.github/workflows/llvm-project-tests.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'clang/bindings/python/**'
|
||||
- 'clang/test/bindings/python/**'
|
||||
- 'clang/tools/libclang/**'
|
||||
- 'clang/CMakeList.txt'
|
||||
- '.github/workflows/libclang-python-tests.yml'
|
||||
- '.github/workflows/llvm-project-tests.yml'
|
||||
|
||||
|
@ -536,6 +536,7 @@ if( CLANG_INCLUDE_TESTS )
|
||||
clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/test/Unit/lit.site.cfg
|
||||
)
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(bindings/python/tests)
|
||||
|
||||
if(CLANG_BUILT_STANDALONE)
|
||||
umbrella_lit_testsuite_end(check-all)
|
||||
|
66
clang/bindings/python/tests/CMakeLists.txt
Normal file
66
clang/bindings/python/tests/CMakeLists.txt
Normal file
@ -0,0 +1,66 @@
|
||||
# Test target to run Python test suite from main build.
|
||||
|
||||
# Avoid configurations including '-include' from interfering with
|
||||
# our tests by setting CLANG_NO_DEFAULT_CONFIG.
|
||||
add_custom_target(check-clang-python
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
CLANG_NO_DEFAULT_CONFIG=1
|
||||
CLANG_LIBRARY_PATH=$<TARGET_FILE_DIR:libclang>
|
||||
"${Python3_EXECUTABLE}" -m unittest discover
|
||||
DEPENDS libclang
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
|
||||
set(RUN_PYTHON_TESTS TRUE)
|
||||
set_target_properties(check-clang-python PROPERTIES FOLDER "Clang/Tests")
|
||||
|
||||
# Tests require libclang.so which is only built with LLVM_ENABLE_PIC=ON
|
||||
if(NOT LLVM_ENABLE_PIC)
|
||||
set(RUN_PYTHON_TESTS FALSE)
|
||||
endif()
|
||||
|
||||
# Do not try to run if libclang was built with sanitizers because
|
||||
# the sanitizer library will likely be loaded too late to perform
|
||||
# interception and will then fail.
|
||||
# We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
|
||||
# portable so its easier just to not run the tests when building
|
||||
# with ASan.
|
||||
if(NOT LLVM_USE_SANITIZER STREQUAL "")
|
||||
set(RUN_PYTHON_TESTS FALSE)
|
||||
endif()
|
||||
|
||||
# Tests fail on Windows, and need someone knowledgeable to fix.
|
||||
# It's not clear whether it's a test or a valid binding problem.
|
||||
if(WIN32)
|
||||
set(RUN_PYTHON_TESTS FALSE)
|
||||
endif()
|
||||
|
||||
# The Python FFI interface is broken on AIX: https://bugs.python.org/issue38628.
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
|
||||
set(RUN_PYTHON_TESTS FALSE)
|
||||
endif()
|
||||
|
||||
# AArch64, Hexagon, and Sparc have known test failures that need to be
|
||||
# addressed.
|
||||
# SystemZ has broken Python/FFI interface:
|
||||
# https://reviews.llvm.org/D52840#1265716
|
||||
if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|Sparc|SystemZ)$")
|
||||
set(RUN_PYTHON_TESTS FALSE)
|
||||
endif()
|
||||
|
||||
# Tests will fail if cross-compiling for a different target, as tests will try
|
||||
# to use the host Python3_EXECUTABLE and make FFI calls to functions in target
|
||||
# libraries.
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
# FIXME: Consider a solution that allows better control over these tests in
|
||||
# a crosscompiling scenario. e.g. registering them with lit to allow them to
|
||||
# be explicitly skipped via appropriate LIT_ARGS, or adding a mechanism to
|
||||
# allow specifying a python interpreter compiled for the target that could
|
||||
# be executed using qemu-user.
|
||||
message(WARNING "check-clang-python not added to check-all as these tests fail in a cross-build setup")
|
||||
set(RUN_PYTHON_TESTS FALSE)
|
||||
endif()
|
||||
|
||||
if(RUN_PYTHON_TESTS)
|
||||
set_property(GLOBAL APPEND PROPERTY
|
||||
LLVM_ALL_ADDITIONAL_TEST_TARGETS check-clang-python)
|
||||
endif()
|
@ -226,17 +226,6 @@ add_custom_target(clang-test)
|
||||
add_dependencies(clang-test check-clang)
|
||||
set_target_properties(clang-test PROPERTIES FOLDER "Clang/Tests")
|
||||
|
||||
# Allow running Clang Python binding tests separately from CI.
|
||||
add_lit_testsuite(check-clang-python "Running the Clang Python tests"
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
#LIT ${LLVM_LIT}
|
||||
PARAMS ${CLANG_TEST_PARAMS}
|
||||
DEPENDS ${CLANG_TEST_DEPS}
|
||||
ARGS ${CLANG_TEST_EXTRA_ARGS} --filter=bindings.sh
|
||||
# Avoid running tests twice.
|
||||
EXCLUDE_FROM_CHECK_ALL
|
||||
)
|
||||
|
||||
# FIXME: This logic can be removed once all buildbots have moved
|
||||
# debuginfo-test from clang/test to llvm/projects or monorepo.
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests)
|
||||
|
@ -1,38 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# UNSUPPORTED: !libclang-loadable
|
||||
|
||||
# Tests fail on Windows, and need someone knowledgeable to fix.
|
||||
# It's not clear whether it's a test or a valid binding problem.
|
||||
# XFAIL: target={{.*windows.*}}
|
||||
|
||||
# The Python FFI interface is broken on AIX: https://bugs.python.org/issue38628.
|
||||
# XFAIL: target={{.*-aix.*}}
|
||||
|
||||
# Hexagon has known test failures that need to be addressed.
|
||||
# https://reviews.llvm.org/D52840#1265716
|
||||
# XFAIL: target={{hexagon-.*}}
|
||||
# python SEGVs on Linux/sparc64 when loading libclang.so. Seems to be an FFI
|
||||
# issue, too.
|
||||
# XFAIL: target={{sparc.*-.*-linux.*}}
|
||||
|
||||
# Tests will fail if cross-compiling for a different target, as tests will try
|
||||
# to use the host Python3_EXECUTABLE and make FFI calls to functions in target
|
||||
# libraries.
|
||||
#
|
||||
# FIXME: Consider a solution that allows better control over these tests in
|
||||
# a crosscompiling scenario. e.g. registering them with lit to allow them to
|
||||
# be explicitly skipped via appropriate LIT_ARGS, or adding a mechanism to
|
||||
# allow specifying a python interpreter compiled for the target that could
|
||||
# be executed using qemu-user.
|
||||
# REQUIRES: native
|
||||
|
||||
# SystemZ has broken Python/FFI interface
|
||||
# according to https://reviews.llvm.org/D52840#1265716
|
||||
# This leads to failures only when Clang is built with GCC apparently, see:
|
||||
# https://github.com/llvm/llvm-project/pull/146844#issuecomment-3048291798
|
||||
# REQUIRES: !target={{s390x-.*}}
|
||||
|
||||
# RUN: env PYTHONPATH=%S/../../../bindings/python \
|
||||
# RUN: CLANG_LIBRARY_PATH=%libdir \
|
||||
# RUN: %python -m unittest discover -s %S/tests
|
@ -1,41 +0,0 @@
|
||||
def is_libclang_loadable():
|
||||
# Do not try to run if libclang was built with sanitizers because
|
||||
# the sanitizer library will likely be loaded too late to perform
|
||||
# interception and will then fail.
|
||||
# We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
|
||||
# portable so its easier just to not run the tests when building
|
||||
# with ASan.
|
||||
if config.llvm_use_sanitizer != "":
|
||||
return False
|
||||
try:
|
||||
sys.path.append(os.path.join(config.clang_src_dir, "bindings/python"))
|
||||
from clang.cindex import Config
|
||||
conf = Config()
|
||||
Config.set_library_path(config.clang_lib_dir)
|
||||
conf.lib
|
||||
return True
|
||||
except Exception as e:
|
||||
# Expected failure modes are considered benign when nothing can be
|
||||
# done about them.
|
||||
#
|
||||
# Cannot load a 32-bit libclang.so into a 64-bit python.
|
||||
if "wrong ELF class: ELFCLASS32" in str(e):
|
||||
return False
|
||||
# If libclang.so is missing, it must have been disabled intentionally,
|
||||
# e.g. by building with LLVM_ENABLE_PIC=OFF.
|
||||
elif "No such file or directory" in str(e):
|
||||
return False
|
||||
# Unexpected failure modes need to be investigated to either fix an
|
||||
# underlying bug or accept the failure, so return True. This causes
|
||||
# tests to run and FAIL, drawing developer attention.
|
||||
else:
|
||||
print("warning: unhandled failure in is_libclang_loadable: "
|
||||
+ str(e), file=sys.stderr)
|
||||
return True
|
||||
|
||||
if is_libclang_loadable():
|
||||
config.available_features.add("libclang-loadable")
|
||||
|
||||
config.substitutions.append(('%libdir', config.clang_lib_dir))
|
||||
|
||||
config.suffixes = ['.sh']
|
Loading…
x
Reference in New Issue
Block a user