Skip to content

Commit 5745ced

Browse files
committed
mac launcher working
1 parent 37880d2 commit 5745ced

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

java/org/approvaltests/reporters/GenericDiffReporter.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package org.approvaltests.reporters;
22

33
import java.io.File;
4+
import java.io.IOException;
45
import java.util.Arrays;
56
import java.util.List;
67

78
import com.spun.util.SystemUtils;
9+
import com.spun.util.ThreadUtils;
810
import com.spun.util.io.FileUtils;
911

1012
public class GenericDiffReporter implements EnvironmentAwareReporter
@@ -40,11 +42,22 @@ public void report(String received, String approved) throws Exception
4042
{
4143
if (!isWorkingInThisEnvironment(received)) { throw new RuntimeException(diffProgramNotFoundMessage); }
4244
FileUtils.createIfNeeded(approved);
43-
Process exec = Runtime.getRuntime().exec(
44-
getCommandLine(convertFileForCommandLine(received), convertFileForCommandLine(approved)));
45-
// int waitFor = exec.waitFor();
46-
// String text = DatabaseLifeCycleUtils.extractText(exec.getErrorStream());
47-
// System.out.println(waitFor + text);
45+
launch(received, approved);
46+
}
47+
private void launch(String received, String approved) throws IOException
48+
{
49+
ProcessBuilder builder = new ProcessBuilder(getCommandLine(received, approved));
50+
Process process = builder.start();
51+
ThreadUtils.sleep(500); //Give program time to start
52+
}
53+
public String[] getCommandLine(String received, String approved)
54+
{
55+
String[] p = arguments.split(" ");
56+
String r = String.format(p[0], received);
57+
String a = String.format(p[1], approved);
58+
String[] commands = new String[]{diffProgram, r, a};
59+
System.out.println(Arrays.toString(commands));
60+
return commands;
4861
}
4962
public static String convertFileForCommandLine(String fileName)
5063
{
@@ -65,13 +78,6 @@ else if (windowsOs)
6578
return fileName.replace(" ", "\\ ");
6679
}
6780
}
68-
public String getCommandLine(String received, String approved)
69-
{
70-
String command = "%s " + arguments;
71-
command = String.format(command, diffProgram, received, approved);
72-
System.out.println(command);
73-
return command;
74-
}
7581
@Override
7682
public boolean isWorkingInThisEnvironment(String forFile)
7783
{

0 commit comments

Comments
 (0)