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