diff --git a/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java b/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java index d8d4df67e..4f49f0d51 100644 --- a/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java +++ b/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java @@ -33,6 +33,7 @@ import hudson.model.UpdateSite.Plugin; import hudson.util.VersionNumber; import io.jenkins.lib.versionnumber.JavaSpecificationVersion; + import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -72,6 +73,7 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; + import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.commons.io.IOUtils; @@ -380,11 +382,11 @@ && new VersionNumber(coreCoordinates.version).compareTo(new VersionNumber("1.485 } if (failed && config.isFailOnError()) { - throw new AbortException("Execution was aborted due to the failure in a plugin test (-failOnError is set)"); + throw new AbortException("Execution was aborted due to the failure in a plugin test (-failOnError is set)"); } return report; - } + } protected void generateHtmlReportFile() throws IOException { if (!config.reportFile.exists() || !config.reportFile.isFile()) { @@ -433,7 +435,7 @@ private TestExecutionResult testPluginAgainst(MavenCoordinates coreCoordinates, File pluginCheckoutDir = new File(config.workDirectory.getAbsolutePath() + File.separator + plugin.name + File.separator); - try { + try { // Run any precheckout hooks Map beforeCheckout = new HashMap<>(); beforeCheckout.put("pluginName", plugin.name); @@ -534,7 +536,9 @@ private TestExecutionResult testPluginAgainst(MavenCoordinates coreCoordinates, } List args = new ArrayList<>(); - args.add("--define=forkCount=1"); + + Map userProperties = mconfig.userProperties; + args.add(String.format("--define=forkCount=%s",userProperties.containsKey("forkCount") ? userProperties.get("forkCount") : "1")); args.add("hpi:resolve-test-dependencies"); args.add("hpi:test-hpl"); args.add("surefire:test"); @@ -554,7 +558,7 @@ private TestExecutionResult testPluginAgainst(MavenCoordinates coreCoordinates, pcth.runBeforeExecution(forExecutionHooks); args = (List)forExecutionHooks.get("args"); Set types = new HashSet<>((List) forExecutionHooks.get("types")); - mconfig.userProperties.put("types", String.join(",", types)); + userProperties.put("types", String.join(",", types)); // Execute with tests runner.run(mconfig, pluginCheckoutDir, buildLogFile, args.toArray(new String[args.size()])); @@ -1014,6 +1018,12 @@ private void addSplitPluginDependencies(String thisPlugin, MavenRunner.Config mc toAddTest = difference(pluginDeps, toAddTest); toAddTest = difference(toAdd, toAddTest); + if(toReplaceTest.containsKey("configuration-as-code")){ + VersionNumber versionNumber = toReplaceTest.get("configuration-as-code"); + pluginGroupIds.put("test-harness", "io.jenkins.configuration-as-code"); + toReplaceTest.put("test-harness", versionNumber); + } + if (!toAdd.isEmpty() || !toReplace.isEmpty() || !toAddTest.isEmpty() || !toReplaceTest.isEmpty()) { System.out.println("Adding/replacing plugin dependencies for compatibility: " + toAdd + " " + toReplace + "\nFor test: " + toAddTest + " " + toReplaceTest); pom.addDependencies(toAdd, toReplace, toAddTest, toReplaceTest, coreDep, pluginGroupIds, convertFromTestDep);