diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-01-20 01:45:48 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-01-20 01:46:01 +0100 |
commit | d1899a81e95bdc69955aa593be905be0ff77043e (patch) | |
tree | 114f7af33ea57ca4042b431f317bfc5c216a27c8 /test/core/src | |
parent | e5dc6203c8dd2ac51594c8dd73945bb62c7fe047 (diff) | |
download | lombok-d1899a81e95bdc69955aa593be905be0ff77043e.tar.gz lombok-d1899a81e95bdc69955aa593be905be0ff77043e.tar.bz2 lombok-d1899a81e95bdc69955aa593be905be0ff77043e.zip |
[test] Missing after-X files used to be an implicit 'just ignore the content' signal; now you need an explicit directive to allow this behaviour.
[configuration] added tests for @Accessors configuration key implementations.
Diffstat (limited to 'test/core/src')
-rw-r--r-- | test/core/src/lombok/AbstractRunTests.java | 16 | ||||
-rw-r--r-- | test/core/src/lombok/LombokTestSource.java | 16 |
2 files changed, 26 insertions, 6 deletions
diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java index db515f0e..9b256b36 100644 --- a/test/core/src/lombok/AbstractRunTests.java +++ b/test/core/src/lombok/AbstractRunTests.java @@ -36,9 +36,12 @@ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; +import org.junit.Assert; + import lombok.core.AST; import lombok.core.LombokConfiguration; import lombok.core.LombokImmutableList; +import lombok.core.configuration.ConfigurationKeysLoader; import lombok.core.configuration.ConfigurationResolver; import lombok.core.configuration.ConfigurationResolverFactory; import lombok.javac.CapturingDiagnosticListener.CompilerMessage; @@ -51,8 +54,9 @@ public abstract class AbstractRunTests { } public boolean compareFile(DirectoryRunner.TestParams params, File file) throws Throwable { + ConfigurationKeysLoader.LoaderLoader.loadAllConfigurationKeys(); final LombokTestSource sourceDirectives = LombokTestSource.readDirectives(file); - if (sourceDirectives.isIgnore()) return false; + if (sourceDirectives.isIgnore() || !sourceDirectives.versionWithinLimit(params.getVersion())) return false; String fileName = file.getName(); LombokTestSource expected = LombokTestSource.read(params.getAfterDirectory(), params.getMessagesDirectory(), fileName); @@ -70,7 +74,7 @@ public abstract class AbstractRunTests { transformCode(messages, writer, file); - compare(file.getName(), expected, writer.toString(), messages, params.printErrors()); + compare(file.getName(), expected, writer.toString(), messages, params.printErrors(), sourceDirectives.isSkipCompareContent() || expected.isSkipCompareContent()); return true; } @@ -124,8 +128,8 @@ public abstract class AbstractRunTests { } } - private void compare(String name, LombokTestSource expected, String actualFile, LinkedHashSet<CompilerMessage> actualMessages, boolean printErrors) throws Throwable { - if (expected.getContent() != null) try { + private void compare(String name, LombokTestSource expected, String actualFile, LinkedHashSet<CompilerMessage> actualMessages, boolean printErrors, boolean skipCompareContent) throws Throwable { + if (!skipCompareContent) try { compareContent(name, expected.getContent(), actualFile); } catch (Throwable e) { if (printErrors) { @@ -209,7 +213,9 @@ public abstract class AbstractRunTests { actualLines = removeBlanks(actualLines); int size = Math.min(expectedLines.length, actualLines.length); - if (size == 0) return; + if (size == 0 && expectedLines.length + actualLines.length > 0) { + Assert.fail("Missing / empty expected file."); + } for (int i = 0; i < size; i++) { String expected = expectedLines[i]; diff --git a/test/core/src/lombok/LombokTestSource.java b/test/core/src/lombok/LombokTestSource.java index 0cd09707..318c5885 100644 --- a/test/core/src/lombok/LombokTestSource.java +++ b/test/core/src/lombok/LombokTestSource.java @@ -46,6 +46,7 @@ public class LombokTestSource { private final String content; private final LombokImmutableList<CompilerMessageMatcher> messages; private final boolean ignore; + private final boolean skipCompareContent; private final int versionLowerLimit, versionUpperLimit; private final ConfigurationResolver configuration; @@ -69,6 +70,10 @@ public class LombokTestSource { return ignore; } + public boolean isSkipCompareContent() { + return skipCompareContent; + } + public ConfigurationResolver getConfiguration() { return configuration; } @@ -105,7 +110,9 @@ public class LombokTestSource { return null; } - private static final Pattern IGNORE_PATTERN = Pattern.compile("^\\s*ignore\\s*(?:[:-].*)?$", Pattern.CASE_INSENSITIVE); + private static final Pattern IGNORE_PATTERN = Pattern.compile("^\\s*ignore\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE); + private static final Pattern SKIP_COMPARE_CONTENT_PATTERN = Pattern.compile("^\\s*skip[- ]?compare[- ]?content\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE); + private LombokTestSource(File file, String content, List<CompilerMessageMatcher> messages, List<String> directives) { this.file = file; this.content = content; @@ -115,6 +122,7 @@ public class LombokTestSource { int versionLower = 0; int versionUpper = Integer.MAX_VALUE; boolean ignore = false; + boolean skipCompareContent = false; for (String directive : directives) { directive = directive.trim(); @@ -124,6 +132,11 @@ public class LombokTestSource { continue; } + if (SKIP_COMPARE_CONTENT_PATTERN.matcher(directive).matches()) { + skipCompareContent = true; + continue; + } + if (lc.startsWith("version ")) { int[] limits = parseVersionLimit(lc.substring(7).trim()); if (limits == null) { @@ -148,6 +161,7 @@ public class LombokTestSource { this.versionLowerLimit = versionLower; this.versionUpperLimit = versionUpper; this.ignore = ignore; + this.skipCompareContent = skipCompareContent; 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 + ")"); |