question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Correctly restore stdout after tests

See original GitHub issue

We have many tests that overwrite stdout with a custom output stream and we call System.setOut(null) to attempt to restore stdout.

We need to either:

  • capture the original System.out and restore that same instance
  • use StdOutCaptureRule provided by com.google.cloud:google-cloud-core’s tests classifier (jar)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kurtisvgcommented, Jan 5, 2021

I think there are a few other samples that still do this incorrectly, so I’m going to reopen so we don’t forget about it.

0reactions
lesvcommented, Apr 5, 2021

I’m going to close this, and we’ll deal with individual issues and PR’s for any of these we find.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I restore STDOUT after redirecting it to a file in a Perl ...
You need to save STDOUT before reopening it: open(SAVE, ">&STDOUT") || die "Can't save STDOUT\n"; ... open(STDOUT, ">&SAVE") || die "Can't restore STDOUT\n" ......
Read more >
get the default `process.stdout.write` back after tests are finished
I have a test which tests stdout so I need to change the default behaviour of process.stdout. process.stdout.write = (function(write) ...
Read more >
exec | Cypress Documentation
A command must exit within the execTimeout or Cypress will kill the command's process and fail the current test. Reset timeout via Cypress.config()....
Read more >
How to tell if output of a command or shell script is stdout or ...
What you can do, in a case like the above, would be to run the command with stdout and stderr redirected to different...
Read more >
Redirected stderr not reset properly when using logging
And then context manager resets back stdout and stderr where it should ... and what to do after I was done with capturing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found