xml2: added <errors> element
This commit is contained in:
parent
26b21a5ae0
commit
9a383388be
|
@ -55,7 +55,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
|
||||||
errorlist = true;
|
errorlist = true;
|
||||||
std::cout << ErrorLogger::ErrorMessage::getXMLHeader(_settings._xml_version);
|
std::cout << ErrorLogger::ErrorMessage::getXMLHeader(_settings._xml_version);
|
||||||
cppcheck->getErrorMessages();
|
cppcheck->getErrorMessages();
|
||||||
std::cout << ErrorLogger::ErrorMessage::getXMLFooter() << std::endl;
|
std::cout << ErrorLogger::ErrorMessage::getXMLFooter(_settings._xml_version) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.ExitAfterPrinting())
|
if (parser.ExitAfterPrinting())
|
||||||
|
@ -141,7 +141,7 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
|
||||||
|
|
||||||
if (_settings._xml)
|
if (_settings._xml)
|
||||||
{
|
{
|
||||||
reportErr(ErrorLogger::ErrorMessage::getXMLFooter());
|
reportErr(ErrorLogger::ErrorMessage::getXMLFooter(_settings._xml_version));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (returnValue)
|
if (returnValue)
|
||||||
|
|
|
@ -162,15 +162,16 @@ std::string ErrorLogger::ErrorMessage::getXMLHeader(int xml_version)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ostr << "<results version=\"" << xml_version << "\">\n";
|
ostr << "<results version=\"" << xml_version << "\">\n";
|
||||||
ostr << " <cppcheck version=\"" << CppCheck::version() << "\"/>";
|
ostr << " <cppcheck version=\"" << CppCheck::version() << "\"/>\n";
|
||||||
|
ostr << " <errors>";
|
||||||
}
|
}
|
||||||
|
|
||||||
return ostr.str();
|
return ostr.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ErrorLogger::ErrorMessage::getXMLFooter()
|
std::string ErrorLogger::ErrorMessage::getXMLFooter(int xml_version)
|
||||||
{
|
{
|
||||||
return "</results>";
|
return (xml_version<=1) ? "</results>" : " </errors>\n</results>";
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string stringToXml(std::string s)
|
static std::string stringToXml(std::string s)
|
||||||
|
|
|
@ -137,7 +137,7 @@ public:
|
||||||
std::string toXML(bool verbose, int ver) const;
|
std::string toXML(bool verbose, int ver) const;
|
||||||
|
|
||||||
static std::string getXMLHeader(int xml_version);
|
static std::string getXMLHeader(int xml_version);
|
||||||
static std::string getXMLFooter();
|
static std::string getXMLFooter(int xml_version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format the error message into a string.
|
* Format the error message into a string.
|
||||||
|
|
|
@ -124,7 +124,7 @@ private:
|
||||||
locs.push_back(loc);
|
locs.push_back(loc);
|
||||||
ErrorMessage msg(locs, Severity::error, "Programming error.\nVerbose error", "errorId");
|
ErrorMessage msg(locs, Severity::error, "Programming error.\nVerbose error", "errorId");
|
||||||
ASSERT_EQUALS("<?xml version=\"1.0\"?>\n<results>", ErrorLogger::ErrorMessage::getXMLHeader(1));
|
ASSERT_EQUALS("<?xml version=\"1.0\"?>\n<results>", ErrorLogger::ErrorMessage::getXMLHeader(1));
|
||||||
ASSERT_EQUALS("</results>", ErrorLogger::ErrorMessage::getXMLFooter());
|
ASSERT_EQUALS("</results>", ErrorLogger::ErrorMessage::getXMLFooter(1));
|
||||||
ASSERT_EQUALS("<error file=\"foo.cpp\" line=\"5\" id=\"errorId\" severity=\"error\" msg=\"Programming error.\"/>", msg.toXML(false,1));
|
ASSERT_EQUALS("<error file=\"foo.cpp\" line=\"5\" id=\"errorId\" severity=\"error\" msg=\"Programming error.\"/>", msg.toXML(false,1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ private:
|
||||||
locs.push_back(loc);
|
locs.push_back(loc);
|
||||||
ErrorMessage msg(locs, Severity::error, "Programming error.\nVerbose error", "errorId");
|
ErrorMessage msg(locs, Severity::error, "Programming error.\nVerbose error", "errorId");
|
||||||
ASSERT_EQUALS("<?xml version=\"1.0\"?>\n<results>", ErrorLogger::ErrorMessage::getXMLHeader(1));
|
ASSERT_EQUALS("<?xml version=\"1.0\"?>\n<results>", ErrorLogger::ErrorMessage::getXMLHeader(1));
|
||||||
ASSERT_EQUALS("</results>", ErrorLogger::ErrorMessage::getXMLFooter());
|
ASSERT_EQUALS("</results>", ErrorLogger::ErrorMessage::getXMLFooter(1));
|
||||||
ASSERT_EQUALS("<error file=\"foo.cpp\" line=\"5\" id=\"errorId\" severity=\"error\" msg=\"Verbose error\"/>", msg.toXML(true,1));
|
ASSERT_EQUALS("<error file=\"foo.cpp\" line=\"5\" id=\"errorId\" severity=\"error\" msg=\"Verbose error\"/>", msg.toXML(true,1));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue