aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/core/src/lombok/AbstractRunTests.java17
-rw-r--r--test/core/src/lombok/LombokTestSource.java20
-rw-r--r--test/transform/resource/after-ecj/ValInTryWithResources.java1
3 files changed, 25 insertions, 13 deletions
diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java
index 91f22502..64956c7f 100644
--- a/test/core/src/lombok/AbstractRunTests.java
+++ b/test/core/src/lombok/AbstractRunTests.java
@@ -53,14 +53,13 @@ public abstract class AbstractRunTests {
String fileName = file.getName();
LombokTestSource expected = LombokTestSource.read(params.getAfterDirectory(), params.getMessagesDirectory(), fileName);
- if (expected.isIgnore() || expected.versionWithinLimit(params.getVersion())) return false;
+ if (expected.isIgnore() || !expected.versionWithinLimit(params.getVersion())) return false;
LinkedHashSet<CompilerMessage> messages = new LinkedHashSet<CompilerMessage>();
StringWriter writer = new StringWriter();
transformCode(messages, writer, file, sourceDirectives.getConfLines());
compare(file.getName(), expected, writer.toString(), messages, params.printErrors());
-
return true;
}
@@ -186,15 +185,21 @@ public abstract class AbstractRunTests {
private static void compareContent(String name, String expectedFile, String actualFile) {
String[] expectedLines = expectedFile.split("(\\r?\\n)");
String[] actualLines = actualFile.split("(\\r?\\n)");
- if (expectedLines[0].startsWith("// Generated by delombok at ")) {
- expectedLines[0] = "";
+
+ for (int i = 0; i < expectedLines.length; i++) {
+ if (expectedLines[i].isEmpty() || expectedLines[i].startsWith("//")) expectedLines[i] = "";
+ else break;
}
- if (actualLines[0].startsWith("// Generated by delombok at ")) {
- actualLines[0] = "";
+ for (int i = 0; i < actualLines.length; i++) {
+ if (actualLines[i].isEmpty() || actualLines[i].startsWith("//")) actualLines[i] = "";
+ else break;
}
expectedLines = removeBlanks(expectedLines);
actualLines = removeBlanks(actualLines);
+
int size = Math.min(expectedLines.length, actualLines.length);
+ if (size == 0) return;
+
for (int i = 0; i < size; i++) {
String expected = expectedLines[i];
String actual = actualLines[i];
diff --git a/test/core/src/lombok/LombokTestSource.java b/test/core/src/lombok/LombokTestSource.java
index e4174c08..1ad92109 100644
--- a/test/core/src/lombok/LombokTestSource.java
+++ b/test/core/src/lombok/LombokTestSource.java
@@ -24,6 +24,7 @@ package lombok;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
@@ -99,6 +100,7 @@ public class LombokTestSource {
return null;
}
+ private static final Pattern IGNORE_PATTERN = Pattern.compile("^\\s*ignore\\s*(?:[:-].*)?$", Pattern.CASE_INSENSITIVE);
private LombokTestSource(File file, String content, List<CompilerMessageMatcher> messages, List<String> directives) {
this.file = file;
this.content = content;
@@ -112,7 +114,7 @@ public class LombokTestSource {
for (String directive : directives) {
directive = directive.trim();
String lc = directive.toLowerCase();
- if (lc.equals("ignore")) {
+ if (IGNORE_PATTERN.matcher(directive).matches()) {
ignore = true;
continue;
}
@@ -191,16 +193,20 @@ public class LombokTestSource {
}
in.close();
rawIn.close();
- } else {
- content = new StringBuilder();
}
+ if (content == null) content = new StringBuilder();
+
List<CompilerMessageMatcher> messages = null;
if (messagesFolder != null) {
- File messagesFile = new File(messagesFolder, fileName);
- @Cleanup val rawIn = new FileInputStream(messagesFile);
- messages = CompilerMessageMatcher.readAll(rawIn);
- rawIn.close();
+ File messagesFile = new File(messagesFolder, fileName + ".messages");
+ try {
+ @Cleanup val rawIn = new FileInputStream(messagesFile);
+ messages = CompilerMessageMatcher.readAll(rawIn);
+ rawIn.close();
+ } catch (FileNotFoundException e) {
+ messages = null;
+ }
}
return new LombokTestSource(sourceFile, content.toString(), messages, directives);
diff --git a/test/transform/resource/after-ecj/ValInTryWithResources.java b/test/transform/resource/after-ecj/ValInTryWithResources.java
new file mode 100644
index 00000000..5b354bdf
--- /dev/null
+++ b/test/transform/resource/after-ecj/ValInTryWithResources.java
@@ -0,0 +1 @@
+//ignore: This is a J7 feature that isn't turned on in the ecj variant we use to run the tests. We need to update that ecj at some point and enable this test. \ No newline at end of file