summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CTestCommandLine
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-03-09 17:17:33 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-03-09 17:17:44 (GMT)
commitcbd36eac23628f74ae3b50f9d1b8a0478c3e317a (patch)
tree2a1a3b85f60dabb52eb3e7f2c5348a557c17b777 /Tests/RunCMake/CTestCommandLine
parent51e81d1f7354fc425b3fc210900cab37ca00926f (diff)
parent140704d443e73c2dc74ac8192a109ae0c21e834a (diff)
downloadCMake-cbd36eac23628f74ae3b50f9d1b8a0478c3e317a.zip
CMake-cbd36eac23628f74ae3b50f9d1b8a0478c3e317a.tar.gz
CMake-cbd36eac23628f74ae3b50f9d1b8a0478c3e317a.tar.bz2
Merge topic 'ctest_truncate'
140704d443 ctest: add option for output truncation 359e5b17d8 presets: bump version to v5 4634de335b cmCTestTestHandler: refactor CleanTestOutput method Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6993
Diffstat (limited to 'Tests/RunCMake/CTestCommandLine')
-rw-r--r--Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake21
-rw-r--r--Tests/RunCMake/CTestCommandLine/TestOutputTruncation-check.cmake12
-rw-r--r--Tests/RunCMake/CTestCommandLine/TestOutputTruncation-stderr.txt1
3 files changed, 34 insertions, 0 deletions
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