Skip to content

Commit

Permalink
Merge pull request #537 from ruby/removed-needless-block
Browse files Browse the repository at this point in the history
Removed redundant block
  • Loading branch information
hsbt authored Jan 11, 2024
2 parents a7ad109 + 0cb25e0 commit 01a2aab
Showing 1 changed file with 20 additions and 27 deletions.
47 changes: 20 additions & 27 deletions test/test_rake_file_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,40 +342,33 @@ def test_sh_if_a_command_exits_with_error_status_sh_echoes_it_fully
end
end

# https://github.com/seattlerb/minitest/blob/21d9e804b63c619f602f3f4ece6c71b48974707a/lib/minitest/assertions.rb#L188
def _synchronize
yield
end

# https://github.com/seattlerb/minitest/blob/21d9e804b63c619f602f3f4ece6c71b48974707a/lib/minitest/assertions.rb#L546
# Originally copied from minitest/assertions.rb
def capture_subprocess_io
_synchronize do
begin
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
[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!
end
orig_stdout.close
orig_stderr.close
captured_stdout.close!
captured_stderr.close!
end
end

Expand Down

0 comments on commit 01a2aab

Please sign in to comment.