Skip to content

Commit ceff09d

Browse files
committed
cppcheck-opensource#5178 Supply DTD/(XSD/RNG for cppcheck XML output. Add target to Makefile to create and validate XML from regular run. Update xmlV2.rng accordingly.
1 parent c07abdd commit ceff09d

3 files changed

Lines changed: 67 additions & 55 deletions

File tree

‎Makefile‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,13 @@ validatePlatforms: ${PlatformFilesCHECKED}
319319
# Validate XML output (to detect regressions)
320320
/tmp/errorlist.xml: cppcheck
321321
cppcheck --errorlist >$@
322+
/tmp/example.xml: cppcheck
323+
cppcheck --xml --inconclusive -j 4 cli externals gui lib test 2>/tmp/example.xml
324+
createXMLExamples:/tmp/errorlist.xml /tmp/example.xml
322325
.PHONY: validateXMLV2
323-
validateXMLV2: /tmp/errorlist.xml
324-
xmllint --noout --relaxng xmlV2.rng $<
325-
326+
validateXMLV2: createXMLExamples
327+
xmllint --noout --relaxng xmlV2.rng /tmp/errorlist.xml
328+
xmllint --noout --relaxng xmlV2.rng /tmp/example.xml
326329

327330
###### Build
328331

‎tools/dmake.cpp‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,13 @@ int main(int argc, char **argv)
417417
fout << "# Validate XML output (to detect regressions)\n";
418418
fout << "/tmp/errorlist.xml: cppcheck\n";
419419
fout << "\tcppcheck --errorlist >$@\n";
420+
fout << "/tmp/example.xml: cppcheck\n";
421+
fout << "\tcppcheck --xml --inconclusive -j 4 cli externals gui lib test 2>/tmp/example.xml\n";
422+
fout << "createXMLExamples:/tmp/errorlist.xml /tmp/example.xml\n";
420423
fout << ".PHONY: validateXMLV2\n";
421-
fout << "validateXMLV2: /tmp/errorlist.xml\n";
422-
fout << "\txmllint --noout --relaxng xmlV2.rng $<\n\n";
424+
fout << "validateXMLV2: createXMLExamples\n";
425+
fout << "\txmllint --noout --relaxng xmlV2.rng /tmp/errorlist.xml\n";
426+
fout << "\txmllint --noout --relaxng xmlV2.rng /tmp/example.xml\n";
423427

424428
fout << "\n###### Build\n\n";
425429

‎xmlV2.rng‎

100644100755
Lines changed: 55 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,55 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<grammar ns="" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3-
<start>
4-
<element name="results">
5-
<attribute name="version">
6-
<data type="integer"/>
7-
</attribute>
8-
<element name="cppcheck">
9-
<attribute name="version"/>
10-
</element>
11-
<element name="errors">
12-
<oneOrMore>
13-
<element name="error">
14-
<optional>
15-
<attribute name="cwe">
16-
<data type="integer"/>
17-
</attribute>
18-
</optional>
19-
<attribute name="id">
20-
<data type="NCName"/>
21-
</attribute>
22-
<optional>
23-
<attribute name="inconclusive">
24-
<data type="boolean"/>
25-
</attribute>
26-
</optional>
27-
<attribute name="msg"/>
28-
<attribute name="severity">
29-
<data type="NCName"/>
30-
</attribute>
31-
<attribute name="verbose"/>
32-
<choice>
33-
<element name="location">
34-
<attribute name="file"/>
35-
<attribute name="line">
36-
<data type="integer"/>
37-
</attribute>
38-
</element>
39-
<zeroOrMore>
40-
<element name="symbol">
41-
<data type="string"/>
42-
</element>
43-
</zeroOrMore>
44-
</choice>
45-
</element>
46-
</oneOrMore>
47-
</element>
48-
</element>
49-
</start>
50-
</grammar>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<grammar ns="" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3+
<start>
4+
<element name="results">
5+
<attribute name="version">
6+
<data type="integer"/>
7+
</attribute>
8+
<element name="cppcheck">
9+
<attribute name="version"/>
10+
</element>
11+
<element name="errors">
12+
<oneOrMore>
13+
<element name="error">
14+
<optional>
15+
<attribute name="cwe">
16+
<data type="integer"/>
17+
</attribute>
18+
</optional>
19+
<attribute name="id">
20+
<data type="NCName"/>
21+
</attribute>
22+
<optional>
23+
<attribute name="inconclusive">
24+
<data type="boolean"/>
25+
</attribute>
26+
</optional>
27+
<attribute name="msg"/>
28+
<attribute name="severity">
29+
<data type="NCName"/>
30+
</attribute>
31+
<attribute name="verbose"/>
32+
<choice>
33+
<zeroOrMore>
34+
<element name="location">
35+
<attribute name="file"/>
36+
<optional>
37+
<attribute name="info"/>
38+
</optional>
39+
<attribute name="line">
40+
<data type="integer"/>
41+
</attribute>
42+
</element>
43+
</zeroOrMore>
44+
<zeroOrMore>
45+
<element name="symbol">
46+
<data type="anyURI"/>
47+
</element>
48+
</zeroOrMore>
49+
</choice>
50+
</element>
51+
</oneOrMore>
52+
</element>
53+
</element>
54+
</start>
55+
</grammar>

0 commit comments

Comments
 (0)