#5718 Supply DTD/XSD/RNG for cppcheck XML output - supply rng for current XML output. Add an automatic check on travis against the --errorlist output

This commit is contained in:
amai2012 2018-05-17 12:46:15 +02:00
parent 2b14b71c93
commit 64f0d31280
4 changed files with 65 additions and 0 deletions

View File

@ -75,6 +75,8 @@ script:
- sh -c "! grep '^\[' /tmp/cppcheck.cppcheck"
# run extra tests
- tools/generate_and_run_more_tests.sh
# Validate XML
- make validateXMLV2
# check test/cfg
- make checkcfg
- make validateCFG

View File

@ -316,6 +316,13 @@ PlatformFilesCHECKED := $(patsubst %.xml,%.checked,$(PlatformFiles))
xmllint --noout --relaxng platforms/cppcheck-platforms.rng $<
validatePlatforms: ${PlatformFilesCHECKED}
# Validate XML output (to detect regressions)
/tmp/errorlist.xml: cppcheck
cppcheck --errorlist >$@
.PHONY: validateXMLV2
validateXMLV2: /tmp/errorlist.xml
xmllint --noout --relaxng xmlV2.rng $<
###### Build

View File

@ -414,6 +414,12 @@ int main(int argc, char **argv)
fout << "%.checked:%.xml\n";
fout << "\txmllint --noout --relaxng platforms/cppcheck-platforms.rng $<\n";
fout << "validatePlatforms: ${PlatformFilesCHECKED}\n\n";
fout << "# Validate XML output (to detect regressions)\n";
fout << "/tmp/errorlist.xml: cppcheck\n";
fout << "\tcppcheck --errorlist >$@\n";
fout << ".PHONY: validateXMLV2\n";
fout << "validateXMLV2: /tmp/errorlist.xml\n";
fout << "\txmllint --noout --relaxng xmlV2.rng $<\n\n";
fout << "\n###### Build\n\n";

50
xmlV2.rng Normal file
View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<grammar ns="" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<element name="results">
<attribute name="version">
<data type="integer"/>
</attribute>
<element name="cppcheck">
<attribute name="version"/>
</element>
<element name="errors">
<oneOrMore>
<element name="error">
<optional>
<attribute name="cwe">
<data type="integer"/>
</attribute>
</optional>
<attribute name="id">
<data type="NCName"/>
</attribute>
<optional>
<attribute name="inconclusive">
<data type="boolean"/>
</attribute>
</optional>
<attribute name="msg"/>
<attribute name="severity">
<data type="NCName"/>
</attribute>
<attribute name="verbose"/>
<choice>
<element name="location">
<attribute name="file"/>
<attribute name="line">
<data type="integer"/>
</attribute>
</element>
<zeroOrMore>
<element name="symbol">
<data type="string"/>
</element>
</zeroOrMore>
</choice>
</element>
</oneOrMore>
</element>
</element>
</start>
</grammar>