Skip to content

Commit 8209c53

Browse files
committed
Mac Reporters
1 parent c74d501 commit 8209c53

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

java/org/approvaltests/reporters/FirstWorkingReporter.java

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

3+
import java.util.List;
4+
5+
import org.lambda.query.Query;
6+
37
public class FirstWorkingReporter implements EnvironmentAwareReporter
48
{
59
private final EnvironmentAwareReporter[] reporters;
@@ -28,4 +32,8 @@ public boolean isWorkingInThisEnvironment(String forFile)
2832
}
2933
return false;
3034
}
35+
public List<EnvironmentAwareReporter> getWorkingReportersForEnviroment()
36+
{
37+
return Query.where(reporters, r -> r.isWorkingInThisEnvironment("a.txt"));
38+
}
3139
}

java/org/approvaltests/reporters/GenericDiffReporter.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.Arrays;
66
import java.util.List;
77

8+
import com.spun.util.SystemUtils;
89
import com.spun.util.ThreadUtils;
910
import com.spun.util.io.FileUtils;
1011

@@ -46,8 +47,17 @@ public void report(String received, String approved) throws Exception
4647
private void launch(String received, String approved) throws IOException
4748
{
4849
ProcessBuilder builder = new ProcessBuilder(getCommandLine(received, approved));
50+
preventProcessFromClosing(builder);
4951
Process process = builder.start();
50-
ThreadUtils.sleep(500); //Give program time to start
52+
ThreadUtils.sleep(800); //Give program time to start
53+
}
54+
private void preventProcessFromClosing(ProcessBuilder builder)
55+
{
56+
if (!SystemUtils.isWindowsEnviroment())
57+
{
58+
File output = new File("/dev/null");
59+
builder.redirectError(output).redirectOutput(output);
60+
}
5161
}
5262
public String[] getCommandLine(String received, String approved)
5363
{
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.approvaltests.reporters.macosx;
2+
3+
import java.text.MessageFormat;
4+
5+
import org.approvaltests.reporters.GenericDiffReporter;
6+
7+
public class KDiff3Reporter extends GenericDiffReporter
8+
{
9+
private static final String DIFF_PROGRAM = "/Applications/kdiff3.app/Contents/MacOS/kdiff3";
10+
static final String MESSAGE = MessageFormat.format("Unable to find KDiff3 at {0}",
11+
DIFF_PROGRAM);
12+
public static final KDiff3Reporter INSTANCE = new KDiff3Reporter();
13+
public KDiff3Reporter()
14+
{
15+
super(DIFF_PROGRAM, "%s %s -m", MESSAGE, GenericDiffReporter.TEXT_FILE_EXTENSIONS);
16+
}
17+
}

java/org/approvaltests/reporters/macosx/MacDiffReporter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public class MacDiffReporter extends FirstWorkingReporter
77
public static final MacDiffReporter INSTANCE = new MacDiffReporter();
88
public MacDiffReporter()
99
{
10-
super(DiffMergeReporter.INSTANCE, KaleidoscopeDiffReporter.INSTANCE, P4MergeReporter.INSTANCE, TkDiffReporter.INSTANCE);
10+
super(DiffMergeReporter.INSTANCE, KaleidoscopeDiffReporter.INSTANCE, P4MergeReporter.INSTANCE,
11+
KDiff3Reporter.INSTANCE, TkDiffReporter.INSTANCE);
1112
}
1213
}

0 commit comments

Comments
 (0)