1
0
mirror of synced 2026-08-04 22:46:55 +00:00

fix: manually pipe messages from child process sdtout/stderr (#426)

This commit is contained in:
Yury Semikhatsky
2021-05-06 02:24:57 +00:00
committed by GitHub
parent a95f8f3887
commit 0fa416b459
7 changed files with 105 additions and 6 deletions
@@ -48,6 +48,9 @@ public class DriverJar extends Driver {
p.destroy();
throw new RuntimeException("Timed out waiting for browsers to install");
}
if (p.exitValue() != 0) {
throw new RuntimeException("Failed to install browsers, exit code: " + p.exitValue());
}
}
private static boolean isExecutable(Path filePath) {
@@ -17,6 +17,7 @@
package com.microsoft.playwright;
import com.microsoft.playwright.impl.Driver;
import com.microsoft.playwright.impl.StreamRedirectThread;
import org.junit.jupiter.api.Test;
import java.nio.file.Files;
@@ -36,11 +37,13 @@ public class TestInstall {
assertTrue(Files.exists(cli));
ProcessBuilder pb = new ProcessBuilder(cli.toString(), "install");
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
Process p = pb.start();
StreamRedirectThread stdoutThread = new StreamRedirectThread(p.getInputStream(), System.out);
StreamRedirectThread stderrThread = new StreamRedirectThread(p.getErrorStream(), System.err);
boolean result = p.waitFor(1, TimeUnit.MINUTES);
assertTrue(result, "Timed out waiting for browsers to install");
stderrThread.terminateAndJoin();
stdoutThread.terminateAndJoin();
} catch (Exception e) {
e.printStackTrace();
assertNull(e);