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.
This commit is contained in:
Brad King 2015-09-17 10:55:56 -04:00
parent fa73ee025f
commit 6e3151f6cc
7 changed files with 50 additions and 0 deletions

View File

@ -85,3 +85,6 @@ The options are:
been printed to the console. Output from the underlying test command is not been printed to the console. Output from the underlying test command is not
affected. Summary info detailing the percentage of passing tests is also affected. Summary info detailing the percentage of passing tests is also
unaffected by the ``QUIET`` option. unaffected by the ``QUIET`` option.
See also the :variable:`CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE`
and :variable:`CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE` variables.

View File

@ -374,6 +374,8 @@ Variables for CTest
/variable/CTEST_COVERAGE_COMMAND /variable/CTEST_COVERAGE_COMMAND
/variable/CTEST_COVERAGE_EXTRA_FLAGS /variable/CTEST_COVERAGE_EXTRA_FLAGS
/variable/CTEST_CURL_OPTIONS /variable/CTEST_CURL_OPTIONS
/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE
/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE
/variable/CTEST_CVS_CHECKOUT /variable/CTEST_CVS_CHECKOUT
/variable/CTEST_CVS_COMMAND /variable/CTEST_CVS_COMMAND
/variable/CTEST_CVS_UPDATE_OPTIONS /variable/CTEST_CVS_UPDATE_OPTIONS

View File

@ -0,0 +1,6 @@
CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE
--------------------------------------------
Specify the maximum amount of output from a failed test that will
be collected by the :command:`ctest_test` command. If not set,
the default is 300 KiB.

View File

@ -0,0 +1,6 @@
CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE
--------------------------------------------
Specify the maximum amount of output from a passed test that will
be collected by the :command:`ctest_test` command. If not set,
the default is 1 KiB.

View File

@ -2,3 +2,4 @@ cmake_minimum_required(VERSION 3.1)
project(CTestTest@CASE_NAME@ NONE) project(CTestTest@CASE_NAME@ NONE)
include(CTest) include(CTest)
add_test(NAME RunCMakeVersion COMMAND "${CMAKE_COMMAND}" --version) add_test(NAME RunCMakeVersion COMMAND "${CMAKE_COMMAND}" --version)
@CASE_CMAKELISTS_SUFFIX_CODE@

View File

@ -59,3 +59,18 @@ function(run_TestChangeId)
run_ctest(TestChangeId) run_ctest(TestChangeId)
endfunction() endfunction()
run_TestChangeId() 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()

View File

@ -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()