Browse Source

ctest: Provide hints about inspecting test failures

Fixes: #20955
Asit Dhal 5 years ago
parent
commit
5a6c199069

+ 11 - 0
Source/cmCTest.cxx

@@ -1017,6 +1017,17 @@ int cmCTest::ProcessSteps()
   }
   if (res != 0) {
     cmCTestLog(this, ERROR_MESSAGE, "Errors while running CTest" << std::endl);
+    if (!this->Impl->OutputTestOutputOnTestFailure) {
+      const std::string lastTestLog =
+        this->GetBinaryDir() + "/Testing/Temporary/LastTest.log";
+      cmCTestLog(this, ERROR_MESSAGE,
+                 "Output from these tests are in: " << lastTestLog
+                                                    << std::endl);
+      cmCTestLog(this, ERROR_MESSAGE,
+                 "Use \"--rerun-failed --output-on-failure\" to re-run the "
+                 "failed cases verbosely."
+                   << std::endl);
+    }
   }
   return res;
 }

+ 3 - 1
Tests/RunCMake/CTestCommandLine/BadCTestTestfile-stderr.txt

@@ -1,4 +1,6 @@
 ^CMake Error at CTestTestfile.cmake:[0-9]+ \(subdirs\):
   subdirs called with incorrect number of arguments
 +
-Errors while running CTest$
+Errors while running CTest
+Output from these tests are in: .*/Testing/Temporary/LastTest.log
+Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.$

+ 3 - 1
Tests/RunCMake/CTestCommandLine/repeat-until-fail-ctest-stderr.txt

@@ -1 +1,3 @@
-^Errors while running CTest$
+^Errors while running CTest
+Output from these tests are in: .*/Testing/Temporary/LastTest.log
+Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.$