Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed redundant block #537

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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