mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 05:55:46 +02:00
[rubygems/rubygems] util/rubocop -A --only Style/RedundantBegin
b595d3cf0f
This commit is contained in:
parent
a532e9dc37
commit
72d09a568f
16 changed files with 148 additions and 188 deletions
|
@ -117,32 +117,30 @@ class Gem::TestCase < Test::Unit::TestCase
|
|||
# https://github.com/seattlerb/minitest/blob/21d9e804b63c619f602f3f4ece6c71b48974707a/lib/minitest/assertions.rb#L546
|
||||
def capture_subprocess_io
|
||||
_synchronize do
|
||||
begin
|
||||
require "tempfile"
|
||||
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!
|
||||
end
|
||||
orig_stdout.close
|
||||
orig_stderr.close
|
||||
captured_stdout.close!
|
||||
captured_stderr.close!
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1159,14 +1159,12 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
|||
end
|
||||
server.ssl_context.tmp_dh_callback = proc { TEST_KEY_DH2048 }
|
||||
t = Thread.new do
|
||||
begin
|
||||
server.start
|
||||
rescue Exception => ex
|
||||
puts "ERROR during server thread: #{ex.message}"
|
||||
raise
|
||||
ensure
|
||||
server.shutdown
|
||||
end
|
||||
server.start
|
||||
rescue Exception => ex
|
||||
puts "ERROR during server thread: #{ex.message}"
|
||||
raise
|
||||
ensure
|
||||
server.shutdown
|
||||
end
|
||||
while server.status != :Running
|
||||
sleep 0.1
|
||||
|
@ -1213,13 +1211,11 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
|||
end
|
||||
end
|
||||
th = Thread.new do
|
||||
begin
|
||||
s.start
|
||||
rescue Exception => ex
|
||||
abort "ERROR during server thread: #{ex.message}"
|
||||
ensure
|
||||
s.shutdown
|
||||
end
|
||||
s.start
|
||||
rescue Exception => ex
|
||||
abort "ERROR during server thread: #{ex.message}"
|
||||
ensure
|
||||
s.shutdown
|
||||
end
|
||||
th[:server] = s
|
||||
th
|
||||
|
|
|
@ -145,25 +145,21 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||
|
||||
def test_eglible_for_update_prevent_config
|
||||
with_eglible_environment(cmd: @cmd) do
|
||||
begin
|
||||
original_config = Gem.configuration[:prevent_update_suggestion]
|
||||
Gem.configuration[:prevent_update_suggestion] = true
|
||||
refute @cmd.eglible_for_update?
|
||||
ensure
|
||||
Gem.configuration[:prevent_update_suggestion] = original_config
|
||||
end
|
||||
original_config = Gem.configuration[:prevent_update_suggestion]
|
||||
Gem.configuration[:prevent_update_suggestion] = true
|
||||
refute @cmd.eglible_for_update?
|
||||
ensure
|
||||
Gem.configuration[:prevent_update_suggestion] = original_config
|
||||
end
|
||||
end
|
||||
|
||||
def test_eglible_for_update_prevent_env
|
||||
with_eglible_environment(cmd: @cmd) do
|
||||
begin
|
||||
original_env = ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"]
|
||||
ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = "yes"
|
||||
refute @cmd.eglible_for_update?
|
||||
ensure
|
||||
ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = original_env
|
||||
end
|
||||
original_env = ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"]
|
||||
ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = "yes"
|
||||
refute @cmd.eglible_for_update?
|
||||
ensure
|
||||
ENV["RUBYGEMS_PREVENT_UPDATE_SUGGESTION"] = original_env
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -181,13 +177,11 @@ class TestUpdateSuggestion < Gem::TestCase
|
|||
|
||||
def test_eglible_for_update_disabled_update
|
||||
with_eglible_environment(cmd: @cmd) do
|
||||
begin
|
||||
original_disable = Gem.disable_system_update_message
|
||||
Gem.disable_system_update_message = "disabled"
|
||||
refute @cmd.eglible_for_update?
|
||||
ensure
|
||||
Gem.disable_system_update_message = original_disable
|
||||
end
|
||||
original_disable = Gem.disable_system_update_message
|
||||
Gem.disable_system_update_message = "disabled"
|
||||
refute @cmd.eglible_for_update?
|
||||
ensure
|
||||
Gem.disable_system_update_message = original_disable
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -91,12 +91,10 @@ class TestGemRequire < Gem::TestCase
|
|||
|
||||
def create_sync_thread
|
||||
Thread.new do
|
||||
begin
|
||||
yield
|
||||
ensure
|
||||
FILE_ENTERED_LATCH.release
|
||||
FILE_EXIT_LATCH.await
|
||||
end
|
||||
yield
|
||||
ensure
|
||||
FILE_ENTERED_LATCH.release
|
||||
FILE_EXIT_LATCH.await
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue