Fix integration tests on Windows. (#750)

Signed-off-by: Artur Souza <artursouza.ms@outlook.com>
This commit is contained in:
Artur Souza 2022-06-22 01:48:51 -07:00 committed by GitHub
parent ea19b26d5d
commit 6ff58e9ee7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -32,6 +32,8 @@ public class Command {
private final String command;
private final String shell;
private Process process;
private Map<String, String> env;
@ -40,6 +42,7 @@ public class Command {
this.successMessage = successMessage;
this.command = command;
this.env = env;
this.shell = detectShell();
}
public Command(String successMessage, String command) {
@ -49,7 +52,7 @@ public class Command {
public void run() throws InterruptedException, IOException {
final AtomicBoolean success = new AtomicBoolean(false);
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) {
processBuilder.environment().putAll(this.env);
}
@ -103,4 +106,13 @@ public class Command {
public String toString() {
return this.command;
}
private static String detectShell() {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("windows")) {
return "powershell.exe";
}
return "bash";
}
}