Skip to content

Commit

Permalink
Added begin-end for Ruby 2.4 parser of rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Jan 10, 2024
1 parent ddc4b92 commit 1336b5e
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions test/test_rake_file_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,30 +350,32 @@ def _synchronize
# https://github.com/seattlerb/minitest/blob/21d9e804b63c619f602f3f4ece6c71b48974707a/lib/minitest/assertions.rb#L546
def capture_subprocess_io
_synchronize do
require "tempfile"
begin
require "tempfile"

captured_stdout = Tempfile.new("out")
captured_stderr = Tempfile.new("err")
captured_stdout = Tempfile.new("out")
captured_stderr = Tempfile.new("err")

orig_stdout = $stdout.dup
orig_stderr = $stderr.dup
$stdout.reopen captured_stdout
$stderr.reopen captured_stderr
orig_stdout = $stdout.dup
orig_stderr = $stderr.dup
$stdout.reopen captured_stdout
$stderr.reopen captured_stderr

yield
yield

$stdout.rewind
$stderr.rewind
$stdout.rewind
$stderr.rewind

return captured_stdout.read, captured_stderr.read
ensure
$stdout.reopen orig_stdout
$stderr.reopen orig_stderr
return captured_stdout.read, captured_stderr.read
ensure
$stdout.reopen orig_stdout
$stderr.reopen orig_stderr

orig_stdout.close
orig_stderr.close
captured_stdout.close!
captured_stderr.close!
orig_stdout.close
orig_stderr.close
captured_stdout.close!
captured_stderr.close!
end
end
end

Expand Down

0 comments on commit 1336b5e

Please sign in to comment.