RunTests.cmake 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # Set LC_ALL to meet expectations of some locale-sensitive tests.
  2. set(ENV{LC_ALL} "en_US.UTF-8")
  3. set(ENV{VIMRUNTIME} ${WORKING_DIR}/runtime)
  4. set(ENV{NVIM_RPLUGIN_MANIFEST} ${BUILD_DIR}/Xtest_rplugin_manifest)
  5. set(ENV{XDG_CONFIG_HOME} ${BUILD_DIR}/Xtest_xdg/config)
  6. set(ENV{XDG_DATA_HOME} ${BUILD_DIR}/Xtest_xdg/share)
  7. set(ENV{XDG_STATE_HOME} ${BUILD_DIR}/Xtest_xdg/state)
  8. unset(ENV{XDG_DATA_DIRS})
  9. unset(ENV{NVIM}) # Clear $NVIM in case tests are running from Nvim. #11009
  10. # TODO(dundargoc): The CIRRUS_CI environment variable isn't passed to here from
  11. # the main CMakeLists.txt, so we have to manually pass it to this script and
  12. # re-set the environment variable. Investigate if we can avoid manually setting
  13. # it like with the GITHUB_CI environment variable.
  14. set(ENV{CIRRUS_CI} ${CIRRUS_CI})
  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. separate_arguments(BUSTED_ARGS NATIVE_COMMAND $ENV{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. if(DEFINED ENV{TEST_FILTER_OUT} AND NOT "$ENV{TEST_FILTER_OUT}" STREQUAL "")
  38. list(APPEND BUSTED_ARGS --filter-out $ENV{TEST_FILTER_OUT})
  39. endif()
  40. # TMPDIR: for testutil.tmpname() and Nvim tempname().
  41. set(ENV{TMPDIR} "${BUILD_DIR}/Xtest_tmpdir")
  42. execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory $ENV{TMPDIR})
  43. # HISTFILE: do not write into user's ~/.bash_history
  44. set(ENV{HISTFILE} "/dev/null")
  45. if(NOT DEFINED ENV{TEST_TIMEOUT} OR "$ENV{TEST_TIMEOUT}" STREQUAL "")
  46. set(ENV{TEST_TIMEOUT} 1200)
  47. endif()
  48. set(ENV{SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_NAME}) # used by test/testutil.lua.
  49. if(NOT WIN32)
  50. # Tests assume POSIX "sh" and may fail if SHELL=fish. #24941 #6172
  51. set(ENV{SHELL} sh)
  52. endif()
  53. execute_process(
  54. # Note: because of "-ll" (low-level interpreter mode), some modules like
  55. # _editor.lua are not loaded.
  56. COMMAND ${NVIM_PRG} -ll ${WORKING_DIR}/test/lua_runner.lua ${DEPS_INSTALL_DIR} busted -v -o test.busted.outputHandlers.nvim
  57. --lazy --helper=${TEST_DIR}/${TEST_TYPE}/preload.lua
  58. --lpath=${BUILD_DIR}/?.lua
  59. --lpath=${WORKING_DIR}/runtime/lua/?.lua
  60. --lpath=?.lua
  61. ${BUSTED_ARGS}
  62. ${TEST_PATH}
  63. TIMEOUT $ENV{TEST_TIMEOUT}
  64. WORKING_DIRECTORY ${WORKING_DIR}
  65. ERROR_VARIABLE err
  66. RESULT_VARIABLE res
  67. ${EXTRA_ARGS})
  68. file(GLOB RM_FILES ${BUILD_DIR}/Xtest_*)
  69. file(REMOVE_RECURSE ${RM_FILES})
  70. if(res)
  71. message(STATUS "Tests exited non-zero: ${res}")
  72. if("${err}" STREQUAL "")
  73. message(STATUS "No output to stderr.")
  74. else()
  75. message(STATUS "Output to stderr:\n${err}")
  76. endif()
  77. # Dump the logfile on CI (if not displayed and moved already).
  78. if(CI_BUILD)
  79. if(EXISTS $ENV{NVIM_LOG_FILE} AND NOT EXISTS $ENV{NVIM_LOG_FILE}.displayed)
  80. file(READ $ENV{NVIM_LOG_FILE} out)
  81. message(STATUS "$NVIM_LOG_FILE: $ENV{NVIM_LOG_FILE}\n${out}")
  82. endif()
  83. endif()
  84. message(FATAL_ERROR "${TEST_TYPE} tests failed with error: ${res}")
  85. endif()