Skip to content

Commit

Permalink
- F Added FailedFileLog
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottBob committed Jan 9, 2025
1 parent 8bfb04c commit cb76ba6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
30 changes: 30 additions & 0 deletions approvaltests/src/main/java/org/approvaltests/FailedFileLog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.approvaltests;

import com.spun.util.io.FileUtils;

import java.io.File;

import static org.approvaltests.ApprovedFileLog.APPROVAL_TEMP_DIRECTORY;

public class FailedFileLog
{
static
{
FileUtils.writeFile(get(), "");
}
public static File get()
{
File file = new File(APPROVAL_TEMP_DIRECTORY + "/.failed_comparison.log");
FileUtils.createIfNeeded(file.getAbsolutePath());
return file;
}
public static void log(File received, File approved)
{
File log = get();
FileUtils.appendToFile(log, String.format("%s -> %s\n", received.getAbsolutePath(), approved.getAbsolutePath()));
}

public static void touch() {
// Allows static initializer to be called
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.spun.util.ObjectUtils;
import com.spun.util.io.FileUtils;
import org.approvaltests.ApprovedFileLog;
import org.approvaltests.FailedFileLog;
import org.approvaltests.core.ApprovalFailureReporter;
import org.approvaltests.core.ApprovalReporterWithCleanUp;
import org.approvaltests.core.ApprovalWriter;
Expand Down Expand Up @@ -48,6 +49,7 @@ public VerifyResult approve()
{
tracker.assertUnique(approved.getAbsolutePath());
ApprovedFileLog.log(approved);
FailedFileLog.touch();
received = writer.writeReceivedFile(received);
return approver.call(received, approved);
}
Expand All @@ -61,6 +63,7 @@ public void cleanUpAfterSuccess(ApprovalFailureReporter reporter)
}
public VerifyResult reportFailure(ApprovalFailureReporter reporter)
{
FailedFileLog.log(received, approved);
reporter.report(received.getAbsolutePath(), approved.getAbsolutePath());
if (reporter instanceof ReporterWithApprovalPower)
{
Expand Down

0 comments on commit cb76ba6

Please sign in to comment.