diff options
author | Roel Spilker <r.spilker@gmail.com> | 2015-11-17 01:41:23 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2015-11-17 01:41:23 +0100 |
commit | 8a504f8beec691b64d1c08f629520c2443821847 (patch) | |
tree | c25494ced45d6038a2c418c4b7ec3dc6f0d14e50 /test/core/src/lombok/AbstractRunTests.java | |
parent | 9eb70cb3e2043b5262e686b4a80da36e5aa88d81 (diff) | |
download | lombok-8a504f8beec691b64d1c08f629520c2443821847.tar.gz lombok-8a504f8beec691b64d1c08f629520c2443821847.tar.bz2 lombok-8a504f8beec691b64d1c08f629520c2443821847.zip |
handle ignored tests correctly
Diffstat (limited to 'test/core/src/lombok/AbstractRunTests.java')
-rw-r--r-- | test/core/src/lombok/AbstractRunTests.java | 48 |
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() { |