aboutsummaryrefslogtreecommitdiff
path: root/test/core/src/lombok/AbstractRunTests.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/src/lombok/AbstractRunTests.java')
-rw-r--r--test/core/src/lombok/AbstractRunTests.java48
1 files changed, 26 insertions, 22 deletions
diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java
index 85c3674f..f564d0dc 100644
--- a/test/core/src/lombok/AbstractRunTests.java
+++ b/test/core/src/lombok/AbstractRunTests.java
@@ -39,6 +39,7 @@ import java.util.Map;
import org.junit.Assert;
+import lombok.DirectoryRunner.FileTester;
import lombok.core.AST;
import lombok.core.LombokConfiguration;
import lombok.core.LombokImmutableList;
@@ -54,35 +55,38 @@ public abstract class AbstractRunTests {
this.dumpActualFilesHere = findPlaceToDumpActualFiles();
}
- public boolean compareFile(DirectoryRunner.TestParams params, File file) throws Throwable {
+ 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 false;
- if (!sourceDirectives.versionWithinLimit(params.getVersion())) return false;
- if (!sourceDirectives.versionWithinLimit(getClasspathVersion())) return false;
+ if (sourceDirectives.isIgnore()) return null;
+ if (!sourceDirectives.versionWithinLimit(params.getVersion())) return null;
+ if (!sourceDirectives.versionWithinLimit(getClasspathVersion())) return null;
String fileName = file.getName();
- LombokTestSource expected = LombokTestSource.read(params.getAfterDirectory(), params.getMessagesDirectory(), fileName);
+ final LombokTestSource expected = LombokTestSource.read(params.getAfterDirectory(), params.getMessagesDirectory(), fileName);
- if (expected.isIgnore()) return false;
- if (!expected.versionWithinLimit(params.getVersion())) return false;
+ if (expected.isIgnore()) return null;
+ if (!expected.versionWithinLimit(params.getVersion())) return null;
- LinkedHashSet<CompilerMessage> messages = new LinkedHashSet<CompilerMessage>();
- StringWriter writer = new StringWriter();
-
- LombokConfiguration.overrideConfigurationResolverFactory(new ConfigurationResolverFactory() {
- @Override public ConfigurationResolver createResolver(AST<?, ?, ?> ast) {
- return sourceDirectives.getConfiguration();
+ return new FileTester() {
+ @Override public void runTest() throws Throwable {
+ LinkedHashSet<CompilerMessage> messages = new LinkedHashSet<CompilerMessage>();
+ StringWriter writer = new StringWriter();
+
+ LombokConfiguration.overrideConfigurationResolverFactory(new ConfigurationResolverFactory() {
+ @Override public ConfigurationResolver createResolver(AST<?, ?, ?> ast) {
+ return sourceDirectives.getConfiguration();
+ }
+ });
+
+ 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());
}
- });
-
- 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());
- return true;
+ };
}
private static int getClasspathVersion() {