aboutsummaryrefslogtreecommitdiff
path: root/test/core/src
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2014-01-12 00:10:24 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2014-01-18 18:55:53 +0100
commitc65ec9694305c8b577e36be64a8a60675251ef92 (patch)
treea474240d68b02b8d69b43a5fe73877328f935015 /test/core/src
parentf6da35e4c4f3305ecd1b415e2ab1b9ef8a9120b4 (diff)
downloadlombok-c65ec9694305c8b577e36be64a8a60675251ef92.tar.gz
lombok-c65ec9694305c8b577e36be64a8a60675251ef92.tar.bz2
lombok-c65ec9694305c8b577e36be64a8a60675251ef92.zip
[test-directives] another update to the 'test directives' system; test files now can start with directives (configuration keys, 'ignore', and java language version limits), and the test directory runner now has a framework to handle these. All existing tests pass at this point.
Diffstat (limited to 'test/core/src')
-rw-r--r--test/core/src/lombok/AbstractRunTests.java17
-rw-r--r--test/core/src/lombok/LombokTestSource.java20
2 files changed, 24 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);