tests: improve RunTests.cmake (#10239)

- allow for passing in BUSTED_ARGS via env
- quote values of TEST_TAG/TEST_FILTER

  Previously TEST_FILTER="'foo bar'" was required.

This allows for:

    make functionaltest TEST_FILE=test/functional/terminal/tui_spec.lua \
      BUSTED_ARGS="--no-keep-going --shuffle" \
      TEST_FILTER="TUI background color handles"

* RunTests.cmake: BUILD_DIR for Xtest files, isolated TMPDIR

Assume relative path for given TEST_PATH.
This commit is contained in:
Daniel Hahler 2019-06-22 06:44:52 +02:00 committed by GitHub
parent 058a8ed6ec
commit f1f9a2f97b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,12 +2,12 @@
set(ENV{LC_ALL} "en_US.UTF-8") set(ENV{LC_ALL} "en_US.UTF-8")
set(ENV{VIMRUNTIME} ${WORKING_DIR}/runtime) set(ENV{VIMRUNTIME} ${WORKING_DIR}/runtime)
set(ENV{NVIM_RPLUGIN_MANIFEST} ${WORKING_DIR}/Xtest_rplugin_manifest) set(ENV{NVIM_RPLUGIN_MANIFEST} ${BUILD_DIR}/Xtest_rplugin_manifest)
set(ENV{XDG_CONFIG_HOME} ${WORKING_DIR}/Xtest_xdg/config) set(ENV{XDG_CONFIG_HOME} ${BUILD_DIR}/Xtest_xdg/config)
set(ENV{XDG_DATA_HOME} ${WORKING_DIR}/Xtest_xdg/share) set(ENV{XDG_DATA_HOME} ${BUILD_DIR}/Xtest_xdg/share)
if(NOT DEFINED ENV{NVIM_LOG_FILE}) if(NOT DEFINED ENV{NVIM_LOG_FILE})
set(ENV{NVIM_LOG_FILE} ${WORKING_DIR}/.nvimlog) set(ENV{NVIM_LOG_FILE} ${BUILD_DIR}/.nvimlog)
endif() endif()
if(NVIM_PRG) if(NVIM_PRG)
@ -16,40 +16,47 @@ endif()
if(DEFINED ENV{TEST_FILE}) if(DEFINED ENV{TEST_FILE})
set(TEST_PATH "$ENV{TEST_FILE}") set(TEST_PATH "$ENV{TEST_FILE}")
set(rel_test_path "${TEST_PATH}")
else() else()
set(TEST_PATH "${TEST_DIR}/${TEST_TYPE}") set(TEST_PATH "${TEST_DIR}/${TEST_TYPE}")
file(RELATIVE_PATH rel_test_path "${TEST_DIR}" "${TEST_PATH}")
endif() endif()
if(BUSTED_OUTPUT_TYPE STREQUAL junit) if(BUSTED_OUTPUT_TYPE STREQUAL junit)
set(EXTRA_ARGS OUTPUT_FILE ${BUILD_DIR}/${TEST_TYPE}test-junit.xml) set(EXTRA_ARGS OUTPUT_FILE ${BUILD_DIR}/${TEST_TYPE}test-junit.xml)
endif() endif()
set(BUSTED_ARGS $ENV{BUSTED_ARGS})
separate_arguments(BUSTED_ARGS)
if(DEFINED ENV{TEST_TAG} AND NOT "$ENV{TEST_TAG}" STREQUAL "") if(DEFINED ENV{TEST_TAG} AND NOT "$ENV{TEST_TAG}" STREQUAL "")
set(TEST_TAG "--tags=$ENV{TEST_TAG}") list(APPEND BUSTED_ARGS --tags="$ENV{TEST_TAG}")
endif() endif()
if(DEFINED ENV{TEST_FILTER} AND NOT "$ENV{TEST_FILTER}" STREQUAL "") if(DEFINED ENV{TEST_FILTER} AND NOT "$ENV{TEST_FILTER}" STREQUAL "")
set(TEST_FILTER "--filter=$ENV{TEST_FILTER}") list(APPEND BUSTED_ARGS --filter="$ENV{TEST_FILTER}")
endif() endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${WORKING_DIR}/Xtest-tmpdir) # TMPDIR: use relative test path (for parallel test runs / isolation).
set(ENV{TMPDIR} ${WORKING_DIR}/Xtest-tmpdir) set(ENV{TMPDIR} "${BUILD_DIR}/Xtest_tmpdir/${rel_test_path}")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory $ENV{TMPDIR})
set(ENV{SYSTEM_NAME} ${SYSTEM_NAME}) set(ENV{SYSTEM_NAME} ${SYSTEM_NAME})
execute_process( execute_process(
COMMAND ${BUSTED_PRG} ${TEST_TAG} ${TEST_FILTER} -v -o ${BUSTED_OUTPUT_TYPE} COMMAND ${BUSTED_PRG} -v -o ${BUSTED_OUTPUT_TYPE}
--lua=${LUA_PRG} --lazy --helper=${TEST_DIR}/${TEST_TYPE}/preload.lua --lua=${LUA_PRG} --lazy --helper=${TEST_DIR}/${TEST_TYPE}/preload.lua
--lpath=${BUILD_DIR}/?.lua --lpath=${BUILD_DIR}/?.lua
--lpath=${WORKING_DIR}/runtime/lua/?.lua --lpath=${WORKING_DIR}/runtime/lua/?.lua
--lpath=?.lua --lpath=?.lua
${BUSTED_ARGS}
${TEST_PATH} ${TEST_PATH}
WORKING_DIRECTORY ${WORKING_DIR} WORKING_DIRECTORY ${WORKING_DIR}
ERROR_VARIABLE err ERROR_VARIABLE err
RESULT_VARIABLE res RESULT_VARIABLE res
${EXTRA_ARGS}) ${EXTRA_ARGS})
file(REMOVE ${WORKING_DIR}/Xtest_rplugin_manifest) file(GLOB RM_FILES ${BUILD_DIR}/Xtest_*)
file(REMOVE_RECURSE ${WORKING_DIR}/Xtest_xdg) file(REMOVE_RECURSE ${RM_FILES})
file(REMOVE_RECURSE ${WORKING_DIR}/Xtest-tmpdir)
if(NOT res EQUAL 0) if(NOT res EQUAL 0)
message(STATUS "Output to stderr:\n${err}") message(STATUS "Output to stderr:\n${err}")