RunTests.cmake 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. # Avoid policy warning due to CI=true. This is needed even if the main
  5. # project has already set this policy as policy settings are reset when using
  6. # the cmake script mode (-P).
  7. cmake_policy(SET CMP0012 NEW)
  8. endif()
  9. set(ENV{VIMRUNTIME} ${WORKING_DIR}/runtime)
  10. set(ENV{NVIM_RPLUGIN_MANIFEST} ${BUILD_DIR}/Xtest_rplugin_manifest)
  11. set(ENV{XDG_CONFIG_HOME} ${BUILD_DIR}/Xtest_xdg/config)
  12. set(ENV{XDG_DATA_HOME} ${BUILD_DIR}/Xtest_xdg/share)
  13. unset(ENV{XDG_DATA_DIRS})
  14. unset(ENV{NVIM}) # Clear $NVIM in case tests are running from Nvim. #11009
  15. if(NOT DEFINED ENV{NVIM_LOG_FILE})
  16. set(ENV{NVIM_LOG_FILE} ${BUILD_DIR}/.nvimlog)
  17. endif()
  18. if(NVIM_PRG)
  19. set(ENV{NVIM_PRG} "${NVIM_PRG}")
  20. endif()
  21. if(DEFINED ENV{TEST_FILE})
  22. set(TEST_PATH "$ENV{TEST_FILE}")
  23. else()
  24. set(TEST_PATH "${TEST_DIR}/${TEST_TYPE}")
  25. endif()
  26. # Force $TEST_PATH to workdir-relative path ("test/…").
  27. if(IS_ABSOLUTE ${TEST_PATH})
  28. file(RELATIVE_PATH TEST_PATH "${WORKING_DIR}" "${TEST_PATH}")
  29. endif()
  30. if(BUSTED_OUTPUT_TYPE STREQUAL junit)
  31. set(EXTRA_ARGS OUTPUT_FILE ${BUILD_DIR}/${TEST_TYPE}test-junit.xml)
  32. endif()
  33. set(BUSTED_ARGS $ENV{BUSTED_ARGS})
  34. separate_arguments(BUSTED_ARGS)
  35. if(DEFINED ENV{TEST_TAG} AND NOT "$ENV{TEST_TAG}" STREQUAL "")
  36. list(APPEND BUSTED_ARGS --tags $ENV{TEST_TAG})
  37. endif()
  38. if(DEFINED ENV{TEST_FILTER} AND NOT "$ENV{TEST_FILTER}" STREQUAL "")
  39. list(APPEND BUSTED_ARGS --filter $ENV{TEST_FILTER})
  40. endif()
  41. if(DEFINED ENV{TEST_FILTER_OUT} AND NOT "$ENV{TEST_FILTER_OUT}" STREQUAL "")
  42. list(APPEND BUSTED_ARGS --filter-out $ENV{TEST_FILTER_OUT})
  43. endif()
  44. # TMPDIR: for helpers.tmpname() and Nvim tempname().
  45. set(ENV{TMPDIR} "${BUILD_DIR}/Xtest_tmpdir")
  46. execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory $ENV{TMPDIR})
  47. # HISTFILE: do not write into user's ~/.bash_history
  48. set(ENV{HISTFILE} "/dev/null")
  49. if(NOT DEFINED ENV{TEST_TIMEOUT} OR "$ENV{TEST_TIMEOUT}" STREQUAL "")
  50. set(ENV{TEST_TIMEOUT} 1200)
  51. endif()
  52. set(ENV{SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_NAME}) # used by test/helpers.lua.
  53. execute_process(
  54. COMMAND ${BUSTED_PRG} -v -o test.busted.outputHandlers.${BUSTED_OUTPUT_TYPE}
  55. --lazy --helper=${TEST_DIR}/${TEST_TYPE}/preload.lua
  56. --lpath=${BUILD_DIR}/?.lua
  57. --lpath=${WORKING_DIR}/runtime/lua/?.lua
  58. --lpath=?.lua
  59. ${BUSTED_ARGS}
  60. ${TEST_PATH}
  61. TIMEOUT $ENV{TEST_TIMEOUT}
  62. WORKING_DIRECTORY ${WORKING_DIR}
  63. ERROR_VARIABLE err
  64. RESULT_VARIABLE res
  65. ${EXTRA_ARGS})
  66. file(GLOB RM_FILES ${BUILD_DIR}/Xtest_*)
  67. file(REMOVE_RECURSE ${RM_FILES})
  68. if(NOT res EQUAL 0)
  69. message(STATUS "Tests exited non-zero: ${res}")
  70. if("${err}" STREQUAL "")
  71. message(STATUS "No output to stderr.")
  72. else()
  73. message(STATUS "Output to stderr:\n${err}")
  74. endif()
  75. # Dump the logfile on CI (if not displayed and moved already).
  76. if($ENV{CI})
  77. if(EXISTS $ENV{NVIM_LOG_FILE} AND NOT EXISTS $ENV{NVIM_LOG_FILE}.displayed)
  78. file(READ $ENV{NVIM_LOG_FILE} out)
  79. message(STATUS "$NVIM_LOG_FILE: $ENV{NVIM_LOG_FILE}\n${out}")
  80. endif()
  81. endif()
  82. message(FATAL_ERROR "${TEST_TYPE} tests failed with error: ${res}")
  83. endif()