Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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<String, Object> beforeCheckout = new HashMap<>();
beforeCheckout.put("pluginName", plugin.name);
Expand Down Expand Up @@ -534,7 +536,9 @@ private TestExecutionResult testPluginAgainst(MavenCoordinates coreCoordinates,
}

List<String> args = new ArrayList<>();
args.add("--define=forkCount=1");

Map<String, String> 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");
Expand All @@ -554,7 +558,7 @@ private TestExecutionResult testPluginAgainst(MavenCoordinates coreCoordinates,
pcth.runBeforeExecution(forExecutionHooks);
args = (List<String>)forExecutionHooks.get("args");
Set<String> types = new HashSet<>((List<String>) 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()]));
Expand Down Expand Up @@ -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);
Expand Down