rspec-expectations icon indicating copy to clipboard operation
rspec-expectations copied to clipboard

Fix output.to_stdout_from_any_process when $stdout has been reassigned

Open jdelStrother opened this issue 1 year ago • 2 comments

(An alternate fix for https://github.com/rspec/rspec-core/pull/3113)

When running under rspec bisect runner, $stdout & $stderr are reassigned to a StringIO, which would cause "can't convert Tempfile into StringIO" when trying to reopen the stream in CaptureStreamToTempfile

Since CaptureStreamToTempfile reopens the stream rather than reassigning it, I think it makes sense to use STDOUT rather than whatever the current value of $stdout is.

(Please feel free to sanity-check that assumption. I've gone round in circles a few too many times on this)

jdelStrother avatar Sep 19 '24 15:09 jdelStrother

I don't have any objections to this approach apart from the fact it breaks our build due to having already redeclared std out, I'm not sure how to fix this yet...

JonRowe avatar Sep 20 '24 11:09 JonRowe

I've pushed a possible fix, where instead of reopening $stderr, it reopens STDERR and reassigns $stderr. I'm not entirely sure it's going to work, but see what you think and I can squash it if desired.

jdelStrother avatar Sep 20 '24 15:09 jdelStrother

Migrated to the monorepo as rspec/rspec#151

JonRowe avatar Nov 30 '24 12:11 JonRowe