Skip to content

Commit 0c359d7

Browse files
authored
Revert "Move python binding tests to lit framework (#142948)" (#145774)
This reverts commit 7dfcced since it casued a buildfailure: https://lab.llvm.org/buildbot/#/builders/46/builds/19019
1 parent 62f8281 commit 0c359d7

39 files changed

+67
-85
lines changed

clang/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ if( CLANG_INCLUDE_TESTS )
530530
clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/test/Unit/lit.site.cfg
531531
)
532532
add_subdirectory(test)
533+
add_subdirectory(bindings/python/tests)
533534

534535
if(CLANG_BUILT_STANDALONE)
535536
umbrella_lit_testsuite_end(check-all)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Test target to run Python test suite from main build.
2+
3+
# Avoid configurations including '-include' from interfering with
4+
# our tests by setting CLANG_NO_DEFAULT_CONFIG.
5+
add_custom_target(check-clang-python
6+
COMMAND ${CMAKE_COMMAND} -E env
7+
CLANG_NO_DEFAULT_CONFIG=1
8+
CLANG_LIBRARY_PATH=$<TARGET_FILE_DIR:libclang>
9+
"${Python3_EXECUTABLE}" -m unittest discover
10+
DEPENDS libclang
11+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
12+
13+
set(RUN_PYTHON_TESTS TRUE)
14+
set_target_properties(check-clang-python PROPERTIES FOLDER "Clang/Tests")
15+
16+
# Tests require libclang.so which is only built with LLVM_ENABLE_PIC=ON
17+
if(NOT LLVM_ENABLE_PIC)
18+
set(RUN_PYTHON_TESTS FALSE)
19+
endif()
20+
21+
# Do not try to run if libclang was built with sanitizers because
22+
# the sanitizer library will likely be loaded too late to perform
23+
# interception and will then fail.
24+
# We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
25+
# portable so its easier just to not run the tests when building
26+
# with ASan.
27+
if(NOT LLVM_USE_SANITIZER STREQUAL "")
28+
set(RUN_PYTHON_TESTS FALSE)
29+
endif()
30+
31+
# Tests fail on Windows, and need someone knowledgeable to fix.
32+
# It's not clear whether it's a test or a valid binding problem.
33+
if(WIN32)
34+
set(RUN_PYTHON_TESTS FALSE)
35+
endif()
36+
37+
# The Python FFI interface is broken on AIX: https://bugs.python.org/issue38628.
38+
if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
39+
set(RUN_PYTHON_TESTS FALSE)
40+
endif()
41+
42+
# AArch64, Hexagon, and Sparc have known test failures that need to be
43+
# addressed.
44+
# SystemZ has broken Python/FFI interface:
45+
# https://reviews.llvm.org/D52840#1265716
46+
if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|Sparc|SystemZ)$")
47+
set(RUN_PYTHON_TESTS FALSE)
48+
endif()
49+
50+
# Tests will fail if cross-compiling for a different target, as tests will try
51+
# to use the host Python3_EXECUTABLE and make FFI calls to functions in target
52+
# libraries.
53+
if(CMAKE_CROSSCOMPILING)
54+
# FIXME: Consider a solution that allows better control over these tests in
55+
# a crosscompiling scenario. e.g. registering them with lit to allow them to
56+
# be explicitly skipped via appropriate LIT_ARGS, or adding a mechanism to
57+
# allow specifying a python interpreter compiled for the target that could
58+
# be executed using qemu-user.
59+
message(WARNING "check-clang-python not added to check-all as these tests fail in a cross-build setup")
60+
set(RUN_PYTHON_TESTS FALSE)
61+
endif()
62+
63+
if(RUN_PYTHON_TESTS)
64+
set_property(GLOBAL APPEND PROPERTY
65+
LLVM_ALL_ADDITIONAL_TEST_TARGETS check-clang-python)
66+
endif()

clang/test/CMakeLists.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -211,17 +211,6 @@ add_custom_target(clang-test)
211211
add_dependencies(clang-test check-clang)
212212
set_target_properties(clang-test PROPERTIES FOLDER "Clang/Tests")
213213

214-
# Allow running Clang Python binding tests separately from CI.
215-
add_lit_testsuite(check-clang-python "Running the Clang Python tests"
216-
${CMAKE_CURRENT_BINARY_DIR}
217-
#LIT ${LLVM_LIT}
218-
PARAMS ${CLANG_TEST_PARAMS}
219-
DEPENDS ${CLANG_TEST_DEPS}
220-
ARGS ${CLANG_TEST_EXTRA_ARGS} --filter=bindings.sh
221-
# Avoid running tests twice.
222-
EXCLUDE_FROM_CHECK_ALL
223-
)
224-
225214
# FIXME: This logic can be removed once all buildbots have moved
226215
# debuginfo-test from clang/test to llvm/projects or monorepo.
227216
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests)

clang/test/bindings/python/bindings.sh

Lines changed: 0 additions & 35 deletions
This file was deleted.

clang/test/bindings/python/lit.local.cfg

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)