summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoseph Snyder <joe.snyder@kitware.com>2021-05-19 15:46:21 (GMT)
committerBrad King <brad.king@kitware.com>2021-06-02 12:41:09 (GMT)
commit5d5610b04f51c780d4e5b7f2fd24268f773bea3d (patch)
tree491f80813a393c8a5b629b0ab4ddd3ead7961be6
parentcf470d8dac5abe956b7a0ec62afe2d93fb533336 (diff)
downloadCMake-5d5610b04f51c780d4e5b7f2fd24268f773bea3d.zip
CMake-5d5610b04f51c780d4e5b7f2fd24268f773bea3d.tar.gz
CMake-5d5610b04f51c780d4e5b7f2fd24268f773bea3d.tar.bz2
CTest: Exit coverage handling early if no binary dir
Check for the existence of the Binary directory string before checking for coverage files. If the directory is not specified, write an error message and do not do any checking. Fixes: #22102
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx7
-rw-r--r--Tests/RunCMake/CTestCommandLine/EmptyDirCoverage-ctest-stderr.txt3
-rw-r--r--Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake4
3 files changed, 14 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 3d7d031..57b1dda 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -289,6 +289,13 @@ int cmCTestCoverageHandler::ProcessHandler()
this->CTest->GetCTestConfiguration("SourceDirectory");
std::string binaryDir = this->CTest->GetCTestConfiguration("BuildDirectory");
+ if (binaryDir.empty()) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Binary directory is not set. "
+ "No coverage checking will be performed."
+ << std::endl);
+ return 0;
+ }
this->LoadLabels();
cmGeneratedFileStream ofs;
diff --git a/Tests/RunCMake/CTestCommandLine/EmptyDirCoverage-ctest-stderr.txt b/Tests/RunCMake/CTestCommandLine/EmptyDirCoverage-ctest-stderr.txt
new file mode 100644
index 0000000..e6f9325
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/EmptyDirCoverage-ctest-stderr.txt
@@ -0,0 +1,3 @@
+Cannot find file: [^
+]*/Tests/RunCMake/CTestCommandLine/EmptyDirCoverage-ctest-build/DartConfiguration.tcl
+Binary directory is not set. No coverage checking will be performed.$
diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
index afec011..4b654f8 100644
--- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
@@ -360,6 +360,10 @@ run_NoTests()
# Check the configuration type variable is passed
run_ctest(check-configuration-type)
+run_cmake_command(EmptyDirCoverage-ctest
+ ${CMAKE_CTEST_COMMAND} -C Debug -M Experimental -T Coverage
+ )
+
function(run_MemCheckSan case opts)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/MemCheckSan${case}-build)