Skip to content

Commit

Permalink
Revert "fix: manually pipe messages from child process sdtout/stderr (m…
Browse files Browse the repository at this point in the history
…icrosoft#426)" (microsoft#440)

This reverts commit 0fa416b.
  • Loading branch information
yury-s committed May 12, 2021
1 parent 74bf663 commit 2f5912a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
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;
Expand All @@ -37,13 +36,11 @@ void playwrightCliInstalled() throws Exception {
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);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,21 @@

public class PlaywrightImpl extends ChannelOwner implements Playwright {
private Process driverProcess;
private StreamRedirectThread stderrThread;

public static PlaywrightImpl create() {
StreamRedirectThread stderrThread = null;
try {
Path driver = Driver.ensureDriverInstalled();
ProcessBuilder pb = new ProcessBuilder(driver.toString(), "run-driver");
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
// pb.environment().put("DEBUG", "pw:pro*");
Process p = pb.start();
stderrThread = new StreamRedirectThread(p.getErrorStream(), System.err);
Connection connection = new Connection(new PipeTransport(p.getInputStream(), p.getOutputStream()));
PlaywrightImpl result = (PlaywrightImpl) connection.waitForObjectWithKnownName("Playwright");
result.driverProcess = p;
result.stderrThread = stderrThread;
stderrThread = null;
result.initSharedSelectors(null);
return result;
} catch (IOException e) {
throw new PlaywrightException("Failed to launch driver", e);
} finally {
if (stderrThread != null) {
stderrThread.terminateAndJoin();
}
}
}

Expand Down Expand Up @@ -111,7 +103,6 @@ public void close() {
if (!didClose) {
System.err.println("WARNING: Timed out while waiting for driver process to exit");
}
stderrThread.terminateAndJoin();
} catch (IOException e) {
throw new PlaywrightException("Failed to terminate", e);
} catch (InterruptedException e) {
Expand Down

0 comments on commit 2f5912a

Please sign in to comment.