summaryrefslogtreecommitdiff
path: root/src/main/org
diff options
context:
space:
mode:
authorJaikiran Pai <jaikiran@apache.org>2018-08-27 17:46:12 +0530
committerJaikiran Pai <jaikiran@apache.org>2018-08-27 17:48:53 +0530
commit8590e1539af7e5057d02941911c44d887ba3caca (patch)
treef769cf670500d40a34a031b8fe91cd319fc02d44 /src/main/org
parentedfeba73e34b6f14259b01046d284f627c66af1a (diff)
downloadant-8590e1539af7e5057d02941911c44d887ba3caca.tar.gz
[junitlauncher] More fine-grained control over classpath for forked tests in junitlauncher
- Allows Ant runtime libraries to be excluded and thus letting the user have control over where those library jars come from - Allows JUnit platform libraries to be excluded and thus letting the user have control over where those library jars come from Plus added testcases to verify this feature
Diffstat (limited to 'src/main/org')
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/ForkDefinition.java18
-rw-r--r--src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/StandaloneLauncher.java3
2 files changed, 16 insertions, 5 deletions
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/ForkDefinition.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/ForkDefinition.java
index bda3381db..c5c95cc0d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/ForkDefinition.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/ForkDefinition.java
@@ -41,7 +41,7 @@ import java.io.File;
public class ForkDefinition {
private boolean includeAntRuntimeLibraries = true;
- private boolean includeJunitPlatformLibraries = true;
+ private boolean includeJUnitPlatformLibraries = true;
private final CommandlineJava commandLineJava;
private final Environment env = new Environment();
@@ -69,6 +69,14 @@ public class ForkDefinition {
return this.timeout;
}
+ public void setIncludeJUnitPlatformLibraries(final boolean include) {
+ this.includeJUnitPlatformLibraries = include;
+ }
+
+ public void setIncludeAntRuntimeLibraries(final boolean include) {
+ this.includeAntRuntimeLibraries = include;
+ }
+
public Commandline.Argument createJvmArg() {
return this.commandLineJava.createVmArgument();
}
@@ -121,19 +129,23 @@ public class ForkDefinition {
addAntRuntimeResourceSource(antRuntimeResourceSources, task, toResourceName(AntMain.class));
addAntRuntimeResourceSource(antRuntimeResourceSources, task, toResourceName(Task.class));
addAntRuntimeResourceSource(antRuntimeResourceSources, task, toResourceName(JUnitLauncherTask.class));
+ } else {
+ task.log("Excluding Ant runtime libraries from forked JVM classpath", Project.MSG_DEBUG);
}
-
- if (this.includeJunitPlatformLibraries) {
+ if (this.includeJUnitPlatformLibraries) {
// platform-engine
addAntRuntimeResourceSource(antRuntimeResourceSources, task, toResourceName(TestEngine.class));
// platform-launcher
addAntRuntimeResourceSource(antRuntimeResourceSources, task, toResourceName(LauncherFactory.class));
// platform-commons
addAntRuntimeResourceSource(antRuntimeResourceSources, task, toResourceName(Testable.class));
+ } else {
+ task.log("Excluding JUnit platform libraries from forked JVM classpath", Project.MSG_DEBUG);
}
final Path classPath = cmdLine.createClasspath(project);
classPath.createPath().append(antRuntimeResourceSources);
+
return cmdLine;
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/StandaloneLauncher.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/StandaloneLauncher.java
index 8f43da373..69a1556c8 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/StandaloneLauncher.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/StandaloneLauncher.java
@@ -98,7 +98,6 @@ public class StandaloneLauncher {
i = i + numArgsConsumed;
}
-
launchDefinition.setTestExecutionContext(forkedExecution);
final LauncherSupport launcherSupport = new LauncherSupport(launchDefinition);
try {
@@ -106,8 +105,8 @@ public class StandaloneLauncher {
} catch (Throwable t) {
if (launcherSupport.hasTestFailures()) {
System.exit(Constants.FORK_EXIT_CODE_TESTS_FAILED);
- throw t;
}
+ throw t;
}
if (launcherSupport.hasTestFailures()) {
System.exit(Constants.FORK_EXIT_CODE_TESTS_FAILED);