public StreamedTestOutput(OutErr outErr, Path testLogPath) throws IOException { this.testLogPath = testLogPath; this.outErr = outErr; this.headerFilter = TestLogHelper.getHeaderFilteringOutputStream(outErr.getOutputStream()); this.watcher = new FileWatcher(testLogPath, OutErr.create(headerFilter, headerFilter), false); watcher.start(); }
@Override public void close() throws IOException { watcher.stopPumping(); try { // The watcher thread might leak if the following call is interrupted. // This is a relatively minor issue since the worst it could do is // write one additional line from the test.log to the console later on // in the build. watcher.join(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } if (!headerFilter.foundHeader()) { try (InputStream input = testLogPath.getInputStream()) { ByteStreams.copy(input, outErr.getOutputStream()); } } }
public static OutErr outErrForReporter(EventHandler rep) { return OutErr.create( // We don't use BufferedOutputStream here, because in general the Blaze // code base assumes that the output streams are not buffered. new ReporterStream(rep, EventKind.STDOUT), new ReporterStream(rep, EventKind.STDERR)); }
@Override public int exec(List<String> args, OutErr outErr, long firstContactTime) throws Exception { outErr.printOut(COMMAND_STDOUT); outErr.printErr(COMMAND_STDERR); return 42; }