aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/core/src/lombok/AbstractRunTests.java25
-rw-r--r--test/core/src/lombok/LombokTestSource.java2
-rw-r--r--test/transform/resource/before/VarWarning.java10
-rw-r--r--test/transform/resource/messages-delombok/VarWarning.java.messages1
-rw-r--r--test/transform/resource/messages-ecj/VarWarning.java.messages1
5 files changed, 30 insertions, 9 deletions
diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java
index f564d0dc..d044a39f 100644
--- a/test/core/src/lombok/AbstractRunTests.java
+++ b/test/core/src/lombok/AbstractRunTests.java
@@ -57,10 +57,16 @@ public abstract class AbstractRunTests {
public final FileTester createTester(final DirectoryRunner.TestParams params, final File file) throws IOException {
ConfigurationKeysLoader.LoaderLoader.loadAllConfigurationKeys();
- final LombokTestSource sourceDirectives = LombokTestSource.readDirectives(file);
- if (sourceDirectives.isIgnore()) return null;
- if (!sourceDirectives.versionWithinLimit(params.getVersion())) return null;
- if (!sourceDirectives.versionWithinLimit(getClasspathVersion())) return null;
+ AssertionError directiveFailure = null;
+ LombokTestSource sourceDirectives = null;
+ try {
+ sourceDirectives = LombokTestSource.readDirectives(file);
+ if (sourceDirectives.isIgnore()) return null;
+ if (!sourceDirectives.versionWithinLimit(params.getVersion())) return null;
+ if (!sourceDirectives.versionWithinLimit(getClasspathVersion())) return null;
+ } catch (AssertionError ae) {
+ directiveFailure = ae;
+ }
String fileName = file.getName();
final LombokTestSource expected = LombokTestSource.read(params.getAfterDirectory(), params.getMessagesDirectory(), fileName);
@@ -68,23 +74,26 @@ public abstract class AbstractRunTests {
if (expected.isIgnore()) return null;
if (!expected.versionWithinLimit(params.getVersion())) return null;
+ final LombokTestSource sourceDirectives_ = sourceDirectives;
+ final AssertionError directiveFailure_ = directiveFailure;
return new FileTester() {
@Override public void runTest() throws Throwable {
+ if (directiveFailure_ != null) throw directiveFailure_;
LinkedHashSet<CompilerMessage> messages = new LinkedHashSet<CompilerMessage>();
StringWriter writer = new StringWriter();
LombokConfiguration.overrideConfigurationResolverFactory(new ConfigurationResolverFactory() {
@Override public ConfigurationResolver createResolver(AST<?, ?, ?> ast) {
- return sourceDirectives.getConfiguration();
+ return sourceDirectives_.getConfiguration();
}
});
- boolean changed = transformCode(messages, writer, file, sourceDirectives.getSpecifiedEncoding(), sourceDirectives.getFormatPreferences());
- boolean forceUnchanged = sourceDirectives.forceUnchanged() || sourceDirectives.isSkipCompareContent();
+ boolean changed = transformCode(messages, writer, file, sourceDirectives_.getSpecifiedEncoding(), sourceDirectives_.getFormatPreferences());
+ boolean forceUnchanged = sourceDirectives_.forceUnchanged() || sourceDirectives_.isSkipCompareContent();
if (params.expectChanges() && !forceUnchanged && !changed) messages.add(new CompilerMessage(-1, -1, true, "not flagged modified"));
if (!params.expectChanges() && changed) messages.add(new CompilerMessage(-1, -1, true, "unexpected modification"));
- compare(file.getName(), expected, writer.toString(), messages, params.printErrors(), sourceDirectives.isSkipCompareContent() || expected.isSkipCompareContent());
+ compare(file.getName(), expected, writer.toString(), messages, params.printErrors(), sourceDirectives_.isSkipCompareContent() || expected.isSkipCompareContent());
}
};
}
diff --git a/test/core/src/lombok/LombokTestSource.java b/test/core/src/lombok/LombokTestSource.java
index cd7cd166..16f9f49f 100644
--- a/test/core/src/lombok/LombokTestSource.java
+++ b/test/core/src/lombok/LombokTestSource.java
@@ -130,7 +130,7 @@ public class LombokTestSource {
private static final Pattern IGNORE_PATTERN = Pattern.compile("^\\s*ignore\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE);
private static final Pattern UNCHANGED_PATTERN = Pattern.compile("^\\s*unchanged\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE);
- private static final Pattern SKIP_COMPARE_CONTENT_PATTERN = Pattern.compile("^\\s*skip[- ]?compare[- ]?content\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE);
+ private static final Pattern SKIP_COMPARE_CONTENT_PATTERN = Pattern.compile("^\\s*skip[- ]?compare[- ]?contents?\\s*(?:[-:].*)?$", Pattern.CASE_INSENSITIVE);
private LombokTestSource(File file, String content, List<CompilerMessageMatcher> messages, List<String> directives) {
this.file = file;
diff --git a/test/transform/resource/before/VarWarning.java b/test/transform/resource/before/VarWarning.java
new file mode 100644
index 00000000..85559587
--- /dev/null
+++ b/test/transform/resource/before/VarWarning.java
@@ -0,0 +1,10 @@
+//CONF: lombok.var.flagUsage = WARNING
+//skip compare contents
+import lombok.experimental.var;
+
+public class VarWarning {
+ public void isOkay() {
+ var x = "Warning";
+ x.toLowerCase();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/messages-delombok/VarWarning.java.messages b/test/transform/resource/messages-delombok/VarWarning.java.messages
new file mode 100644
index 00000000..48c89581
--- /dev/null
+++ b/test/transform/resource/messages-delombok/VarWarning.java.messages
@@ -0,0 +1 @@
+7 Use of var is flagged according to lombok configuration \ No newline at end of file
diff --git a/test/transform/resource/messages-ecj/VarWarning.java.messages b/test/transform/resource/messages-ecj/VarWarning.java.messages
new file mode 100644
index 00000000..48c89581
--- /dev/null
+++ b/test/transform/resource/messages-ecj/VarWarning.java.messages
@@ -0,0 +1 @@
+7 Use of var is flagged according to lombok configuration \ No newline at end of file