aboutsummaryrefslogtreecommitdiff
path: root/test/core/src/lombok
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/src/lombok')
-rw-r--r--test/core/src/lombok/AbstractRunTests.java5
-rw-r--r--test/core/src/lombok/LombokTestSource.java19
-rw-r--r--test/core/src/lombok/RunTestsViaDelombok.java4
-rw-r--r--test/core/src/lombok/RunTestsViaEcj.java2
4 files changed, 26 insertions, 4 deletions
diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java
index 85d4d4f3..4e1c83dd 100644
--- a/test/core/src/lombok/AbstractRunTests.java
+++ b/test/core/src/lombok/AbstractRunTests.java
@@ -35,6 +35,7 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import org.junit.Assert;
@@ -75,7 +76,7 @@ public abstract class AbstractRunTests {
}
});
- transformCode(messages, writer, file, sourceDirectives.getSpecifiedEncoding());
+ transformCode(messages, writer, file, sourceDirectives.getSpecifiedEncoding(), sourceDirectives.getFormatPreferences());
compare(file.getName(), expected, writer.toString(), messages, params.printErrors(), sourceDirectives.isSkipCompareContent() || expected.isSkipCompareContent());
return true;
@@ -97,7 +98,7 @@ public abstract class AbstractRunTests {
return 8;
}
- protected abstract void transformCode(Collection<CompilerMessage> messages, StringWriter result, File file, String encoding) throws Throwable;
+ protected abstract void transformCode(Collection<CompilerMessage> messages, StringWriter result, File file, String encoding, Map<String, String> formatPreferences) throws Throwable;
protected String readFile(File file) throws IOException {
BufferedReader reader;
diff --git a/test/core/src/lombok/LombokTestSource.java b/test/core/src/lombok/LombokTestSource.java
index f31d7be7..9b5607ef 100644
--- a/test/core/src/lombok/LombokTestSource.java
+++ b/test/core/src/lombok/LombokTestSource.java
@@ -29,7 +29,9 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -45,6 +47,7 @@ public class LombokTestSource {
private final File file;
private final String content;
private final LombokImmutableList<CompilerMessageMatcher> messages;
+ private final Map<String, String> formatPreferences;
private final boolean ignore;
private final boolean skipCompareContent;
private final int versionLowerLimit, versionUpperLimit;
@@ -83,6 +86,10 @@ public class LombokTestSource {
return configuration;
}
+ public Map<String, String> getFormatPreferences() {
+ return formatPreferences;
+ }
+
private static final Pattern VERSION_STYLE_1 = Pattern.compile("^(\\d+)$");
private static final Pattern VERSION_STYLE_2 = Pattern.compile("^\\:(\\d+)$");
private static final Pattern VERSION_STYLE_3 = Pattern.compile("^(\\d+):$");
@@ -129,6 +136,7 @@ public class LombokTestSource {
boolean ignore = false;
boolean skipCompareContent = false;
String encoding = null;
+ Map<String, String> formats = new HashMap<String, String>();
for (String directive : directives) {
directive = directive.trim();
@@ -165,6 +173,16 @@ public class LombokTestSource {
continue;
}
+ if (lc.startsWith("format:")) {
+ String formatLine = directive.substring(7).trim();
+ int idx = formatLine.indexOf('=');
+ if (idx == -1) throw new IllegalArgumentException("To add a format directive, use: \"//FORMAT: javaLangAsFQN = skip\"");
+ String key = formatLine.substring(0, idx).trim();
+ String value = formatLine.substring(idx + 1).trim();
+ formats.put(key.toLowerCase(), value);
+ continue;
+ }
+
Assert.fail("Directive line \"" + directive + "\" in '" + file.getAbsolutePath() + "' invalid: unrecognized directive.");
throw new RuntimeException();
}
@@ -180,6 +198,7 @@ public class LombokTestSource {
};
this.configuration = new BubblingConfigurationResolver(Collections.singleton(StringConfigurationSource.forString(conf, reporter, file.getAbsolutePath())));
+ this.formatPreferences = Collections.unmodifiableMap(formats);
}
public static LombokTestSource readDirectives(File file) throws IOException {
diff --git a/test/core/src/lombok/RunTestsViaDelombok.java b/test/core/src/lombok/RunTestsViaDelombok.java
index 1482c865..8ec41ef1 100644
--- a/test/core/src/lombok/RunTestsViaDelombok.java
+++ b/test/core/src/lombok/RunTestsViaDelombok.java
@@ -25,6 +25,7 @@ import java.io.File;
import java.io.StringWriter;
import java.util.Collection;
import java.util.Locale;
+import java.util.Map;
import lombok.delombok.Delombok;
import lombok.javac.CapturingDiagnosticListener;
@@ -34,10 +35,11 @@ public class RunTestsViaDelombok extends AbstractRunTests {
private Delombok delombok = new Delombok();
@Override
- public void transformCode(Collection<CompilerMessage> messages, StringWriter result, final File file, String encoding) throws Throwable {
+ public void transformCode(Collection<CompilerMessage> messages, StringWriter result, final File file, String encoding, Map<String, String> formatPreferences) throws Throwable {
delombok.setVerbose(false);
delombok.setForceProcess(true);
delombok.setCharset(encoding == null ? "UTF-8" : encoding);
+ delombok.setFormatPreferences(formatPreferences);
delombok.setDiagnosticsListener(new CapturingDiagnosticListener(file, messages));
diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java
index 74fe6e92..1571f401 100644
--- a/test/core/src/lombok/RunTestsViaEcj.java
+++ b/test/core/src/lombok/RunTestsViaEcj.java
@@ -93,7 +93,7 @@ public class RunTestsViaEcj extends AbstractRunTests {
}
@Override
- public void transformCode(Collection<CompilerMessage> messages, StringWriter result, File file, String encoding) throws Throwable {
+ public void transformCode(Collection<CompilerMessage> messages, StringWriter result, File file, String encoding, Map<String, String> formatPreferences) throws Throwable {
final AtomicReference<CompilationResult> compilationResult_ = new AtomicReference<CompilationResult>();
final AtomicReference<CompilationUnitDeclaration> compilationUnit_ = new AtomicReference<CompilationUnitDeclaration>();
ICompilerRequestor bitbucketRequestor = new ICompilerRequestor() {