CMake: Fix running tests on Windows

For the API tests, output the test programs at $(TOP_BUILDDIR) so that
the freshly-built DLLs will be available for the test programs.  For
those that are run through the Python wrapper scripts, use
${PYTHON_EXECUTABLE} instead of plain 'python' in case the Python
interpreter is not in the PATH.
This commit is contained in:
Chun-wei Fan 2018-03-12 13:38:01 +08:00
parent b9dcbb1f83
commit eda6a5ea80
4 changed files with 10 additions and 5 deletions

View File

@ -21,7 +21,12 @@ if (HB_HAVE_GLIB)
message (FATAL_ERROR "No source file found for test ${test_name}")
endif ()
target_link_libraries (${test_name} harfbuzz harfbuzz-subset)
add_test (${test_name} ${test_name})
if (WIN32)
set_property (TARGET ${test_name} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_test (NAME ${test_name} COMMAND ${test_name})
else (WIN32)
add_test (${test_name} ${test_name})
endif (WIN32)
endforeach ()
set_tests_properties (${TEST_PROGS} PROPERTIES ENVIRONMENT
"G_TEST_SRCDIR=${CMAKE_CURRENT_SOURCE_DIR};G_TEST_BUILDDIR=${CMAKE_CURRENT_BINARY_DIR}"

View File

@ -13,6 +13,6 @@ if (HB_CHECK)
target_compile_definitions(hb-fuzzer PUBLIC ${FUZZING_CPPFLAGS})
add_test (NAME hb-fuzzer
COMMAND python run-fuzzer-tests.py $<TARGET_FILE:hb-fuzzer>
COMMAND "${PYTHON_EXECUTABLE}" run-fuzzer-tests.py $<TARGET_FILE:hb-fuzzer>
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif ()

View File

@ -3,7 +3,7 @@ if (HB_BUILD_UTILS)
extract_make_variable (TESTS ${INHOUSE})
foreach (test IN ITEMS ${TESTS})
add_test (NAME ${test}
COMMAND python run-tests.py $<TARGET_FILE:hb-shape> "data/in-house/${test}"
COMMAND "${PYTHON_EXECUTABLE}" run-tests.py $<TARGET_FILE:hb-shape> "data/in-house/${test}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endforeach ()
@ -11,7 +11,7 @@ if (HB_BUILD_UTILS)
extract_make_variable (TESTS ${TEXTRENDERING})
foreach (test IN ITEMS ${TESTS})
add_test (NAME ${test}
COMMAND python run-tests.py $<TARGET_FILE:hb-shape> "data/text-rendering-tests/${test}"
COMMAND "${PYTHON_EXECUTABLE}" run-tests.py $<TARGET_FILE:hb-shape> "data/text-rendering-tests/${test}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endforeach ()
endif ()

View File

@ -3,7 +3,7 @@ if (HB_BUILD_UTILS)
extract_make_variable (TESTS ${SOURCES})
foreach (test IN ITEMS ${TESTS})
add_test (NAME ${test}
COMMAND python run-tests.py $<TARGET_FILE:hb-subset> "data/${test}"
COMMAND "${PYTHON_EXECUTABLE}" run-tests.py $<TARGET_FILE:hb-subset> "data/${test}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set_property(TEST ${test} PROPERTY SKIP_RETURN_CODE 77)
endforeach ()