From c9dea7ed4449f99f5dd374a637c1073946996edf Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Tue, 2 Feb 2021 14:11:21 +0100 Subject: [PATCH 1/3] Add an integration test for the parser of the parasoft-findings plugin. --- plugin/pom.xml | 6 + .../analysis/warnings/steps/ParsersITest.java | 18 +- .../analysis/warnings/steps/parasoft.xml | 197 ++++++++++++++++++ 3 files changed, 215 insertions(+), 6 deletions(-) create mode 100644 plugin/src/test/resources/io/jenkins/plugins/analysis/warnings/steps/parasoft.xml diff --git a/plugin/pom.xml b/plugin/pom.xml index 5ccc866236..e93fe5956d 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -364,6 +364,12 @@ + + com.parasoft + parasoft-findings + 10.5.0 + test + org.jenkins-ci.plugins flexible-publish diff --git a/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ParsersITest.java b/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ParsersITest.java index ae9b271932..f811f0f8ef 100644 --- a/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ParsersITest.java +++ b/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ParsersITest.java @@ -3,14 +3,13 @@ import java.util.Arrays; import java.util.stream.Collectors; -import org.junit.jupiter.api.Test; +import org.jenkinsci.plugins.workflow.job.WorkflowJob; +import org.junit.Test; + +import com.parasoft.xtest.reports.jenkins.tool.ParasoftTool; import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.Report; - -import org.jenkinsci.plugins.workflow.job.WorkflowJob; - -import io.jenkins.plugins.analysis.core.model.AnalysisModelParser; import io.jenkins.plugins.analysis.core.model.AnalysisResult; import io.jenkins.plugins.analysis.core.model.StaticAnalysisLabelProvider; import io.jenkins.plugins.analysis.core.model.Tool; @@ -69,6 +68,13 @@ class ParsersITest extends IntegrationTestWithJenkinsPerSuite { + "files="$files $directory/$i"\n" + "done"; + /** Runs the Parasoft parser (part of the parasoft-findings plugin) on a file that contains 5 issues. */ + @Test + public void shouldReadParasoftWarnings() { + shouldFindIssuesOfTool(5, new ParasoftTool(), "parasoft.xml"); + } + + /** Runs the native parser on a file that contains 9 issues. */ @Test void shouldFindAllRevapiIssues() { shouldFindIssuesOfTool(7, new RevApi(), "revapi-result.json"); @@ -992,7 +998,7 @@ void shouldFindAllCrossCoreEmbeddedStudioIssues() { void shouldFindAllCodeGeneratorIssues() { shouldFindIssuesOfTool(8, new CodeGenerator(), "CodeGenerator.log"); } - + /** Runs the trivy parser on an output file that contains 4 issues. */ @Test void shouldFindAllTrivyIssues() { diff --git a/plugin/src/test/resources/io/jenkins/plugins/analysis/warnings/steps/parasoft.xml b/plugin/src/test/resources/io/jenkins/plugins/analysis/warnings/steps/parasoft.xml new file mode 100644 index 0000000000..c75f1cf00b --- /dev/null +++ b/plugin/src/test/resources/io/jenkins/plugins/analysis/warnings/steps/parasoft.xml @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 9fcb9ced578e624c52da472470e4696fa17f2d51 Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Fri, 5 Feb 2021 16:09:43 +0100 Subject: [PATCH 2/3] Add Parasoft embedded repository to resolve missing artefacts. --- plugin/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin/pom.xml b/plugin/pom.xml index e93fe5956d..826fb07a41 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -626,6 +626,10 @@ repo.jenkins-ci.org https://repo.jenkins-ci.org/public/ + + repo.parasoft.com + https://github.com/jenkinsci/parasoft-findings-plugin/tree/master/repository + incrementals.jenkins-ci.org https://repo.jenkins-ci.org/incrementals/ From 545fa8a8257bcd5346da29acf5f4cb762116382c Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Sat, 6 Jan 2024 20:56:41 +0100 Subject: [PATCH 3/3] Bump version of parasoft-findings to 10.7.1. --- plugin/pom.xml | 6 +----- .../analysis/warnings/steps/ParsersITest.java | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/plugin/pom.xml b/plugin/pom.xml index 826fb07a41..dcdee1bea3 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -367,7 +367,7 @@ com.parasoft parasoft-findings - 10.5.0 + 10.7.1 test @@ -626,10 +626,6 @@ repo.jenkins-ci.org https://repo.jenkins-ci.org/public/ - - repo.parasoft.com - https://github.com/jenkinsci/parasoft-findings-plugin/tree/master/repository - incrementals.jenkins-ci.org https://repo.jenkins-ci.org/incrementals/ diff --git a/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ParsersITest.java b/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ParsersITest.java index f811f0f8ef..4f2edea9f5 100644 --- a/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ParsersITest.java +++ b/plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ParsersITest.java @@ -3,14 +3,18 @@ import java.util.Arrays; import java.util.stream.Collectors; -import org.jenkinsci.plugins.workflow.job.WorkflowJob; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import com.parasoft.xtest.reports.jenkins.tool.ParasoftTool; +import com.parasoft.findings.jenkins.tool.ParasoftTool; import edu.hm.hafner.analysis.Issue; import edu.hm.hafner.analysis.Report; + +import org.jenkinsci.plugins.workflow.job.WorkflowJob; + +import io.jenkins.plugins.analysis.core.model.AnalysisModelParser; import io.jenkins.plugins.analysis.core.model.AnalysisResult; +import io.jenkins.plugins.analysis.core.model.ReportScanningTool; import io.jenkins.plugins.analysis.core.model.StaticAnalysisLabelProvider; import io.jenkins.plugins.analysis.core.model.Tool; import io.jenkins.plugins.analysis.core.testutil.IntegrationTestWithJenkinsPerSuite; @@ -70,7 +74,7 @@ class ParsersITest extends IntegrationTestWithJenkinsPerSuite { /** Runs the Parasoft parser (part of the parasoft-findings plugin) on a file that contains 5 issues. */ @Test - public void shouldReadParasoftWarnings() { + void shouldReadParasoftWarnings() { shouldFindIssuesOfTool(5, new ParasoftTool(), "parasoft.xml"); } @@ -1035,7 +1039,7 @@ void shouldFindAllGrypeIssues() { shouldFindIssuesOfTool(3, new Grype(), "grype-report.json"); } - private void shouldFindIssuesOfTool(final int expectedSizeOfIssues, final AnalysisModelParser tool, + private void shouldFindIssuesOfTool(final int expectedSizeOfIssues, final ReportScanningTool tool, final String... fileNames) { String defaultPipelineDefinition = "recordIssues tool: %s(pattern:'**/%s', reportEncoding:'UTF-8')"; @@ -1050,7 +1054,7 @@ private void shouldFindIssuesOfTool(final int expectedSizeOfIssues, final Analys expectedSizeOfIssues, tool, fileNames); } - private Report findIssuesWithoutAnsiColorPlugin(final int expectedSizeOfIssues, final AnalysisModelParser tool, + private Report findIssuesWithoutAnsiColorPlugin(final int expectedSizeOfIssues, final ReportScanningTool tool, final String... fileNames) { return findIssuesInPipeline( "recordIssues tool: %s(pattern:'**/%s', reportEncoding:'UTF-8')", expectedSizeOfIssues, tool, @@ -1058,7 +1062,7 @@ private Report findIssuesWithoutAnsiColorPlugin(final int expectedSizeOfIssues, } private Report findIssuesWithAnsiColorPlugin(final int expectedSizeOfIssues, - final AnalysisModelParser tool, final String... fileNames) { + final ReportScanningTool tool, final String... fileNames) { String pipelineDefinition = "wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {\n" + " recordIssues tool: %s(pattern:'**/%s', reportEncoding:'UTF-8')\n" + "}"; @@ -1067,7 +1071,7 @@ private Report findIssuesWithAnsiColorPlugin(final int expectedSizeOfIssues, @SuppressWarnings({"illegalcatch", "OverlyBroadCatchBlock", "PMD.LinguisticNaming"}) private Report findIssuesInPipeline(final String pipelineDefinition, - final int expectedSizeOfIssues, final AnalysisModelParser tool, final String... fileNames) { + final int expectedSizeOfIssues, final ReportScanningTool tool, final String... fileNames) { try { WorkflowJob job = createPipeline(); copyMultipleFilesToWorkspace(job, fileNames);