diff options
Diffstat (limited to 'test')
11 files changed, 113 insertions, 14 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 + ")"); diff --git a/test/transform/resource/after-delombok/AccessorsConfiguration.java b/test/transform/resource/after-delombok/AccessorsConfiguration.java new file mode 100644 index 00000000..fd60b152 --- /dev/null +++ b/test/transform/resource/after-delombok/AccessorsConfiguration.java @@ -0,0 +1,26 @@ +class AccessorsConfiguration { + private String m_FieldName = ""; + @java.lang.SuppressWarnings("all") + public String fieldName() { + return this.m_FieldName; + } + @java.lang.SuppressWarnings("all") + public void fieldName(final String m_FieldName) { + this.m_FieldName = m_FieldName; + } +} +class AccessorsConfiguration2 { + private String m_FieldName = ""; + @java.lang.SuppressWarnings("all") + public void setM_FieldName(final String m_FieldName) { + this.m_FieldName = m_FieldName; + } +} +class AccessorsConfiguration3 { + private String fFieldName = ""; + @java.lang.SuppressWarnings("all") + public AccessorsConfiguration3 setFieldName(final String fFieldName) { + this.fFieldName = fFieldName; + return this; + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/AccessorsConfiguration.java b/test/transform/resource/after-ecj/AccessorsConfiguration.java new file mode 100644 index 00000000..6678e020 --- /dev/null +++ b/test/transform/resource/after-ecj/AccessorsConfiguration.java @@ -0,0 +1,31 @@ +class AccessorsConfiguration { + private @lombok.Getter @lombok.Setter @lombok.experimental.Accessors(fluent = true) String m_FieldName = ""; + AccessorsConfiguration() { + super(); + } + public @java.lang.SuppressWarnings("all") String fieldName() { + return this.m_FieldName; + } + public @java.lang.SuppressWarnings("all") void fieldName(final String m_FieldName) { + this.m_FieldName = m_FieldName; + } +} +@lombok.experimental.Accessors(prefix = {}) class AccessorsConfiguration2 { + private @lombok.Setter String m_FieldName = ""; + AccessorsConfiguration2() { + super(); + } + public @java.lang.SuppressWarnings("all") void setM_FieldName(final String m_FieldName) { + this.m_FieldName = m_FieldName; + } +} +@lombok.experimental.Accessors(chain = true) class AccessorsConfiguration3 { + private @lombok.Setter String fFieldName = ""; + AccessorsConfiguration3() { + super(); + } + public @java.lang.SuppressWarnings("all") AccessorsConfiguration3 setFieldName(final String fFieldName) { + this.fFieldName = fFieldName; + return this; + } +} diff --git a/test/transform/resource/before/AccessorsConfiguration.java b/test/transform/resource/before/AccessorsConfiguration.java new file mode 100644 index 00000000..187fd393 --- /dev/null +++ b/test/transform/resource/before/AccessorsConfiguration.java @@ -0,0 +1,20 @@ +//CONF: lombok.Accessors.prefix += m_ +//CONF: lombok.Accessors.prefix += f +//CONF: lombok.Accessors.chain = false + +class AccessorsConfiguration { + @lombok.Getter @lombok.Setter @lombok.experimental.Accessors(fluent=true) + private String m_FieldName = ""; +} + +@lombok.experimental.Accessors(prefix = {}) +class AccessorsConfiguration2 { + @lombok.Setter + private String m_FieldName = ""; +} + +@lombok.experimental.Accessors(chain = true) +class AccessorsConfiguration3 { + @lombok.Setter + private String fFieldName = ""; +} diff --git a/test/transform/resource/before/BuilderInvalidUse.java b/test/transform/resource/before/BuilderInvalidUse.java index 07f37d3d..d7052e1e 100644 --- a/test/transform/resource/before/BuilderInvalidUse.java +++ b/test/transform/resource/before/BuilderInvalidUse.java @@ -1,3 +1,4 @@ +//skip compare content @lombok.experimental.Builder class BuilderInvalidUse { private int something; diff --git a/test/transform/resource/before/FlagUsages.java b/test/transform/resource/before/FlagUsages.java index 8fc8b306..6631224f 100644 --- a/test/transform/resource/before/FlagUsages.java +++ b/test/transform/resource/before/FlagUsages.java @@ -1,3 +1,4 @@ +//skip compare content //CONF: lombok.Getter.flagUsage = WARNING //CONF: lombok.experimental.flagUsage = ERROR public class FlagUsages { diff --git a/test/transform/resource/messages-delombok/BuilderInvalidUse.java.messages b/test/transform/resource/messages-delombok/BuilderInvalidUse.java.messages index a04b4f9b..506a3426 100644 --- a/test/transform/resource/messages-delombok/BuilderInvalidUse.java.messages +++ b/test/transform/resource/messages-delombok/BuilderInvalidUse.java.messages @@ -1,2 +1,2 @@ -1 @Getter, @Setter, @Wither, @Data, @ToString, @EqualsAndHashCode, @AllArgsConstructor are not allowed on builder classes. -12 @Value is not allowed on builder classes.
\ No newline at end of file +2 @Getter, @Setter, @Wither, @Data, @ToString, @EqualsAndHashCode, @AllArgsConstructor are not allowed on builder classes. +13 @Value is not allowed on builder classes.
\ No newline at end of file diff --git a/test/transform/resource/messages-delombok/FlagUsages.java.messages b/test/transform/resource/messages-delombok/FlagUsages.java.messages index 79cb456b..13a148b1 100644 --- a/test/transform/resource/messages-delombok/FlagUsages.java.messages +++ b/test/transform/resource/messages-delombok/FlagUsages.java.messages @@ -1,2 +1,2 @@ -4 Use of @Getter is flagged according to lombok configuration. -6 Use of any lombok.experimental feature is flagged according to lombok configuration. +5 Use of @Getter is flagged according to lombok configuration. +7 Use of any lombok.experimental feature is flagged according to lombok configuration. diff --git a/test/transform/resource/messages-ecj/BuilderInvalidUse.java.messages b/test/transform/resource/messages-ecj/BuilderInvalidUse.java.messages index 84942101..c5571b92 100644 --- a/test/transform/resource/messages-ecj/BuilderInvalidUse.java.messages +++ b/test/transform/resource/messages-ecj/BuilderInvalidUse.java.messages @@ -1,2 +1,2 @@ -1 @Getter, @Setter, @FieldDefaults, @Wither, @Data, @ToString, @EqualsAndHashCode, @AllArgsConstructor are not allowed on builder classes. -12 @Value is not allowed on builder classes.
\ No newline at end of file +2 @Getter, @Setter, @FieldDefaults, @Wither, @Data, @ToString, @EqualsAndHashCode, @AllArgsConstructor are not allowed on builder classes. +13 @Value is not allowed on builder classes.
\ No newline at end of file diff --git a/test/transform/resource/messages-ecj/FlagUsages.java.messages b/test/transform/resource/messages-ecj/FlagUsages.java.messages index 79cb456b..13a148b1 100644 --- a/test/transform/resource/messages-ecj/FlagUsages.java.messages +++ b/test/transform/resource/messages-ecj/FlagUsages.java.messages @@ -1,2 +1,2 @@ -4 Use of @Getter is flagged according to lombok configuration. -6 Use of any lombok.experimental feature is flagged according to lombok configuration. +5 Use of @Getter is flagged according to lombok configuration. +7 Use of any lombok.experimental feature is flagged according to lombok configuration. |