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.
This commit is contained in:
Joseph Snyder 2015-03-06 11:18:19 -05:00
parent 8f38b8a443
commit c771f9d945
3 changed files with 6 additions and 1 deletions

View File

@ -78,7 +78,10 @@ class cmParseJacocoCoverage::XMLParser: public cmXMLParser
std::string line; std::string line;
FileLinesType& curFileLines = FileLinesType& curFileLines =
this->Coverage.TotalCoverage[this->CurFileName]; this->Coverage.TotalCoverage[this->CurFileName];
curFileLines.push_back(-1); if(fin)
{
curFileLines.push_back(-1);
}
while(cmSystemTools::GetLineFromStream(fin, line)) while(cmSystemTools::GetLineFromStream(fin, line))
{ {
curFileLines.push_back(-1); curFileLines.push_back(-1);

View File

@ -2409,6 +2409,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Testing/JacocoCoverage/DartConfiguration.tcl") "${CMake_BINARY_DIR}/Testing/JacocoCoverage/DartConfiguration.tcl")
file(COPY "${CMake_SOURCE_DIR}/Tests/JacocoCoverage/Coverage" file(COPY "${CMake_SOURCE_DIR}/Tests/JacocoCoverage/Coverage"
DESTINATION "${CMake_BINARY_DIR}/Testing/JacocoCoverage") 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 add_test(NAME CTestJacocoCoverage
COMMAND cmake -E chdir COMMAND cmake -E chdir
${CMake_BINARY_DIR}/Testing/JacocoCoverage ${CMake_BINARY_DIR}/Testing/JacocoCoverage