diff options
Diffstat (limited to 'Tests')
6 files changed, 65 insertions, 1 deletions
diff --git a/Tests/RunCMake/CMakePresetsTest/Good.json.in b/Tests/RunCMake/CMakePresetsTest/Good.json.in index ea20d9d..d484a19 100644 --- a/Tests/RunCMake/CMakePresetsTest/Good.json.in +++ b/Tests/RunCMake/CMakePresetsTest/Good.json.in @@ -48,7 +48,8 @@ "quiet": false, "outputLogFile": "", "labelSummary": true, - "subprojectSummary": true + "subprojectSummary": true, + "testOutputTruncation": "tail" }, "filter": { "include": { diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 7da95a2..5b198bd 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -274,6 +274,27 @@ function(run_TestOutputSize) endfunction() run_TestOutputSize() +# Test --test-output-truncation +function(run_TestOutputTruncation mode expected) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestOutputTruncation_${mode}) + set(RunCMake_TEST_NO_CLEAN 1) + set(TRUNCATED_OUTPUT ${expected}) # used in TestOutputTruncation-check.cmake + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" " + add_test(Truncation_${mode} \"${CMAKE_COMMAND}\" -E echo 123456789) +") + run_cmake_command(TestOutputTruncation + ${CMAKE_CTEST_COMMAND} -M Experimental -T Test + --no-compress-output + --test-output-size-passed 5 + --test-output-truncation ${mode} + ) +endfunction() +run_TestOutputTruncation("head" "\\.\\.\\.6789") +run_TestOutputTruncation("middle" "12\\.\\.\\..*\\.\\.\\.89") +run_TestOutputTruncation("tail" "12345\.\.\.") + # Test --stop-on-failure function(run_stop_on_failure) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/stop-on-failure) diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-check.cmake b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-check.cmake new file mode 100644 index 0000000..5769c9f --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-check.cmake @@ -0,0 +1,12 @@ +file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml") +if(test_xml_file) + file(READ "${test_xml_file}" test_xml LIMIT 4096) + if("${test_xml}" MATCHES [[(<Test Status="passed">.*</Test>)]]) + set(test_result "${CMAKE_MATCH_1}") + endif() + if(NOT "${test_result}" MATCHES "<Value>.*${TRUNCATED_OUTPUT}.*</Value>") + set(RunCMake_TEST_FAILED "Test output truncation failed:\n ${test_result}\nExpected: ${TRUNCATED_OUTPUT}") + endif() +else() + set(RunCMake_TEST_FAILED "Test.xml not found") +endif() diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-stderr.txt b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-stderr.txt new file mode 100644 index 0000000..30b46ce --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-stderr.txt @@ -0,0 +1 @@ +^Cannot find file: .*/Tests/RunCMake/CTestCommandLine/TestOutputTruncation.*/DartConfiguration.tcl diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index de81049..b41c271 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -80,6 +80,23 @@ add_test(NAME FailingTest COMMAND ${CMAKE_COMMAND} -E no_such_command) endfunction() run_TestOutputSize() +# Test --test-output-truncation +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) + ]]) + + run_ctest(TestOutputTruncation) +endfunction() +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) diff --git a/Tests/RunCMake/ctest_test/TestOutputTruncation-check.cmake b/Tests/RunCMake/ctest_test/TestOutputTruncation-check.cmake new file mode 100644 index 0000000..5769c9f --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestOutputTruncation-check.cmake @@ -0,0 +1,12 @@ +file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml") +if(test_xml_file) + file(READ "${test_xml_file}" test_xml LIMIT 4096) + if("${test_xml}" MATCHES [[(<Test Status="passed">.*</Test>)]]) + set(test_result "${CMAKE_MATCH_1}") + endif() + if(NOT "${test_result}" MATCHES "<Value>.*${TRUNCATED_OUTPUT}.*</Value>") + set(RunCMake_TEST_FAILED "Test output truncation failed:\n ${test_result}\nExpected: ${TRUNCATED_OUTPUT}") + endif() +else() + set(RunCMake_TEST_FAILED "Test.xml not found") +endif() |