Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bdc2467
commit 31a2a1d
Showing
6 changed files
with
279 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/resources/org/jenkinsci/plugins/cppcheck/cppcheck-2.0.xsd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!-- | ||
/******************************************************************************* | ||
* Author : Gregory Boissinot * | ||
******************************************************************************/ | ||
--> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
|
||
<xs:element name="error"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element name="location"> | ||
<xs:complexType> | ||
<xs:attribute name="file"/> | ||
<xs:attribute name="line"/> | ||
</xs:complexType> | ||
</xs:element> | ||
</xs:sequence> | ||
<xs:attribute name="file" type="xs:string" use="required"/> | ||
<xs:attribute name="line" type="xs:string" use="optional"/> | ||
<xs:attribute name="id" type="xs:string" use="required"/> | ||
<xs:attribute name="severity" type="xs:string" use="required"/> | ||
<xs:attribute name="msg" type="xs:string" use="required"/> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
<xs:element name="cppcheck"> | ||
<xs:complexType> | ||
<xs:attribute name="version"/> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
<xs:element name="errors"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element ref="error" minOccurs="0" maxOccurs="unbounded"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
|
||
<xs:element name="results"> | ||
<xs:complexType> | ||
<xs:sequence> | ||
<xs:element ref="cppcheck" minOccurs="1" maxOccurs="1"/> | ||
<xs:element ref="errors" minOccurs="1" maxOccurs="1"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
</xs:element> | ||
|
||
</xs:schema> |
66 changes: 66 additions & 0 deletions
66
src/test/java/org/jenkinsci/plugins/cppcheck/CppcheckParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.jenkinsci.plugins.cppcheck; | ||
|
||
import com.thalesgroup.hudson.plugins.cppcheck.CppcheckReport; | ||
import com.thalesgroup.hudson.plugins.cppcheck.model.CppcheckFile; | ||
import com.thalesgroup.hudson.plugins.cppcheck.parser.CppcheckParser; | ||
import junit.framework.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
/** | ||
* @author Gregory Boissinot | ||
*/ | ||
public class CppcheckParserTest { | ||
|
||
|
||
CppcheckParser cppcheckParser; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
cppcheckParser = new CppcheckParser(); | ||
} | ||
|
||
@Test | ||
public void testcppcheck1Version2() throws Exception { | ||
processCppcheck("version2/testCppcheck.xml", 16, 0, 0, 0, 2, 14); | ||
} | ||
|
||
private void processCppcheck(String filename, | ||
int nbErrors, | ||
int nbSeveritiesPossibleError, | ||
int nbSeveritiesPossibleStyle, | ||
int nbStyleErrors, | ||
int nbSeveritiesError, | ||
int nbSeveritiesNoCategory) throws Exception { | ||
|
||
CppcheckReport cppcheckReport = cppcheckParser.parse(new File(this.getClass().getResource(filename).toURI())); | ||
|
||
List<CppcheckFile> everyErrors = cppcheckReport.getEverySeverities(); | ||
List<CppcheckFile> possibileErrorSeverities = cppcheckReport.getPossibleErrorSeverities(); | ||
List<CppcheckFile> styleErrors = cppcheckReport.getStyleSeverities(); | ||
List<CppcheckFile> possibleStyleSeverities = cppcheckReport.getPossibleStyleSeverities(); | ||
List<CppcheckFile> errorSeverities = cppcheckReport.getErrorSeverities(); | ||
List<CppcheckFile> noCategorySeverities = cppcheckReport.getNoCategorySeverities(); | ||
|
||
assert possibileErrorSeverities != null; | ||
assert possibleStyleSeverities != null; | ||
assert errorSeverities != null; | ||
assert everyErrors != null; | ||
assert styleErrors != null; | ||
assert noCategorySeverities != null; | ||
|
||
Assert.assertEquals("Wrong computing of list of errors", everyErrors.size(), | ||
noCategorySeverities.size() + possibleStyleSeverities.size() + errorSeverities.size() + possibileErrorSeverities.size() + styleErrors.size()); | ||
|
||
Assert.assertEquals("Wrong total number of errors", nbErrors, everyErrors.size()); | ||
Assert.assertEquals("Wrong total number of errors for the severity 'possible error'", nbSeveritiesPossibleError, possibileErrorSeverities.size()); | ||
Assert.assertEquals("Wrong total number of errors for the severity 'possible style'", nbSeveritiesPossibleStyle, possibleStyleSeverities.size()); | ||
Assert.assertEquals("Wrong total number of errors for the severity 'style'", nbStyleErrors, styleErrors.size()); | ||
Assert.assertEquals("Wrong total number of errors for the severity 'error'", nbSeveritiesError, errorSeverities.size()); | ||
Assert.assertEquals("Wrong total number of errors with no category", nbSeveritiesNoCategory, noCategorySeverities.size()); | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
src/test/resources/org/jenkinsci/plugins/cppcheck/version2/testCppcheck.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<results version="2"> | ||
<cppcheck version="1.48"/> | ||
<errors> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Display/TestGenericDisplay.h" not found." verbose="Include file: "Test/Display/TestGenericDisplay.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="21"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Server/SuperFly.h" not found." verbose="Include file: "Test/Server/SuperFly.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="22"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Graphics/DispColors.h" not found." verbose="Include file: "Graphics/DispColors.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="23"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Graphics/TextureData.h" not found." verbose="Include file: "Graphics/TextureData.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="24"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Graphics/Decals.h" not found." verbose="Include file: "Graphics/Decals.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="25"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "InterfaceTest/InterfaceTest.hpp" not found." verbose="Include file: "InterfaceTest/InterfaceTest.hpp" not found."> | ||
<location file="TestGenericDisplay.cpp" line="26"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Utility/Assert.h" not found." verbose="Include file: "Utility/Assert.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="27"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Utility/FormatCharTesters.h" not found." verbose="Include file: "Utility/FormatCharTesters.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="28"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Utility/Units.h" not found." verbose="Include file: "Utility/Units.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="29"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Display/TestRegion.h" not found." verbose="Include file: "Test/Display/TestRegion.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="31"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "DisplayExec/DisplayModel.h" not found." verbose="Include file: "DisplayExec/DisplayModel.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="32"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Display/TestIndicatorFactory.h" not found." verbose="Include file: "Test/Display/TestIndicatorFactory.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="33"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Display/TestDataMonitor.h" not found." verbose="Include file: "Test/Display/TestDataMonitor.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="35"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Display/TestStatusBlock.h" not found." verbose="Include file: "Test/Display/TestStatusBlock.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="38"/> | ||
</error> | ||
<error id="syntaxError" severity="error" msg="Invalid number of charTestter ({) when these macros are defined: 'TEST;TEST_VM2;TODO_TESTS_REFACTOR'." verbose="Invalid number of charTestter ({) when these macros are defined: 'TEST;TEST_VM2;TODO_TESTS_REFACTOR'."> | ||
<location file="TestGenericDisplay.cpp" line="1600"/> | ||
</error> | ||
<error id="syntaxError" severity="error" msg="Invalid number of charTestter ({) when these macros are defined: 'TODO_TESTS_REFACTOR'." verbose="Invalid number of charTestter ({) when these macros are defined: 'TODO_TESTS_REFACTOR'."> | ||
<location file="TestGenericDisplay.cpp" line="1600"/> | ||
</error> | ||
</errors> | ||
</results> |