GoogleTest-discovery-flush-script-check-list.cmake.in 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. set(expected_number_of_tests 12)
  2. # Check the flushing of the test names buffer
  3. list(LENGTH flush_script_test_TESTS num_test_names)
  4. if(NOT num_test_names EQUAL expected_number_of_tests)
  5. message(FATAL_ERROR
  6. "Test name list has wrong number of test names:\n"
  7. " Expected: ${expected_number_of_tests}\n"
  8. " Actual: ${num_test_names}"
  9. )
  10. endif()
  11. # Check the flushing of the script content variable.
  12. # Note that flushing errors would repeat a test name, so such errors are not
  13. # uncovered by checking the name buffer flushing above.
  14. # PRE_TEST can have a config-specific tests file, POST_BUILD never does
  15. set(tests_file "@CMAKE_CURRENT_BINARY_DIR@/flush_script_test[1]_tests-Debug.cmake")
  16. if(NOT EXISTS "${tests_file}")
  17. set(tests_file "@CMAKE_CURRENT_BINARY_DIR@/flush_script_test[1]_tests.cmake")
  18. endif()
  19. if(NOT EXISTS "${tests_file}")
  20. message(FATAL_ERROR "Tests file is missing")
  21. endif()
  22. file(STRINGS "${tests_file}" add_test_lines REGEX "^add_test" ENCODING UTF-8)
  23. list(LENGTH add_test_lines num_add_test_lines)
  24. if(NOT num_add_test_lines EQUAL expected_number_of_tests)
  25. message(FATAL_ERROR
  26. "Test script has wrong number of add_test() calls:\n"
  27. " Expected: ${expected_number_of_tests}\n"
  28. " Actual: ${num_add_test_lines}"
  29. )
  30. endif()