mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 22:16:11 +00:00
Added support for restricting tests to certain platforms (ecj, javac)
This commit is contained in:
1 parent
b7cede3c27
commit
eb91f71e83
3 files changed
+22
-3
No files matched your search
@@ -55,7 +55,7 @@ public abstract class AbstractRunTests {
|
||||
this.dumpActualFilesHere = findPlaceToDumpActualFiles();
|
||||
}
|
||||
|
||||
public final FileTester createTester(final DirectoryRunner.TestParams params, final File file, int version) throws IOException {
|
||||
public final FileTester createTester(final DirectoryRunner.TestParams params, final File file, String platform, int version) throws IOException {
|
||||
ConfigurationKeysLoader.LoaderLoader.loadAllConfigurationKeys();
|
||||
AssertionError directiveFailure = null;
|
||||
LombokTestSource sourceDirectives = null;
|
||||
@@ -65,6 +65,7 @@ public abstract class AbstractRunTests {
|
||||
if (!sourceDirectives.versionWithinLimit(params.getVersion())) return null;
|
||||
if (!sourceDirectives.versionWithinLimit(getClasspathVersion())) return null;
|
||||
if (!sourceDirectives.versionWithinLimit(version)) return null;
|
||||
if (!sourceDirectives.runOnPlatform(platform)) return null;
|
||||
} catch (AssertionError ae) {
|
||||
directiveFailure = ae;
|
||||
}
|
||||
|
||||
@@ -157,9 +157,9 @@ public class DirectoryRunner extends Runner {
|
||||
File file = new File(params.getBeforeDirectory(), fileName);
|
||||
switch (params.getCompiler()) {
|
||||
case DELOMBOK:
|
||||
return new RunTestsViaDelombok().createTester(params, file, params.getVersion());
|
||||
return new RunTestsViaDelombok().createTester(params, file, "javac", params.getVersion());
|
||||
case ECJ:
|
||||
return new RunTestsViaEcj().createTester(params, file, params.getVersion());
|
||||
return new RunTestsViaEcj().createTester(params, file, "ecj", params.getVersion());
|
||||
default:
|
||||
case JAVAC:
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -55,7 +56,14 @@ public class LombokTestSource {
|
||||
private final int versionLowerLimit, versionUpperLimit;
|
||||
private final ConfigurationResolver configuration;
|
||||
private final String specifiedEncoding;
|
||||
private final List<String> platforms;
|
||||
|
||||
public boolean runOnPlatform(String platform) {
|
||||
if (platforms == null || platforms.isEmpty()) return true;
|
||||
for (String pl : platforms) if (pl.equalsIgnoreCase(platform)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean versionWithinLimit(int version) {
|
||||
return version >= versionLowerLimit && version <= versionUpperLimit;
|
||||
}
|
||||
@@ -145,6 +153,7 @@ public class LombokTestSource {
|
||||
boolean unchanged = false;
|
||||
String encoding = null;
|
||||
Map<String, String> formats = new HashMap<String, String>();
|
||||
String[] platformLimit = null;
|
||||
|
||||
for (String directive : directives) {
|
||||
directive = directive.trim();
|
||||
@@ -164,6 +173,14 @@ public class LombokTestSource {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lc.startsWith("platform ")) {
|
||||
String platformDesc = lc.substring("platform ".length());
|
||||
int idx = platformDesc.indexOf(':');
|
||||
if (idx != -1) platformDesc = platformDesc.substring(0, idx).trim();
|
||||
platformLimit = platformDesc.split("\\s*,\\s*");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lc.startsWith("version ")) {
|
||||
int[] limits = parseVersionLimit(lc.substring(7).trim());
|
||||
if (limits == null) {
|
||||
@@ -207,6 +224,7 @@ public class LombokTestSource {
|
||||
this.ignore = ignore;
|
||||
this.skipCompareContent = skipCompareContent;
|
||||
this.unchanged = unchanged;
|
||||
this.platforms = platformLimit == null ? null : Arrays.asList(platformLimit);
|
||||
ConfigurationProblemReporter reporter = new ConfigurationProblemReporter() {
|
||||
@Override public void report(String sourceDescription, String problem, int lineNumber, CharSequence line) {
|
||||
Assert.fail("Problem on directive line: " + problem + " at conf line #" + lineNumber + " (" + line + ")");
|
||||
|
||||
Reference in new issue
Block a user