File tree Expand file tree Collapse file tree 6 files changed +43
-28
lines changed
approvaltests-tests/src/test/java/org/approvaltests
approvaltests/src/main/java/org/approvaltests Expand file tree Collapse file tree 6 files changed +43
-28
lines changed Original file line number Diff line number Diff line change 11package org .approvaltests ;
22
33import com .spun .util .io .FileUtils ;
4+ import org .approvaltests .internal .logs .ApprovedFileLog ;
45import org .approvaltests .namer .ApprovalNamer ;
56import org .junit .Assert ;
67import org .junit .jupiter .api .Test ;
Original file line number Diff line number Diff line change 22
33import com .spun .util .ObjectUtils ;
44import com .spun .util .io .FileUtils ;
5- import org .approvaltests .ApprovedFileLog ;
6- import org .approvaltests .FailedFileLog ;
5+ import org .approvaltests .internal . logs . ApprovedFileLog ;
6+ import org .approvaltests .internal . logs . FailedFileLog ;
77import org .approvaltests .core .ApprovalFailureReporter ;
88import org .approvaltests .core .ApprovalReporterWithCleanUp ;
99import org .approvaltests .core .ApprovalWriter ;
Original file line number Diff line number Diff line change 1- package org .approvaltests ;
1+ package org .approvaltests . internal . logs ;
22
33import com .spun .util .io .FileUtils ;
44
55import java .io .File ;
66
77public class ApprovedFileLog
88{
9- public static final String APPROVAL_TEMP_DIRECTORY = ".approval_tests_temp" ;
109 static
1110 {
1211 FileUtils .writeFile (get (), "" );
1312 }
1413 public static File get ()
1514 {
16- File file = new File (APPROVAL_TEMP_DIRECTORY + "/.approved_files.log" );
15+ File file = new File (LoggingUtils . APPROVAL_TEMP_DIRECTORY + "/.approved_files.log" );
1716 FileUtils .createIfNeeded (file .getAbsolutePath ());
1817 return file ;
1918 }
Original file line number Diff line number Diff line change 1- package org .approvaltests ;
1+ package org .approvaltests . internal . logs ;
22
3- import com .spun .util .SystemUtils ;
43import com .spun .util .io .FileUtils ;
5- import com .spun .util .io .NetUtils ;
64
75import java .io .File ;
86
9- import static org .approvaltests .ApprovedFileLog .APPROVAL_TEMP_DIRECTORY ;
7+ import static org .approvaltests .internal . logs . LoggingUtils .APPROVAL_TEMP_DIRECTORY ;
108
119public class FailedFileLog
1210{
@@ -20,22 +18,8 @@ private static void downloadApproveAllScriptIfMissing()
2018 if (downloadedScriptCheck )
2119 { return ; }
2220 downloadedScriptCheck = true ;
23- try
24- {
25- String extension = SystemUtils .isWindowsEnvironment () ? ".bat" : ".sh" ;
26- File script = new File (APPROVAL_TEMP_DIRECTORY + "/approve_all" + extension );
27- if (!script .exists ())
28- {
29- String github = "https://raw.githubusercontent.com/approvals/ApprovalTests.Java/refs/heads/master/" ;
30- String file = "resources/approve_all" + extension ;
31- FileUtils .writeFile (script , NetUtils .loadWebPage (github + file , null ));
32- script .setExecutable (true );
33- }
34- }
35- catch (Exception e )
36- {
37- // do nothing
38- }
21+ String scriptName = "approve_all" ;
22+ LoggingUtils .downloadScriptIfMissing (scriptName );
3923 }
4024 public static File get ()
4125 {
Original file line number Diff line number Diff line change 1+ package org .approvaltests .internal .logs ;
2+
3+ import com .spun .util .SystemUtils ;
4+ import com .spun .util .io .FileUtils ;
5+ import com .spun .util .io .NetUtils ;
6+
7+ import java .io .File ;
8+
9+ public class LoggingUtils
10+ {
11+ public static final String APPROVAL_TEMP_DIRECTORY = ".approval_tests_temp" ;
12+ public static void downloadScriptIfMissing (String scriptName )
13+ {
14+ try
15+ {
16+ String extension = SystemUtils .isWindowsEnvironment () ? ".bat" : ".sh" ;
17+ File script = new File (APPROVAL_TEMP_DIRECTORY + "/" + scriptName + extension );
18+ if (!script .exists ())
19+ {
20+ String github = "https://raw.githubusercontent.com/approvals/ApprovalTests.Java/refs/heads/master/" ;
21+ String file = "resources/" + scriptName + extension ;
22+ FileUtils .writeFile (script , NetUtils .loadWebPage (github + file , null ));
23+ script .setExecutable (true );
24+ }
25+ }
26+ catch (Exception e )
27+ {
28+ // do nothing
29+ }
30+ }
31+ }
Original file line number Diff line number Diff line change 33import com .spun .util .SystemUtils ;
44import com .spun .util .io .FileUtils ;
55import com .spun .util .logger .SimpleLogger ;
6- import org .approvaltests .ApprovedFileLog ;
76import org .approvaltests .core .ApprovalFailureReporter ;
7+ import org .approvaltests .internal .logs .LoggingUtils ;
88
99import java .io .File ;
1010
@@ -32,14 +32,14 @@ private static void initializeFile()
3232 }
3333 private static void initializeLinux ()
3434 {
35- scriptFile = new File (ApprovedFileLog .APPROVAL_TEMP_DIRECTORY + "/" + fileName + ".sh" );
35+ scriptFile = new File (LoggingUtils .APPROVAL_TEMP_DIRECTORY + "/" + fileName + ".sh" );
3636 FileUtils .createIfNeeded (scriptFile .getAbsolutePath ());
3737 FileUtils .writeFile (scriptFile , "#!/bin/bash\n " );
3838 scriptFile .setExecutable (true );
3939 }
4040 private static void initializeWindows ()
4141 {
42- scriptFile = new File (ApprovedFileLog .APPROVAL_TEMP_DIRECTORY + "\\ " + fileName + ".bat" );
42+ scriptFile = new File (LoggingUtils .APPROVAL_TEMP_DIRECTORY + "\\ " + fileName + ".bat" );
4343 FileUtils .createIfNeeded (scriptFile .getAbsolutePath ());
4444 FileUtils .writeFile (scriptFile , "" );
4545 }
You can’t perform that action at this time.
0 commit comments