RunTests.cmake 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # Set LC_ALL to meet expectations of some locale-sensitive tests.
  2. set(ENV{LC_ALL} "en_US.UTF-8")
  3. if(POLICY CMP0012)
  4. # Handle CI=true, without dev warnings.
  5. cmake_policy(SET CMP0012 NEW)
  6. endif()
  7. set(ENV{VIMRUNTIME} ${WORKING_DIR}/runtime)
  8. set(ENV{NVIM_RPLUGIN_MANIFEST} ${BUILD_DIR}/Xtest_rplugin_manifest)
  9. set(ENV{XDG_CONFIG_HOME} ${BUILD_DIR}/Xtest_xdg/config)
  10. set(ENV{XDG_DATA_HOME} ${BUILD_DIR}/Xtest_xdg/share)
  11. if(NOT DEFINED ENV{NVIM_LOG_FILE})
  12. set(ENV{NVIM_LOG_FILE} ${BUILD_DIR}/.nvimlog)
  13. endif()
  14. if(NVIM_PRG)
  15. set(ENV{NVIM_PRG} "${NVIM_PRG}")
  16. endif()
  17. if(DEFINED ENV{TEST_FILE})
  18. set(TEST_PATH "$ENV{TEST_FILE}")
  19. else()
  20. set(TEST_PATH "${TEST_DIR}/${TEST_TYPE}")
  21. endif()
  22. # Force $TEST_PATH to workdir-relative path ("test/…").
  23. if(IS_ABSOLUTE ${TEST_PATH})
  24. file(RELATIVE_PATH TEST_PATH "${WORKING_DIR}" "${TEST_PATH}")
  25. endif()
  26. if(BUSTED_OUTPUT_TYPE STREQUAL junit)
  27. set(EXTRA_ARGS OUTPUT_FILE ${BUILD_DIR}/${TEST_TYPE}test-junit.xml)
  28. endif()
  29. set(BUSTED_ARGS $ENV{BUSTED_ARGS})
  30. separate_arguments(BUSTED_ARGS)
  31. if(DEFINED ENV{TEST_TAG} AND NOT "$ENV{TEST_TAG}" STREQUAL "")
  32. list(APPEND BUSTED_ARGS --tags $ENV{TEST_TAG})
  33. endif()
  34. if(DEFINED ENV{TEST_FILTER} AND NOT "$ENV{TEST_FILTER}" STREQUAL "")
  35. list(APPEND BUSTED_ARGS --filter $ENV{TEST_FILTER})
  36. endif()
  37. # TMPDIR: use relative test path (for parallel test runs / isolation).
  38. set(ENV{TMPDIR} "${BUILD_DIR}/Xtest_tmpdir/${TEST_PATH}")
  39. execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory $ENV{TMPDIR})
  40. set(ENV{SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_NAME}) # used by test/helpers.lua.
  41. execute_process(
  42. COMMAND ${BUSTED_PRG} -v -o test.busted.outputHandlers.${BUSTED_OUTPUT_TYPE}
  43. --lazy --helper=${TEST_DIR}/${TEST_TYPE}/preload.lua
  44. --lpath=${BUILD_DIR}/?.lua
  45. --lpath=${WORKING_DIR}/runtime/lua/?.lua
  46. --lpath=?.lua
  47. ${BUSTED_ARGS}
  48. ${TEST_PATH}
  49. WORKING_DIRECTORY ${WORKING_DIR}
  50. ERROR_VARIABLE err
  51. RESULT_VARIABLE res
  52. ${EXTRA_ARGS})
  53. file(GLOB RM_FILES ${BUILD_DIR}/Xtest_*)
  54. file(REMOVE_RECURSE ${RM_FILES})
  55. if(NOT res EQUAL 0)
  56. message(STATUS "Tests exited non-zero: ${res}")
  57. if("${err}" STREQUAL "")
  58. message(STATUS "No output to stderr.")
  59. else()
  60. message(STATUS "Output to stderr:\n${err}")
  61. endif()
  62. # Dump the logfile on CI (if not displayed and moved already).
  63. if($ENV{CI})
  64. if(EXISTS $ENV{NVIM_LOG_FILE} AND NOT EXISTS $ENV{NVIM_LOG_FILE}.displayed)
  65. file(READ $ENV{NVIM_LOG_FILE} out)
  66. message(STATUS "$NVIM_LOG_FILE: $ENV{NVIM_LOG_FILE}\n${out}")
  67. endif()
  68. endif()
  69. message(FATAL_ERROR "${TEST_TYPE} tests failed with error: ${res}")
  70. endif()