RunCMakeTest: fix Truncation test definition

The `ctest_test` and `CTestCommandLine` truncation tests had multiple problems:
- escape expected result string to avoid regex matching
- specify the truncation size
- pass the truncation mode correctly into the test definition
- use unique test names

Issue: #23868
This commit is contained in:
Frank Winklmeier
2022-09-05 13:42:40 +02:00
parent 0e7bb4e783
commit cb55d5e730
11 changed files with 18 additions and 11 deletions

View File

@@ -284,7 +284,7 @@ function(run_TestOutputTruncation mode expected)
file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
add_test(Truncation_${mode} \"${CMAKE_COMMAND}\" -E echo 123456789)
")
run_cmake_command(TestOutputTruncation
run_cmake_command(TestOutputTruncation_${mode}
${CMAKE_CTEST_COMMAND} -M Experimental -T Test
--no-compress-output
--test-output-size-passed 5

View File

@@ -0,0 +1 @@
include(${RunCMake_SOURCE_DIR}/TestOutputTruncation-check.cmake)

View File

@@ -0,0 +1 @@
include(${RunCMake_SOURCE_DIR}/TestOutputTruncation-check.cmake)

View File

@@ -0,0 +1 @@
^Cannot find file: .*/Tests/RunCMake/CTestCommandLine/TestOutputTruncation.*/DartConfiguration.tcl

View File

@@ -0,0 +1 @@
include(${RunCMake_SOURCE_DIR}/TestOutputTruncation-check.cmake)

View File

@@ -0,0 +1 @@
^Cannot find file: .*/Tests/RunCMake/CTestCommandLine/TestOutputTruncation.*/DartConfiguration.tcl

View File

@@ -84,18 +84,17 @@ run_TestOutputSize()
function(run_TestOutputTruncation mode expected)
set(CASE_CTEST_TEST_ARGS EXCLUDE RunCMakeVersion)
set(TRUNCATED_OUTPUT ${expected}) # used in TestOutputTruncation-check.cmake
set(CASE_TEST_PREFIX_CODE [[
set( CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION${mode})
]])
set(CASE_CMAKELISTS_SUFFIX_CODE [[
add_test(NAME Truncation_${mode} COMMAND ${CMAKE_COMMAND} -E echo 123456789)
]])
string(CONCAT CASE_TEST_PREFIX_CODE "
set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 5)
set(CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION ${mode})" )
set(CASE_CMAKELISTS_SUFFIX_CODE "
add_test(NAME Truncation_${mode} COMMAND \${CMAKE_COMMAND} -E echo 123456789)")
run_ctest(TestOutputTruncation)
run_ctest(TestOutputTruncation_${mode})
endfunction()
run_TestOutputTruncation("head" "...6789")
run_TestOutputTruncation("middle" "12....*...89")
run_TestOutputTruncation("tail" "12345...")
run_TestOutputTruncation("head" "\\.\\.\\.6789")
run_TestOutputTruncation("middle" "12\\.\\.\\..*\\.\\.\\.89")
run_TestOutputTruncation("tail" "12345\\.\\.\\.")
run_ctest_test(TestRepeatBad1 REPEAT UNKNOWN:3)
run_ctest_test(TestRepeatBad2 REPEAT UNTIL_FAIL:-1)

View File

@@ -0,0 +1 @@
include(${RunCMake_SOURCE_DIR}/TestOutputTruncation-check.cmake)

View File

@@ -0,0 +1 @@
include(${RunCMake_SOURCE_DIR}/TestOutputTruncation-check.cmake)

View File

@@ -0,0 +1 @@
include(${RunCMake_SOURCE_DIR}/TestOutputTruncation-check.cmake)