private AbstractCompatibilityTestRunner(Class<?> target, String versionStr) {
super(target);
validateTestName(target);
previous = new ArrayList<GradleDistribution>();
final ReleasedVersionDistributions previousVersions = new ReleasedVersionDistributions();
if (versionStr.equals("latest")) {
previous.add(previousVersions.getMostRecentFinalRelease());
implicitVersion = true;
} else if (versionStr.equals("all")) {
implicitVersion = true;
List<GradleDistribution> all = previousVersions.getAll();
for (GradleDistribution previous : all) {
if (!previous.worksWith(Jvm.current())) {
add(new IgnoredVersion(previous, "does not work with current JVM"));
continue;
}
if (!previous.worksWith(OperatingSystem.current())) {
add(new IgnoredVersion(previous, "does not work with current OS"));
continue;
}
this.previous.add(previous);
}
} else if (versionStr.matches("^\\d.*$")) {
implicitVersion = false;
String[] versions = versionStr.split(",");
List<GradleVersion> gradleVersions = CollectionUtils.sort(collect(Arrays.asList(versions), new Transformer<GradleVersion, String>() {
public GradleVersion transform(String versionString) {
return GradleVersion.version(versionString);
}
}), Collections.reverseOrder());
inject(previous, gradleVersions, new Action<InjectionStep<List<GradleDistribution>, GradleVersion>>() {
public void execute(InjectionStep<List<GradleDistribution>, GradleVersion> step) {
GradleDistribution distribution = previousVersions.getDistribution(step.getItem());
if (distribution == null) {
throw new RuntimeException("Gradle version '" + step.getItem().getVersion() + "' is not a valid testable released version");
}
step.getTarget().add(distribution);
}