diff options
Diffstat (limited to 'Tests')
4 files changed, 36 insertions, 0 deletions
diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index dfc1e33..00895cc 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 0000000..918d242 --- /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 0000000..9c558e3 --- /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 0000000..ba4235d --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/TestOutputSize-stderr.txt @@ -0,0 +1 @@ +Errors while running CTest |