Skip to content

Commit

Permalink
Bump version of plugin-util to 5.0.0-rc990.a_c915b_e8801a_.
Browse files Browse the repository at this point in the history
Update test cases that have compile errors due to changed API.
  • Loading branch information
uhafner committed Sep 19, 2024
1 parent 79219de commit 5db511f
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 38 deletions.
4 changes: 2 additions & 2 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<changelist>-SNAPSHOT</changelist>
<module.name>${project.groupId}.warnings.ng</module.name>

<analysis-model-api.version>12.5.0</analysis-model-api.version>
<analysis-model-tests.version>${analysis-model-api.version}</analysis-model-tests.version>
<analysis-model-api.version>12.6.0-rc839.46d92a_4783a_5</analysis-model-api.version>
<analysis-model-tests.version>12.5.0</analysis-model-tests.version>
<pull-request-monitoring.version>335.v525cd64ec76b_</pull-request-monitoring.version>

<eclipse-collections.version>9.2.0</eclipse-collections.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import com.google.errorprone.annotations.CanIgnoreReturnValue;

import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import hudson.model.AbstractProject;
import hudson.model.FreeStyleProject;
Expand Down Expand Up @@ -100,14 +99,14 @@ void shouldCreateChecksDetailsWithNewIssuesAsAnnotations() {
}

private void configureScanner(final WorkflowJob job, final String fileName, final String parameters) {
job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " discoverReferenceBuild()\n"
+ " recordIssues tool: checkStyle(pattern: '**/" + fileName + "-*') "
+ parameters
+ "\n"
+ " }\n"
+ "}", true));
+ "}"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.util.PathUtil;

import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;

import io.jenkins.plugins.analysis.core.model.AnalysisResult;
Expand All @@ -32,12 +31,12 @@ void shouldCorrectlyParseJavacErrors() {

createFileInWorkspace(project, "Test.java", "public class Test {}");

project.setDefinition(new CpsFlowDefinition("node {\n"
project.setDefinition(createPipelineScript("node {\n"
+ " timestamps {\n"
+ " echo '[javac] Test.java:39: warning: Test Warning'\n"
+ " recordIssues tools: [java()], skipBlames: true\n"
+ " }\n"
+ "}", true));
+ "}"));

AnalysisResult result = scheduleSuccessfulBuild(project);

Expand Down Expand Up @@ -71,12 +70,12 @@ void shouldCorrectlyParseClangErrors() {

createFileInWorkspace(project, "test.c", "int main(void) { }");

project.setDefinition(new CpsFlowDefinition("node {\n"
project.setDefinition(createPipelineScript("node {\n"
+ " timestamps {\n"
+ " echo 'test.c:1:2: error: This is an error.'\n"
+ " recordIssues tools: [clang(id: 'clang', name: 'clang')], skipBlames: true\n"
+ " }\n"
+ "}", true));
+ "}"));

AnalysisResult result = scheduleSuccessfulBuild(project);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.junit.jupiter.api.Test;

import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import hudson.model.Result;

Expand Down Expand Up @@ -44,7 +43,7 @@ void shouldExpandTokenMacro() {
void shouldExpandDifferentSeverities() {
WorkflowJob job = createPipelineWithWorkspaceFilesWithSuffix("all-severities.xml");

job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " recordIssues tool: checkStyle(pattern: '**/" + "all-severities" + "*')\n"
+ " def total = tm('${ANALYSIS_ISSUES_COUNT}')\n"
Expand All @@ -58,7 +57,7 @@ void shouldExpandDifferentSeverities() {
+ " echo '[normal=' + normal + ']' \n"
+ " echo '[low=' + low + ']' \n"
+ " }\n"
+ "}", true));
+ "}"));

AnalysisResult baseline = scheduleBuildAndAssertStatus(job, Result.SUCCESS);

Expand Down Expand Up @@ -91,7 +90,7 @@ private void verifyConsoleLog(final AnalysisResult baseline, final int totalSize
}

private void configureToken(final WorkflowJob job, final String fileName) {
job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " discoverReferenceBuild()\n"
+ " recordIssues tool: checkStyle(pattern: '**/" + fileName + "*')\n"
Expand All @@ -106,6 +105,6 @@ private void configureToken(final WorkflowJob job, final String fileName) {
+ " echo '[new=' + additional + ']' \n"
+ " echo '[fixed=' + fixed + ']' \n"
+ " }\n"
+ "}", true));
+ "}"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import com.google.errorprone.annotations.CanIgnoreReturnValue;

import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import hudson.model.AbstractProject;
import hudson.model.FreeStyleProject;
Expand Down Expand Up @@ -48,14 +47,14 @@ class QualityGateITest extends IntegrationTestWithJenkinsPerSuite {
void shouldUseTwoQualityGates() {
WorkflowJob job = createPipelineWithWorkspaceFilesWithSuffix("checkstyle1.xml", "checkstyle2.xml");

job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " recordIssues tools: [checkStyle(pattern: '**/*issues.txt')],\n"
+ " qualityGates: [\n"
+ " [threshold: 3, type: 'TOTAL', criticality: 'NOTE'],\n"
+ " [threshold: 7, type: 'TOTAL', criticality: 'ERROR']]\n"
+ " }\n"
+ "}", true));
+ "}"));

AnalysisResult result = scheduleSuccessfulBuild(job);
assertThat(result).hasTotalSize(6);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class StepsITest extends IntegrationTestWithJenkinsPerSuite {
@Test
void shouldNotFailWhenJobHasNoWorkspace() {
var job = createPipelineWithWorkspaceFilesWithSuffix("eclipse.txt");
job.setDefinition(new CpsFlowDefinition("def r; node {r = scanForIssues tool: eclipse(pattern: '*issues.txt')}; publishIssues issues: [r]", true));
job.setDefinition(createPipelineScript("def r; node {r = scanForIssues tool: eclipse(pattern: '*issues.txt')}; publishIssues issues: [r]"));

var build = buildSuccessfully(job);
assertThat(build.getAction(ResultAction.class).getResult().getIssues()).hasSize(8);
Expand All @@ -81,12 +81,12 @@ void shouldNotFailWhenJobHasNoWorkspace() {
void shouldParseCheckstyleUsingTheParserRegistry() {
WorkflowJob job = createPipelineWithWorkspaceFilesWithSuffix("checkstyle1.xml", "checkstyle2.xml");

job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " recordIssues tool: analysisParser(analysisModelId: 'checkstyle', pattern: '**/"
+ "checkstyle1" + "*')\n"
+ " }\n"
+ "}", true));
+ "}"));

AnalysisResult baseline = scheduleSuccessfulBuild(job);
assertThat(baseline).hasTotalSize(3);
Expand Down Expand Up @@ -157,7 +157,7 @@ void shouldWhitelistRecorderApi() {
}

private void configureRecorder(final WorkflowJob job, final String fileName) {
job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " discoverReferenceBuild()\n"
+ " def reports = recordIssues tool: checkStyle(pattern: '**/" + fileName
Expand All @@ -173,11 +173,11 @@ private void configureRecorder(final WorkflowJob job, final String fileName) {
+ " echo issue.toString()\n"
+ " }"
+ " }\n"
+ "}", true));
+ "}"));
}

private void configureScanner(final WorkflowJob job, final String fileName) {
job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " def report = scanForIssues tool: checkStyle(pattern: '**/" + fileName + "*')\n"
+ " echo '[total=' + report.size() + ']' \n"
Expand All @@ -189,7 +189,7 @@ private void configureScanner(final WorkflowJob job, final String fileName) {
+ " echo issue.getAuthorName()\n"
+ " }"
+ " }\n"
+ "}", true));
+ "}"));
}

