xml results: added a command line switch for generating simple results.xml file
This commit is contained in:
parent
12b6cf8c70
commit
0ca38cc9fe
|
@ -95,6 +95,10 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
|
||||||
else if (strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "--force") == 0)
|
else if (strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "--force") == 0)
|
||||||
_settings._force = true;
|
_settings._force = true;
|
||||||
|
|
||||||
|
// Write results in results.xml
|
||||||
|
else if (strcmp(argv[i], "--xml-results") == 0)
|
||||||
|
_settings._xmlResults = true;
|
||||||
|
|
||||||
// Print help
|
// Print help
|
||||||
else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
|
else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
|
||||||
{
|
{
|
||||||
|
@ -272,6 +276,24 @@ unsigned int CppCheck::check()
|
||||||
_checkFunctionUsage.check();
|
_checkFunctionUsage.check();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// xml results..
|
||||||
|
if (_settings._xmlResults)
|
||||||
|
{
|
||||||
|
std::ofstream fxml("results.xml");
|
||||||
|
fxml << "<cppcheckResults>\n"
|
||||||
|
<< " <test result=\"" << (_errorList.empty() ? "OK" : "ERROR") << "\"/>\n"
|
||||||
|
<< " <name>cppcheck</name>\n";
|
||||||
|
if (_errorList.size())
|
||||||
|
{
|
||||||
|
fxml << " <message>\n";
|
||||||
|
for (std::list<std::string>::const_iterator it = _errorList.begin(); it != _errorList.end(); ++it)
|
||||||
|
fxml << *it << "\n";
|
||||||
|
fxml << " </message>\n";
|
||||||
|
}
|
||||||
|
fxml << " </test>\n"
|
||||||
|
<< "</cppcheckResults>\n";
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int result = _errorList.size();
|
unsigned int result = _errorList.size();
|
||||||
_errorList.clear();
|
_errorList.clear();
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -27,6 +27,7 @@ Settings::Settings()
|
||||||
_errorsOnly = false;
|
_errorsOnly = false;
|
||||||
_verbose = false;
|
_verbose = false;
|
||||||
_force = false;
|
_force = false;
|
||||||
|
_xmlResults = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::~Settings()
|
Settings::~Settings()
|
||||||
|
|
|
@ -39,6 +39,9 @@ public:
|
||||||
|
|
||||||
/** Force checking t he files with "too many" configurations. */
|
/** Force checking t he files with "too many" configurations. */
|
||||||
bool _force;
|
bool _force;
|
||||||
|
|
||||||
|
/** write results in xml file results.xml */
|
||||||
|
bool _xmlResults;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGS_H
|
#endif // SETTINGS_H
|
||||||
|
|
Loading…
Reference in New Issue