diff options
author | Brad King <brad.king@kitware.com> | 2015-09-17 14:55:56 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-09-18 15:32:05 (GMT) |
commit | 6e3151f6ccd035ffd704d3cb0162c873d5e95e15 (patch) | |
tree | fb9af5b6228bc9e382f9e9db5cfdf4692c966a54 /Tests/RunCMake/ctest_test | |
parent | fa73ee025fb979fe8668483ca04f8be8f69b2f5b (diff) | |
download | CMake-6e3151f6ccd035ffd704d3cb0162c873d5e95e15.zip CMake-6e3151f6ccd035ffd704d3cb0162c873d5e95e15.tar.gz CMake-6e3151f6ccd035ffd704d3cb0162c873d5e95e15.tar.bz2 |
CTest: Document and test custom output size settings
Add documentation and tests for the existing
CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE
CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE
CTest variables.
Diffstat (limited to 'Tests/RunCMake/ctest_test')
-rw-r--r-- | Tests/RunCMake/ctest_test/CMakeLists.txt.in | 1 | ||||
-rw-r--r-- | Tests/RunCMake/ctest_test/RunCMakeTest.cmake | 15 | ||||
-rw-r--r-- | Tests/RunCMake/ctest_test/TestOutputSize-check.cmake | 17 |
3 files changed, 33 insertions, 0 deletions
diff --git a/Tests/RunCMake/ctest_test/CMakeLists.txt.in b/Tests/RunCMake/ctest_test/CMakeLists.txt.in index cedf379..e61b556 100644 --- a/Tests/RunCMake/ctest_test/CMakeLists.txt.in +++ b/Tests/RunCMake/ctest_test/CMakeLists.txt.in @@ -2,3 +2,4 @@ cmake_minimum_required(VERSION 3.1) project(CTestTest@CASE_NAME@ NONE) include(CTest) add_test(NAME RunCMakeVersion COMMAND "${CMAKE_COMMAND}" --version) +@CASE_CMAKELISTS_SUFFIX_CODE@ diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index 76dc143..e2f380c 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -59,3 +59,18 @@ function(run_TestChangeId) run_ctest(TestChangeId) endfunction() run_TestChangeId() + +function(run_TestOutputSize) + set(CASE_CTEST_TEST_ARGS EXCLUDE RunCMakeVersion) + set(CASE_TEST_PREFIX_CODE [[ +set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 10) +set(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 12) + ]]) + set(CASE_CMAKELISTS_SUFFIX_CODE [[ +add_test(NAME PassingTest COMMAND ${CMAKE_COMMAND} -E echo PassingTestOutput) +add_test(NAME FailingTest COMMAND ${CMAKE_COMMAND} -E no_such_command) + ]]) + + run_ctest(TestOutputSize) +endfunction() +run_TestOutputSize() diff --git a/Tests/RunCMake/ctest_test/TestOutputSize-check.cmake b/Tests/RunCMake/ctest_test/TestOutputSize-check.cmake new file mode 100644 index 0000000..918d242 --- /dev/null +++ b/Tests/RunCMake/ctest_test/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() |