Skip to content

Commit 9091fb6

Browse files
committed
Make it obvious that test files are deleted correctly
1 parent afd9ad3 commit 9091fb6

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/test/java/DiffTreeParserTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ public void testCase(Path testCasePath) throws IOException, DiffParseException {
7777
var expectedFile = Files.newBufferedReader(expectedPath);
7878
var actualFile = Files.newBufferedReader(actualPath);
7979
) {
80-
if (!IOUtils.contentEqualsIgnoreEOL(expectedFile, actualFile)) {
80+
if (IOUtils.contentEqualsIgnoreEOL(expectedFile, actualFile)) {
81+
// Delete output files if the test succeeded
82+
Files.delete(actualPath);
83+
} else {
84+
// Keep output files if the test failed
8185
var visualizationPath = testDir.resolve("tex").resolve(basename + ".tex");
8286
new TikzExporter(new Format(new FullNodeFormat(), new DefaultEdgeLabelFormat()))
8387
.exportFullLatexExample(diffTree, visualizationPath);
8488
fail("The DiffTree in file " + testCasePath + " didn't parse correctly. "
8589
+ "Expected the content of " + expectedPath + " but got the content of " + actualPath + ". "
8690
+ "Note: A visualisation is available at " + visualizationPath);
87-
// Keep output files if the test failed
88-
} else {
89-
// Delete output files if the test succeeded
90-
Files.delete(actualPath);
9191
}
9292
}
9393
}

src/test/java/TreeDiffing.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ public void testCase(TestCase testCase) throws IOException, DiffParseException {
8888
var expectedFile = Files.newBufferedReader(testCase.expected());
8989
var actualFile = Files.newBufferedReader(testCase.actual());
9090
) {
91-
if (!IOUtils.contentEqualsIgnoreEOL(expectedFile, actualFile)) {
91+
if (IOUtils.contentEqualsIgnoreEOL(expectedFile, actualFile)) {
92+
// Delete output files if the test succeeded
93+
Files.delete(testCase.actual());
94+
} else {
95+
// Keep output files if the test failed
9296
new TikzExporter(new Format(new FullNodeFormat(), new DefaultEdgeLabelFormat()))
9397
.exportFullLatexExample(diffTree, testCase.visualisation());
9498
fail(String.format(
@@ -101,10 +105,6 @@ public void testCase(TestCase testCase) throws IOException, DiffParseException {
101105
testCase.actual(),
102106
testCase.visualisation()
103107
));
104-
// Keep output files if the test failed
105-
} else {
106-
// Delete output files if the test succeeded
107-
Files.delete(testCase.actual());
108108
}
109109
}
110110
}

0 commit comments

Comments
 (0)