File tree Expand file tree Collapse file tree 2 files changed +47
-1
lines changed
approvaltests/src/main/java/org/approvaltests Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 66
77public class ApprovedFileLog
88{
9+ public static final String APPROVAL_TEMP_DIRECTORY = ".approval_tests_temp" ;
910 static
1011 {
1112 FileUtils .writeFile (get (), "" );
1213 }
1314 public static File get ()
1415 {
15- File file = new File (".approval_tests_temp /.approved_files.log" );
16+ File file = new File (APPROVAL_TEMP_DIRECTORY + " /.approved_files.log" );
1617 FileUtils .createIfNeeded (file .getAbsolutePath ());
1718 return file ;
1819 }
Original file line number Diff line number Diff line change 1+ package org .approvaltests .reporters ;
2+
3+ import com .spun .util .SystemUtils ;
4+ import com .spun .util .io .FileUtils ;
5+ import com .spun .util .logger .SimpleLogger ;
6+ import org .approvaltests .ApprovedFileLog ;
7+ import org .approvaltests .core .ApprovalFailureReporter ;
8+
9+ import java .io .File ;
10+
11+ public class ReporterThatCreatesAnApprovalScript implements ApprovalFailureReporter {
12+ private static String fileName = "approval_script" ;
13+ private static File scriptFile = null ;
14+ static {
15+ initializeFile ();
16+
17+ }
18+
19+ private static void initializeFile () {
20+ if (scriptFile != null ) {return ;}
21+ if (SystemUtils .isWindowsEnvironment ()) {
22+ initializeWindows ();
23+ } else {
24+ initializeLinux ();
25+ }
26+ SimpleLogger .event ("Created approval script:\n " + scriptFile .getAbsolutePath ());
27+ }
28+
29+ private static void initializeLinux () {
30+
31+ }
32+
33+ private static void initializeWindows () {
34+ scriptFile = new File (ApprovedFileLog .APPROVAL_TEMP_DIRECTORY + "\\ " + fileName + ".bat" );
35+ FileUtils .createIfNeeded (scriptFile .getAbsolutePath ());
36+ FileUtils .writeFile (scriptFile , "" );
37+ }
38+
39+ @ Override
40+ public boolean report (String received , String approved ) {
41+ String commandLine = ClipboardReporter .getCommandLine (received , approved );
42+ FileUtils .appendToFile (scriptFile , commandLine + "\r \n " );
43+ return true ;
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments