From dbf840392d1d6f212d0dc1756644edfccba2a244 Mon Sep 17 00:00:00 2001 From: Frank Winklmeier Date: Fri, 19 Aug 2022 11:31:09 +0200 Subject: ctest: print error for invalid CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION Print an error message for invalid values of `CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION` in a ctest dashboard script. The option was added by commit 140704d443 (ctest: add option for output truncation, 2022-03-07, v3.24.0-rc1~513^2). Fixes: #23869 --- Source/CTest/cmCTestTestHandler.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index d1fad62..daaf5fd 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -363,7 +363,11 @@ void cmCTestTestHandler::PopulateCustomVectors(cmMakefile* mf) cmValue dval = mf->GetDefinition("CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION"); if (dval) { - this->SetTestOutputTruncation(dval); + if (!this->SetTestOutputTruncation(dval)) { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Invalid value for CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION: " + << dval << std::endl); + } } } -- cgit v0.12 From bd30d20bc328af37449b11c3b2b38f79a5be8db9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 7 Sep 2022 12:21:26 -0400 Subject: Tests: Add cases covering bad ctest output truncation types Issue: #23869 --- Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake | 1 + Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-result.txt | 1 + Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-stderr.txt | 1 + Tests/RunCMake/ctest_test/RunCMakeTest.cmake | 1 + Tests/RunCMake/ctest_test/TestOutputTruncation_bad-check.cmake | 4 ++++ Tests/RunCMake/ctest_test/TestOutputTruncation_bad-result.txt | 1 + Tests/RunCMake/ctest_test/TestOutputTruncation_bad-stderr.txt | 1 + 7 files changed, 10 insertions(+) create mode 100644 Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-result.txt create mode 100644 Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-stderr.txt create mode 100644 Tests/RunCMake/ctest_test/TestOutputTruncation_bad-check.cmake create mode 100644 Tests/RunCMake/ctest_test/TestOutputTruncation_bad-result.txt create mode 100644 Tests/RunCMake/ctest_test/TestOutputTruncation_bad-stderr.txt diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 2ac1f36..df3e82a 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -294,6 +294,7 @@ endfunction() run_TestOutputTruncation("head" "\\.\\.\\.6789") run_TestOutputTruncation("middle" "12\\.\\.\\..*\\.\\.\\.89") run_TestOutputTruncation("tail" "12345\\.\\.\\.") +run_TestOutputTruncation("bad" "") # Test --stop-on-failure function(run_stop_on_failure) diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-result.txt b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-stderr.txt b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-stderr.txt new file mode 100644 index 0000000..6afc02b --- /dev/null +++ b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Invalid value for '--test-output-truncation': bad$ diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index 1aa6359..74ae99c 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -95,6 +95,7 @@ endfunction() run_TestOutputTruncation("head" "\\.\\.\\.6789") run_TestOutputTruncation("middle" "12\\.\\.\\..*\\.\\.\\.89") run_TestOutputTruncation("tail" "12345\\.\\.\\.") +run_TestOutputTruncation("bad" "") run_ctest_test(TestRepeatBad1 REPEAT UNKNOWN:3) run_ctest_test(TestRepeatBad2 REPEAT UNTIL_FAIL:-1) diff --git a/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-check.cmake b/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-check.cmake new file mode 100644 index 0000000..4315074f --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-check.cmake @@ -0,0 +1,4 @@ +file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml") +if(test_xml_file) + set(RunCMake_TEST_FAILED "Test.xml should not exist:\n ${test_xml_file}") +endif() diff --git a/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-result.txt b/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-stderr.txt b/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-stderr.txt new file mode 100644 index 0000000..ef4d11b --- /dev/null +++ b/Tests/RunCMake/ctest_test/TestOutputTruncation_bad-stderr.txt @@ -0,0 +1 @@ +^Invalid value for CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION: bad$ -- cgit v0.12