summaryrefslogtreecommitdiff
path: root/Tests/RunCMake/CTestCommandLine
diff options
context:
space:
mode:
authorRoman Wüger <roman.wueger@gmx.at>2015-09-17 11:06:27 -0400
committerBrad King <brad.king@kitware.com>2015-09-18 11:32:06 -0400
commitfd47df45030733341858fa33ee96015d64c73c03 (patch)
treed763169672205165693ac1afb9ff3af525bd2681 /Tests/RunCMake/CTestCommandLine
parent6e3151f6ccd035ffd704d3cb0162c873d5e95e15 (diff)
downloadcmake-fd47df45030733341858fa33ee96015d64c73c03.tar.gz
CTest: Add options to limit output of passed and failed tests
Add ctest command-line options: --test-output-size-passed <n> --test-output-size-failed <n> to set the amount of test output to store in Test.xml as a command-line dashboard client.
Diffstat (limited to 'Tests/RunCMake/CTestCommandLine')
-rw-r--r--Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake17
-rw-r--r--Tests/RunCMake/CTestCommandLine/TestOutputSize-check.cmake17
-rw-r--r--Tests/RunCMake/CTestCommandLine/TestOutputSize-result.txt1
-rw-r--r--Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt1
4 files changed, 36 insertions, 0 deletions
diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
index dfc1e33353..00895cc488 100644
--- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
@@ -108,3 +108,20 @@ run_TestLoad(test-load-invalid 'two')
run_TestLoad(test-load-pass 10)
unset(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING})
+
+function(run_TestOutputSize)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestOutputSize)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
+ add_test(PassingTest \"${CMAKE_COMMAND}\" -E echo PassingTestOutput)
+ add_test(FailingTest \"${CMAKE_COMMAND}\" -E no_such_command)
+")
+ run_cmake_command(TestOutputSize
+ ${CMAKE_CTEST_COMMAND} -M Experimental -T Test
+ --test-output-size-passed 10
+ --test-output-size-failed 12
+ )
+endfunction()
+run_TestOutputSize()
diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputSize-check.cmake b/Tests/RunCMake/CTestCommandLine/TestOutputSize-check.cmake
new file mode 100644
index 0000000000..918d242aa6
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestOutputSize-check.cmake
@@ -0,0 +1,17 @@
+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>).*(<Test Status="failed">.*</Test>)]])
+ set(test_passed "${CMAKE_MATCH_1}")
+ set(test_failed "${CMAKE_MATCH_2}")
+ else()
+ set(RunCMake_TEST_FAILED "Test.xml does not contain a passed then failed test:\n ${test_xml}")
+ endif()
+ if(NOT "${test_passed}" MATCHES [[<Value>PassingTes\.\.\..*10 bytes]])
+ set(RunCMake_TEST_FAILED "Test.xml passed test output not truncated at 10 bytes:\n ${test_passed}")
+ elseif(NOT "${test_failed}" MATCHES [[<Value>CMake Error:\.\.\..*12 bytes]])
+ set(RunCMake_TEST_FAILED "Test.xml failed test output not truncated at 12 bytes:\n ${test_failed}")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "Test.xml not found")
+endif()
diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputSize-result.txt b/Tests/RunCMake/CTestCommandLine/TestOutputSize-result.txt
new file mode 100644
index 0000000000..9c558e357c
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestOutputSize-result.txt
@@ -0,0 +1 @@
+.
diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt b/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt
new file mode 100644
index 0000000000..ba4235defb
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt
@@ -0,0 +1 @@
+Errors while running CTest