Skip to content

Commit a51f8ba

Browse files
CMake: update, improve test summary invocation
* search for a Python3 interpreter for the test summary * replace an unnecessary macro invocation with a function * make summary depend on all other tests Making the summary depend on all other tests fixes test execution in random order (e.g., with `ctest --schedule-random`).
1 parent cda6bf6 commit a51f8ba

File tree

3 files changed

+30
-22
lines changed

3 files changed

+30
-22
lines changed

CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,14 @@ option(BUILD_TESTING "Build tests" ${_is_coverage_build})
179179
include(CTest)
180180
message(STATUS "Build tests: ${BUILD_TESTING}")
181181

182-
# lapack_testing.py uses features from python 2.7 and greater
183182
if(BUILD_TESTING)
184-
set(_msg "Looking for Python >= 2.7 needed for summary tests")
183+
set(_msg "Looking for Python3 needed for summary tests")
185184
message(STATUS "${_msg}")
186-
find_package(PythonInterp 2.7 QUIET)
187-
if(PYTHONINTERP_FOUND)
188-
message(STATUS "${_msg} - found (${PYTHON_VERSION_STRING})")
185+
# find_package(PythonInterp 3) cannot be used because /usr/bin/python may be
186+
# a Python2 interpreter.
187+
find_program(PYTHON_EXECUTABLE python3)
188+
if(PYTHON_EXECUTABLE)
189+
message(STATUS "${_msg} - found")
189190
else()
190191
message(STATUS "${_msg} - not found (skipping summary tests)")
191192
endif()

CTestCustom.cmake.in

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION
4646
"Warning: File .* has modification time .* in the future"
4747
)
4848

49-
# Only rung post test if suitable python interpreter was found
50-
set(PYTHONINTERP_FOUND @PYTHONINTERP_FOUND@)
49+
# Only run post test if suitable python interpreter was found
5150
set(PYTHON_EXECUTABLE @PYTHON_EXECUTABLE@)
52-
if(PYTHONINTERP_FOUND)
51+
if(PYTHON_EXECUTABLE)
5352
set(CTEST_CUSTOM_POST_TEST "${PYTHON_EXECUTABLE} ./lapack_testing.py -s -d TESTING")
5453
endif()
5554

TESTING/CMakeLists.txt

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,20 @@ if(MSVC_VERSION)
66
endif()
77
add_subdirectory(LIN)
88
add_subdirectory(EIG)
9-
macro(add_lapack_test output input target)
9+
10+
11+
# Only run this test if python 3 is found
12+
if(PYTHON_EXECUTABLE)
13+
message(STATUS "Running Summary")
14+
file(COPY ${LAPACK_SOURCE_DIR}/lapack_testing.py DESTINATION ${LAPACK_BINARY_DIR})
15+
add_test(
16+
NAME LAPACK_Test_Summary
17+
WORKING_DIRECTORY ${LAPACK_BINARY_DIR}
18+
COMMAND ${PYTHON_EXECUTABLE} "lapack_testing.py"
19+
)
20+
endif()
21+
22+
function(add_lapack_test output input target)
1023
set(TEST_INPUT "${LAPACK_SOURCE_DIR}/TESTING/${input}")
1124
set(TEST_OUTPUT "${LAPACK_BINARY_DIR}/TESTING/${output}")
1225
string(REPLACE "." "_" input_name ${input})
@@ -18,8 +31,15 @@ macro(add_lapack_test output input target)
1831
-DOUTPUT=${TEST_OUTPUT}
1932
-DINTDIR=${CMAKE_CFG_INTDIR}
2033
-P "${LAPACK_SOURCE_DIR}/TESTING/runtest.cmake")
34+
35+
if(PYTHONINTERP_FOUND)
36+
set_property(
37+
TEST LAPACK_Test_Summary
38+
APPEND PROPERTY DEPENDS LAPACK-${testName}
39+
)
40+
endif()
2141
endif()
22-
endmacro()
42+
endfunction()
2343

2444
if(BUILD_SINGLE)
2545
add_lapack_test(stest.out stest.in xlintsts)
@@ -156,15 +176,3 @@ if(BUILD_COMPLEX AND BUILD_COMPLEX16)
156176
# ======== COMPLEX-COMPLEX16 LIN TESTS ========================
157177
add_lapack_test(zctest.out zctest.in xlintstzc)
158178
endif()
159-
160-
# ==============================================================================
161-
# Only run this test if python 2.7 or greater is found
162-
if(PYTHONINTERP_FOUND)
163-
message(STATUS "Running Summary")
164-
file(COPY ${LAPACK_SOURCE_DIR}/lapack_testing.py DESTINATION ${LAPACK_BINARY_DIR})
165-
add_test(
166-
NAME LAPACK_Test_Summary
167-
WORKING_DIRECTORY ${LAPACK_BINARY_DIR}
168-
COMMAND ${PYTHON_EXECUTABLE} "lapack_testing.py"
169-
)
170-
endif()

0 commit comments

Comments
 (0)