Skip to content

Commit

Permalink
@ F add approval-all script to temp directory
Browse files Browse the repository at this point in the history
Co-authored-by: Jay Bazuzi <[email protected]>
Co-authored-by: Llewellyn Falco <[email protected]>
  • Loading branch information
3 people committed Jan 13, 2025
1 parent bc2c99b commit e21060c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
32 changes: 32 additions & 0 deletions approvaltests/src/main/java/org/approvaltests/FailedFileLog.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.approvaltests;

import com.spun.util.SystemUtils;
import com.spun.util.io.FileUtils;
import com.spun.util.io.NetUtils;

import java.io.File;

Expand All @@ -11,6 +13,36 @@ public class FailedFileLog
static
{
FileUtils.writeFile(get(), "");
downloadApproveAllScriptIfMissing();
}
private static void downloadApproveAllScriptIfMissing()
{
try
{
if (SystemUtils.isWindowsEnvironment())
{
String url = "https://raw.githubusercontent.com/approvals/ApprovalTests.Java/refs/heads/master/resources/approve_all.bat";
File batScript = new File(APPROVAL_TEMP_DIRECTORY + "/approve_all.bat");
if (!batScript.exists())
{
FileUtils.writeFile(batScript, NetUtils.loadWebPage(url, null));
}
}
else
{
String url = "https://raw.githubusercontent.com/approvals/ApprovalTests.Java/refs/heads/master/resources/approve_all.sh";
File bashScript = new File(APPROVAL_TEMP_DIRECTORY + "/approve_all.sh");
if (!bashScript.exists())
{
FileUtils.writeFile(bashScript, NetUtils.loadWebPage(url, null));
bashScript.setExecutable(true);
}
}
}
catch (Exception e)
{
// do nothing
}
}
public static File get()
{
Expand Down
4 changes: 2 additions & 2 deletions resources/approve_all.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off

FOR /F "usebackq delims=" %%L IN ("..\approvaltests-tests\.approval_tests_temp\.failed_comparison.log") DO (
FOR /F "usebackq delims=" %%L IN ("..\.approval_tests_temp\.failed_comparison.log") DO (
REM Store the entire line in an environment variable named LINE
SET "LINE=%%L"
REM Call a subroutine to parse and handle the line
Expand All @@ -23,4 +23,4 @@ GOTO :EOF
)

ENDLOCAL
GOTO :EOF
GOTO :EOF
4 changes: 2 additions & 2 deletions resources/approve_all.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash


LOGFILE="../approvaltests-tests/.approval_tests_temp/.failed_comparison.log"
LOGFILE="../.approval_tests_temp/.failed_comparison.log"

while IFS= read -r line; do
# 1) Parse the line to get source (before '->') and destination (after '->')
Expand All @@ -17,4 +17,4 @@ while IFS= read -r line; do
# 3) Perform the move
echo "Moving '$src' to '$dst'"
mv "$src" "$dst"
done < "$LOGFILE"
done < "$LOGFILE"

0 comments on commit e21060c

Please sign in to comment.