diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2012-07-16 22:22:57 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2012-07-16 22:22:57 +0200 |
commit | bd2d76bb546cf60ff8f36318fca4c2d0498d1d43 (patch) | |
tree | 5c3405ba57c0f1b4e97e6f200a1839d6632a621b /test/core | |
parent | e6421509987c01e06b7c79ef406cc01ff174ae81 (diff) | |
download | lombok-bd2d76bb546cf60ff8f36318fca4c2d0498d1d43.tar.gz lombok-bd2d76bb546cf60ff8f36318fca4c2d0498d1d43.tar.bz2 lombok-bd2d76bb546cf60ff8f36318fca4c2d0498d1d43.zip |
Added feature to test suite to dump actual result of running ecj / delombok on things to a directory (use -Dlombok.tests.dump_actual_files=/path/to/dir).
Useful if you KNOW lombok is working but something changed in output, i.e. order of generated methods.
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/src/lombok/AbstractRunTests.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/core/src/lombok/AbstractRunTests.java b/test/core/src/lombok/AbstractRunTests.java index b2200bbd..02c4803a 100644 --- a/test/core/src/lombok/AbstractRunTests.java +++ b/test/core/src/lombok/AbstractRunTests.java @@ -26,6 +26,7 @@ import static org.junit.Assert.*; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.StringReader; @@ -35,6 +36,11 @@ import java.util.List; public abstract class AbstractRunTests { protected static final String LINE_SEPARATOR = System.getProperty("line.separator"); + private final File dumpActualFilesHere; + + public AbstractRunTests() { + this.dumpActualFilesHere = findPlaceToDumpActualFiles(); + } public boolean compareFile(DirectoryRunner.TestParams params, File file) throws Throwable { StringBuilder messages = new StringBuilder(); @@ -82,6 +88,25 @@ public abstract class AbstractRunTests { return readFile(new File(dir, file.getName() + (messages ? ".messages" : ""))); } + private static File findPlaceToDumpActualFiles() { + String location = System.getProperty("lombok.tests.dump_actual_files"); + if (location != null) { + File dumpActualFilesHere = new File(location); + dumpActualFilesHere.mkdirs(); + return dumpActualFilesHere; + } + return null; + } + + private static void dumpToFile(File file, String content) throws IOException { + FileOutputStream fos = new FileOutputStream(file); + try { + fos.write(content.getBytes("UTF-8")); + } finally { + fos.close(); + } + } + private void compare(String name, String expectedFile, String actualFile, String expectedMessages, String actualMessages, boolean printErrors) throws Throwable { try { compareContent(name, expectedFile, actualFile); @@ -99,6 +124,9 @@ public abstract class AbstractRunTests { } System.out.println("*******************"); } + if (dumpActualFilesHere != null) { + dumpToFile(new File(dumpActualFilesHere, name), actualFile); + } throw e; } try { @@ -113,6 +141,9 @@ public abstract class AbstractRunTests { System.out.println(actualMessages); System.out.println("*******************"); } + if (dumpActualFilesHere != null) { + dumpToFile(new File(dumpActualFilesHere, name + ".messages"), actualMessages); + } throw e; } } |