When debugging issues with GoogleTest sharding, it is very useful to see
the stdout/stderr from the whole shard as part of the test failure
output.
This change ensures that the stream output and error code is kept and
logged in the case of any failures.