Skip to content

Commit e21060c

Browse files
LarsEckartJayBazuziisidore
committed
@ F add approval-all script to temp directory
Co-authored-by: Jay Bazuzi <[email protected]> Co-authored-by: Llewellyn Falco <[email protected]>
1 parent bc2c99b commit e21060c

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

approvaltests/src/main/java/org/approvaltests/FailedFileLog.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.approvaltests;
22

3+
import com.spun.util.SystemUtils;
34
import com.spun.util.io.FileUtils;
5+
import com.spun.util.io.NetUtils;
46

57
import java.io.File;
68

@@ -11,6 +13,36 @@ public class FailedFileLog
1113
static
1214
{
1315
FileUtils.writeFile(get(), "");
16+
downloadApproveAllScriptIfMissing();
17+
}
18+
private static void downloadApproveAllScriptIfMissing()
19+
{
20+
try
21+
{
22+
if (SystemUtils.isWindowsEnvironment())
23+
{
24+
String url = "https://raw.githubusercontent.com/approvals/ApprovalTests.Java/refs/heads/master/resources/approve_all.bat";
25+
File batScript = new File(APPROVAL_TEMP_DIRECTORY + "/approve_all.bat");
26+
if (!batScript.exists())
27+
{
28+
FileUtils.writeFile(batScript, NetUtils.loadWebPage(url, null));
29+
}
30+
}
31+
else
32+
{
33+
String url = "https://raw.githubusercontent.com/approvals/ApprovalTests.Java/refs/heads/master/resources/approve_all.sh";
34+
File bashScript = new File(APPROVAL_TEMP_DIRECTORY + "/approve_all.sh");
35+
if (!bashScript.exists())
36+
{
37+
FileUtils.writeFile(bashScript, NetUtils.loadWebPage(url, null));
38+
bashScript.setExecutable(true);
39+
}
40+
}
41+
}
42+
catch (Exception e)
43+
{
44+
// do nothing
45+
}
1446
}
1547
public static File get()
1648
{

resources/approve_all.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@echo off
22

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

2525
ENDLOCAL
26-
GOTO :EOF
26+
GOTO :EOF

resources/approve_all.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33

4-
LOGFILE="../approvaltests-tests/.approval_tests_temp/.failed_comparison.log"
4+
LOGFILE="../.approval_tests_temp/.failed_comparison.log"
55

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

0 commit comments

Comments
 (0)