From c771f9d945444f6cfe41195e26653f368aff7f42 Mon Sep 17 00:00:00 2001 From: Joseph Snyder Date: Fri, 6 Mar 2015 11:18:19 -0500 Subject: CTest: Fix Jacoco Coverage Rename the example jacoco.xml file to be jacoco.xml.in to stop CMake from apptempting to calculate Jacoco Coverage when running over itself. Enclose a push of -1 to the coverage vector to only happen if there is a fin to calculate for. This prevents a crash if the target file doesn't exist. --- Source/CTest/cmParseJacocoCoverage.cxx | 5 ++++- Tests/CMakeLists.txt | 2 ++ Tests/JacocoCoverage/Coverage/target/site/jacoco.xml | 1 - Tests/JacocoCoverage/Coverage/target/site/jacoco.xml.in | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) delete mode 100644 Tests/JacocoCoverage/Coverage/target/site/jacoco.xml create mode 100644 Tests/JacocoCoverage/Coverage/target/site/jacoco.xml.in diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx index ec4cfad..31ad9fe 100644 --- a/Source/CTest/cmParseJacocoCoverage.cxx +++ b/Source/CTest/cmParseJacocoCoverage.cxx @@ -78,7 +78,10 @@ class cmParseJacocoCoverage::XMLParser: public cmXMLParser std::string line; FileLinesType& curFileLines = this->Coverage.TotalCoverage[this->CurFileName]; - curFileLines.push_back(-1); + if(fin) + { + curFileLines.push_back(-1); + } while(cmSystemTools::GetLineFromStream(fin, line)) { curFileLines.push_back(-1); diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 08765de..703c548 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2409,6 +2409,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release "${CMake_BINARY_DIR}/Testing/JacocoCoverage/DartConfiguration.tcl") file(COPY "${CMake_SOURCE_DIR}/Tests/JacocoCoverage/Coverage" DESTINATION "${CMake_BINARY_DIR}/Testing/JacocoCoverage") + configure_file("${CMake_BINARY_DIR}/Testing/JacocoCoverage/Coverage/target/site/jacoco.xml.in" + "${CMake_BINARY_DIR}/Testing/JacocoCoverage/Coverage/target/site/jacoco.xml") add_test(NAME CTestJacocoCoverage COMMAND cmake -E chdir ${CMake_BINARY_DIR}/Testing/JacocoCoverage diff --git a/Tests/JacocoCoverage/Coverage/target/site/jacoco.xml b/Tests/JacocoCoverage/Coverage/target/site/jacoco.xml deleted file mode 100644 index 49c3e87..0000000 --- a/Tests/JacocoCoverage/Coverage/target/site/jacoco.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Tests/JacocoCoverage/Coverage/target/site/jacoco.xml.in b/Tests/JacocoCoverage/Coverage/target/site/jacoco.xml.in new file mode 100644 index 0000000..49c3e87 --- /dev/null +++ b/Tests/JacocoCoverage/Coverage/target/site/jacoco.xml.in @@ -0,0 +1 @@ + -- cgit v0.12