Skip to content

Commit

Permalink
Allow to mute std out in StandardStreamsCapturer
Browse files Browse the repository at this point in the history
The TimeoutExtension spec was quite noise as it printed thread dumps
to the console.
With this change we mute the output to stdOut for this spec.
  • Loading branch information
leonard84 committed Nov 6, 2023
1 parent 8a091be commit 6c73f3d
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public synchronized void start() {
private void startCapture(PrintStream originalStream, TeePrintStream teeStream, final boolean isOut) {
if (originalStream == teeStream) return;

if (teeStream != null) {
teeStream.stopDelegation();
}

StringMessagePrintStream notifyingStream = new StringMessagePrintStream() {
@Override
protected void printed(String message) {
Expand Down Expand Up @@ -72,9 +68,27 @@ public synchronized void stop() {
private void stopCapture(PrintStream originalStream, TeePrintStream teeStream, boolean isOut) {
if (originalStream != teeStream) return;
if (isOut) {
System.setOut(teeStream.getDelegates().get(0));
System.setOut(teeStream.getOriginal());
} else {
System.setErr(teeStream.getDelegates().get(0));
System.setErr(teeStream.getOriginal());
}
}

public synchronized void muteStandardStreams() {
if (outStream != null) {
outStream.muteOriginal();
}
if (errStream != null) {
errStream.muteOriginal();
}
}

public synchronized void unmuteStandardStreams() {
if (outStream != null) {
outStream.unmuteOriginal();
}
if (errStream != null) {
errStream.unmuteOriginal();
}
}

Expand Down
Loading

0 comments on commit 6c73f3d

Please sign in to comment.