/**
Expand All @@ -199,11 +199,11 @@ private void configureScanner(final WorkflowJob job, final String fileName) {
void shouldSkipBlaming() {
WorkflowJob job = createPipelineWithWorkspaceFilesWithSuffix("checkstyle1.xml");

job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " recordIssues skipBlames: true, tool: checkStyle(pattern: '**/checkstyle1" + "*')\n"
+ " }\n"
+ "}", true));
+ "}"));
Run<?, ?> baseline = buildSuccessfully(job);
assertThat(getConsoleLog(baseline)).contains("Skipping SCM blames as requested");
}
Expand All @@ -214,13 +214,13 @@ void shouldSkipBlaming() {
void shouldToggleQuietStatusOfLogger(final boolean quiet) {
WorkflowJob job = createPipelineWithWorkspaceFilesWithSuffix("checkstyle1.xml");

job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " recordIssues "
+ " quiet: " + quiet + ", "
+ " tool: checkStyle(pattern: '**/" + "checkstyle1" + "*')\n"
+ " }\n"
+ "}", true));
+ "}"));
Run<?, ?> baseline = buildSuccessfully(job);
String consoleLog = getConsoleLog(baseline);
String message = "[CheckStyle]";
Expand Down Expand Up @@ -272,7 +272,7 @@ private void verifyApiResults(final Run<?, ?> baseline, final int totalSize, fin

private void configurePublisher(final WorkflowJob job, final String fileName, final String qualityGate) {
String qualityGateParameter = String.format("qualityGates: [%s]", qualityGate);
job.setDefinition(new CpsFlowDefinition("node {\n"
job.setDefinition(createPipelineScript("node {\n"
+ " stage ('Integration Test') {\n"
+ " discoverReferenceBuild()\n"
+ " def issues = scanForIssues tool: checkStyle(pattern: '**/" + fileName + "*')\n"
Expand All @@ -289,7 +289,7 @@ private void configurePublisher(final WorkflowJob job, final String fileName, fi
+ " echo '[new=' + totals.getNewSize() + ']' \n"
+ " echo '[fixed=' + totals.getFixedSize() + ']' \n"
+ " }\n"
+ "}", true));
+ "}"));
}

/** Verifies that a {@link Tool} defines a {@link Symbol}. */
Expand All @@ -307,7 +307,7 @@ void shouldProvideSymbol() {
void shouldRunInDeclarativePipeline() {
WorkflowJob job = createPipeline();

job.setDefinition(new CpsFlowDefinition("pipeline {\n"
job.setDefinition(createPipelineScript("pipeline {\n"
+ " agent 'any'\n"
+ " stages {\n"
+ " stage ('Create a fake warning') {\n"
Expand All @@ -321,7 +321,7 @@ void shouldRunInDeclarativePipeline() {
+ " recordIssues tool: gcc4(pattern: 'warnings.log')\n"
+ " }\n"
+ " }\n"
+ "}", true));
+ "}"));

AnalysisResult result = scheduleSuccessfulBuild(job);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import org.junit.jupiter.api.Test;

import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import hudson.model.Run;
import hudson.model.Slave;
Expand Down Expand Up @@ -45,10 +44,10 @@ void shouldCopySourcesIfMasterAgentSecurityIsActive() {

createFileInAgentWorkspace(agent, project, "Test.java", JAVA_CONTENT);

project.setDefinition(new CpsFlowDefinition("node('agent') {\n"
project.setDefinition(createPipelineScript("node('agent') {\n"
+ " echo '[javac] Test.java:39: warning: Test Warning'\n"
+ " recordIssues tool: java(), skipBlames: true\n"
+ "}", true));
+ "}"));

AnalysisResult result = scheduleSuccessfulBuild(project);
assertThat(result).hasNoErrorMessages();
Expand Down Expand Up @@ -112,10 +111,10 @@ void shouldNotCopySourcesWhenSourceCodeRetentionIsNever() {

createFileInAgentWorkspace(agent, project, "Test.java", JAVA_CONTENT);

project.setDefinition(new CpsFlowDefinition("node('agent') {\n"
project.setDefinition(createPipelineScript("node('agent') {\n"
+ " echo '[javac] Test.java:39: warning: Test Warning'\n"
+ " recordIssues tool: java(), sourceCodeRetention: 'NEVER'\n"
+ "}", true));
+ "}"));

AnalysisResult result = scheduleSuccessfulBuild(project);
assertThat(result).hasNoErrorMessages();
Expand Down

0 comments on commit 5db511f

Please sign in to comment.