Repository navigation
Ensure Console.Out is not disposed and is restored if it was replaced during the test run - #4317
Conversation
|
I think this could be helpful for 3.13. Redirecting or splitting these outputs has been a bit of a common request in issues and discussions the last few months. |
|
@normj Would you mind creating another PR for merging into the https://github.com/nunit/nunit/tree/v3.13-dev branch? |
… during the test run
9f43045 to
3ed73fa
Compare
|
🤦♂️ Not adding tests on a PR for a test framework @OsirisTerje I added a test to cover the I'm happy to make a make a backporting PR to the |
OsirisTerje
left a comment
There was a problem hiding this comment.
Looks like everything is in order. Thanks @normj for the contribution!
I'm on the AWS .NET team. We got a report from a user that used
NUnitLiteand got an object disposed exception when using this library in their AWS Lambda functions. Lambda is AWS's serverless compute offering.In Lambda we redirect
Console.Outto our ownStreamWriterfor logging.NUnitLiteis wrappingConsole.Outwith its ownColorConsoleWriterand when it is done it disposesColorConsoleWriterand disposes its innerTextWriterwhich would normally be the console stdout that ignores the dispose call but instead calls ourTextWriterto dispose. With ourTextWriterdisposed any calls toConsole.Outnow fail.We have fixed Lambda to ignore the dispose call but I though this PR would be helpful for others to ensure
NUnitLitedoesn't accidently dispose of somebody else's customConsole.Out.I also made sure if
Console.SetOutorConsole.SetErrorare used to be sure to restore to the originalTextWriters after the run is complete.Fixes #4319