RunTests.cmake 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. if(NOT DEFINED ENV{TEST_TIMEOUT} OR "$ENV{TEST_TIMEOUT}" STREQUAL "")
  41. set(ENV{TEST_TIMEOUT} 1200)
  42. endif()
  43. set(ENV{SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_NAME}) # used by test/helpers.lua.
  44. execute_process(
  45. COMMAND ${BUSTED_PRG} -v -o test.busted.outputHandlers.${BUSTED_OUTPUT_TYPE}
  46. --lazy --helper=${TEST_DIR}/${TEST_TYPE}/preload.lua
  47. --lpath=${BUILD_DIR}/?.lua
  48. --lpath=${WORKING_DIR}/runtime/lua/?.lua
  49. --lpath=?.lua
  50. ${BUSTED_ARGS}
  51. ${TEST_PATH}
  52. TIMEOUT $ENV{TEST_TIMEOUT}
  53. WORKING_DIRECTORY ${WORKING_DIR}
  54. ERROR_VARIABLE err
  55. RESULT_VARIABLE res
  56. ${EXTRA_ARGS})
  57. file(GLOB RM_FILES ${BUILD_DIR}/Xtest_*)
  58. file(REMOVE_RECURSE ${RM_FILES})
  59. if(NOT res EQUAL 0)
  60. message(STATUS "Tests exited non-zero: ${res}")
  61. if("${err}" STREQUAL "")
  62. message(STATUS "No output to stderr.")
  63. else()
  64. message(STATUS "Output to stderr:\n${err}")
  65. endif()
  66. # Dump the logfile on CI (if not displayed and moved already).
  67. if($ENV{CI})
  68. if(EXISTS $ENV{NVIM_LOG_FILE} AND NOT EXISTS $ENV{NVIM_LOG_FILE}.displayed)
  69. file(READ $ENV{NVIM_LOG_FILE} out)
  70. message(STATUS "$NVIM_LOG_FILE: $ENV{NVIM_LOG_FILE}\n${out}")
  71. endif()
  72. endif()
  73. message(FATAL_ERROR "${TEST_TYPE} tests failed with error: ${res}")
  74. endif()