Skip to content

Commit cb76ba6

Browse files
committed
- F Added FailedFileLog
1 parent 8bfb04c commit cb76ba6

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.approvaltests;
2+
3+
import com.spun.util.io.FileUtils;
4+
5+
import java.io.File;
6+
7+
import static org.approvaltests.ApprovedFileLog.APPROVAL_TEMP_DIRECTORY;
8+
9+
public class FailedFileLog
10+
{
11+
static
12+
{
13+
FileUtils.writeFile(get(), "");
14+
}
15+
public static File get()
16+
{
17+
File file = new File(APPROVAL_TEMP_DIRECTORY + "/.failed_comparison.log");
18+
FileUtils.createIfNeeded(file.getAbsolutePath());
19+
return file;
20+
}
21+
public static void log(File received, File approved)
22+
{
23+
File log = get();
24+
FileUtils.appendToFile(log, String.format("%s -> %s\n", received.getAbsolutePath(), approved.getAbsolutePath()));
25+
}
26+
27+
public static void touch() {
28+
// Allows static initializer to be called
29+
}
30+
}

approvaltests/src/main/java/org/approvaltests/approvers/FileApprover.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.spun.util.ObjectUtils;
44
import com.spun.util.io.FileUtils;
55
import org.approvaltests.ApprovedFileLog;
6+
import org.approvaltests.FailedFileLog;
67
import org.approvaltests.core.ApprovalFailureReporter;
78
import org.approvaltests.core.ApprovalReporterWithCleanUp;
89
import org.approvaltests.core.ApprovalWriter;
@@ -48,6 +49,7 @@ public VerifyResult approve()
4849
{
4950
tracker.assertUnique(approved.getAbsolutePath());
5051
ApprovedFileLog.log(approved);
52+
FailedFileLog.touch();
5153
received = writer.writeReceivedFile(received);
5254
return approver.call(received, approved);
5355
}
@@ -61,6 +63,7 @@ public void cleanUpAfterSuccess(ApprovalFailureReporter reporter)
6163
}
6264
public VerifyResult reportFailure(ApprovalFailureReporter reporter)
6365
{
66+
FailedFileLog.log(received, approved);
6467
reporter.report(received.getAbsolutePath(), approved.getAbsolutePath());
6568
if (reporter instanceof ReporterWithApprovalPower)
6669
{

0 commit comments

Comments
 (0)