From c096cbc65aeb883a886d70a6ae43ebea2de2a217 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 16 Feb 2017 23:33:43 +0100 Subject: Fixed versionmatching for our test framework. --- test/core/src/lombok/AbstractRunTests.java | 4 +++- test/core/src/lombok/DirectoryRunner.java | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'test/core') diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java index d044a39f..934c74c0 100644 --- a/test/core/src/lombok/AbstractRunTests.java +++ b/test/core/src/lombok/AbstractRunTests.java @@ -55,7 +55,7 @@ public abstract class AbstractRunTests { this.dumpActualFilesHere = findPlaceToDumpActualFiles(); } - public final FileTester createTester(final DirectoryRunner.TestParams params, final File file) throws IOException { + public final FileTester createTester(final DirectoryRunner.TestParams params, final File file, int version) throws IOException { ConfigurationKeysLoader.LoaderLoader.loadAllConfigurationKeys(); AssertionError directiveFailure = null; LombokTestSource sourceDirectives = null; @@ -64,6 +64,7 @@ public abstract class AbstractRunTests { if (sourceDirectives.isIgnore()) return null; if (!sourceDirectives.versionWithinLimit(params.getVersion())) return null; if (!sourceDirectives.versionWithinLimit(getClasspathVersion())) return null; + if (!sourceDirectives.versionWithinLimit(version)) return null; } catch (AssertionError ae) { directiveFailure = ae; } @@ -73,6 +74,7 @@ public abstract class AbstractRunTests { if (expected.isIgnore()) return null; if (!expected.versionWithinLimit(params.getVersion())) return null; + if (!expected.versionWithinLimit(version)) return null; final LombokTestSource sourceDirectives_ = sourceDirectives; final AssertionError directiveFailure_ = directiveFailure; diff --git a/test/core/src/lombok/DirectoryRunner.java b/test/core/src/lombok/DirectoryRunner.java index d4275b09..c9a5de31 100644 --- a/test/core/src/lombok/DirectoryRunner.java +++ b/test/core/src/lombok/DirectoryRunner.java @@ -155,12 +155,11 @@ public class DirectoryRunner extends Runner { private FileTester createTester(String fileName) throws IOException { File file = new File(params.getBeforeDirectory(), fileName); - switch (params.getCompiler()) { case DELOMBOK: - return new RunTestsViaDelombok().createTester(params, file); + return new RunTestsViaDelombok().createTester(params, file, params.getVersion()); case ECJ: - return new RunTestsViaEcj().createTester(params, file); + return new RunTestsViaEcj().createTester(params, file, params.getVersion()); default: case JAVAC: throw new UnsupportedOperationException(); -- cgit From eb91f71e830900f9ce76456f54f97f3988a8906a Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 6 Mar 2017 23:34:01 +0100 Subject: Added support for restricting tests to certain platforms (ecj, javac) --- test/core/src/lombok/AbstractRunTests.java | 3 ++- test/core/src/lombok/DirectoryRunner.java | 4 ++-- test/core/src/lombok/LombokTestSource.java | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) (limited to 'test/core') diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java index 934c74c0..5c5ba898 100644 --- a/test/core/src/lombok/AbstractRunTests.java +++ b/test/core/src/lombok/AbstractRunTests.java @@ -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; } diff --git a/test/core/src/lombok/DirectoryRunner.java b/test/core/src/lombok/DirectoryRunner.java index c9a5de31..72f01de1 100644 --- a/test/core/src/lombok/DirectoryRunner.java +++ b/test/core/src/lombok/DirectoryRunner.java @@ -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(); diff --git a/test/core/src/lombok/LombokTestSource.java b/test/core/src/lombok/LombokTestSource.java index 16f9f49f..31f7db3e 100644 --- a/test/core/src/lombok/LombokTestSource.java +++ b/test/core/src/lombok/LombokTestSource.java @@ -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 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 formats = new HashMap(); + 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 + ")"); -- cgit From 8bfbd7fa846537c9393350e02c459c6878c0dec2 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 7 Mar 2017 01:10:03 +0100 Subject: fixded the version mess in the test framework. --- test/core/src/lombok/AbstractRunTests.java | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'test/core') diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java index 5c5ba898..1a454585 100644 --- a/test/core/src/lombok/AbstractRunTests.java +++ b/test/core/src/lombok/AbstractRunTests.java @@ -62,8 +62,6 @@ public abstract class AbstractRunTests { try { sourceDirectives = LombokTestSource.readDirectives(file); if (sourceDirectives.isIgnore()) return null; - 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) { @@ -101,22 +99,6 @@ public abstract class AbstractRunTests { }; } - private static int getClasspathVersion() { - try { - Class.forName("java.lang.AutoCloseable"); - } catch (ClassNotFoundException e) { - return 6; - } - - try { - Class.forName("java.util.stream.Stream"); - } catch (ClassNotFoundException e) { - return 7; - } - - return 8; - } - protected abstract boolean transformCode(Collection messages, StringWriter result, File file, String encoding, Map formatPreferences) throws Throwable; protected String readFile(File file) throws IOException { -- cgit