RunCMakeTest.cmake 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. include(RunCMake)
  2. function(run_GoogleTest)
  3. # Use a single build tree for a few tests without cleaning.
  4. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-build)
  5. set(RunCMake_TEST_NO_CLEAN 1)
  6. if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
  7. set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
  8. endif()
  9. file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  10. file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
  11. run_cmake(GoogleTest)
  12. run_cmake_command(GoogleTest-build
  13. ${CMAKE_COMMAND}
  14. --build .
  15. --config Debug
  16. --target fake_gtest
  17. )
  18. run_cmake_command(GoogleTest-property-timeout-exe
  19. ${CMAKE_COMMAND}
  20. --build .
  21. --config Debug
  22. --target property_timeout_test
  23. )
  24. set(RunCMake_TEST_OUTPUT_MERGE 1)
  25. run_cmake_command(GoogleTest-discovery-timeout-build
  26. ${CMAKE_COMMAND}
  27. --build .
  28. --config Debug
  29. --target discovery_timeout_test
  30. )
  31. set(RunCMake_TEST_OUTPUT_MERGE 0)
  32. run_cmake_command(GoogleTest-test1
  33. ${CMAKE_CTEST_COMMAND}
  34. -C Debug
  35. -L TEST1
  36. --no-label-summary
  37. )
  38. run_cmake_command(GoogleTest-test2
  39. ${CMAKE_CTEST_COMMAND}
  40. -C Debug
  41. -L TEST2
  42. --no-label-summary
  43. )
  44. run_cmake_command(GoogleTest-test-missing
  45. ${CMAKE_CTEST_COMMAND}
  46. -C Debug
  47. -R no_tests_defined
  48. --no-label-summary
  49. )
  50. run_cmake_command(GoogleTest-property-timeout1
  51. ${CMAKE_CTEST_COMMAND}
  52. -C Debug
  53. -R property_timeout\\.case_no_discovery
  54. --no-label-summary
  55. )
  56. run_cmake_command(GoogleTest-property-timeout2
  57. ${CMAKE_CTEST_COMMAND}
  58. -C Debug
  59. -R property_timeout\\.case_with_discovery
  60. --no-label-summary
  61. )
  62. run_cmake_command(GoogleTest-discovery-timeout-test
  63. ${CMAKE_CTEST_COMMAND}
  64. -C Debug
  65. -R discovery_timeout_test
  66. --no-label-summary
  67. )
  68. endfunction()
  69. function(run_GoogleTestXML)
  70. # Use a single build tree for a few tests without cleaning.
  71. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTestXML-build)
  72. set(RunCMake_TEST_NO_CLEAN 1)
  73. if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
  74. set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
  75. endif()
  76. file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  77. file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
  78. run_cmake(GoogleTestXML)
  79. run_cmake_command(GoogleTestXML-discovery
  80. ${CMAKE_COMMAND}
  81. --build .
  82. --config Debug
  83. --target xml_output
  84. )
  85. run_cmake_command(GoogleTestXML-result
  86. ${CMAKE_CTEST_COMMAND}
  87. -C Debug
  88. -R GoogleTestXML
  89. --no-label-summary
  90. )
  91. endfunction()
  92. run_GoogleTest()
  93. run_GoogleTestXML()