mirror of https://github.com/dapr/java-sdk.git
Fix integration tests on Windows. (#750)
Signed-off-by: Artur Souza <artursouza.ms@outlook.com>
This commit is contained in:
parent
ea19b26d5d
commit
6ff58e9ee7
|
@ -32,6 +32,8 @@ public class Command {
|
||||||
|
|
||||||
private final String command;
|
private final String command;
|
||||||
|
|
||||||
|
private final String shell;
|
||||||
|
|
||||||
private Process process;
|
private Process process;
|
||||||
|
|
||||||
private Map<String, String> env;
|
private Map<String, String> env;
|
||||||
|
@ -40,6 +42,7 @@ public class Command {
|
||||||
this.successMessage = successMessage;
|
this.successMessage = successMessage;
|
||||||
this.command = command;
|
this.command = command;
|
||||||
this.env = env;
|
this.env = env;
|
||||||
|
this.shell = detectShell();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Command(String successMessage, String command) {
|
public Command(String successMessage, String command) {
|
||||||
|
@ -49,7 +52,7 @@ public class Command {
|
||||||
public void run() throws InterruptedException, IOException {
|
public void run() throws InterruptedException, IOException {
|
||||||
final AtomicBoolean success = new AtomicBoolean(false);
|
final AtomicBoolean success = new AtomicBoolean(false);
|
||||||
final Semaphore finished = new Semaphore(0);
|
final Semaphore finished = new Semaphore(0);
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder("bash", "-c", command);
|
ProcessBuilder processBuilder = new ProcessBuilder(this.shell, "-c", command);
|
||||||
if (this.env != null) {
|
if (this.env != null) {
|
||||||
processBuilder.environment().putAll(this.env);
|
processBuilder.environment().putAll(this.env);
|
||||||
}
|
}
|
||||||
|
@ -103,4 +106,13 @@ public class Command {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.command;
|
return this.command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String detectShell() {
|
||||||
|
String osName = System.getProperty("os.name").toLowerCase();
|
||||||
|
if (osName.contains("windows")) {
|
||||||
|
return "powershell.exe";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "bash";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue