Browse Source

Merge topic 'truncation_invalid'

bd30d20bc3 Tests: Add cases covering bad ctest output truncation types
dbf840392d ctest: print error for invalid CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION

Acked-by: Kitware Robot <[email protected]>
Acked-by: buildbot <[email protected]>
Merge-request: !7596
Brad King 3 years ago
parent
commit
29c0633793

+ 5 - 1
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);
+    }
   }
 }
 

+ 1 - 0
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)

+ 1 - 0
Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-result.txt

@@ -0,0 +1 @@
+1

+ 1 - 0
Tests/RunCMake/CTestCommandLine/TestOutputTruncation_bad-stderr.txt

@@ -0,0 +1 @@
+^CMake Error: Invalid value for '--test-output-truncation': bad$

+ 1 - 0
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)

+ 4 - 0
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()

+ 1 - 0
Tests/RunCMake/ctest_test/TestOutputTruncation_bad-result.txt

@@ -0,0 +1 @@
+[^0]

+ 1 - 0
Tests/RunCMake/ctest_test/TestOutputTruncation_bad-stderr.txt

@@ -0,0 +1 @@
+^Invalid value for CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION: bad$