mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Use capture_output instead of capture_io.
ad9206d4d0
This commit is contained in:
parent
cddeee21e9
commit
26cbda8dc9
Notes:
git
2021-05-12 17:25:23 +09:00
12 changed files with 33 additions and 33 deletions
|
@ -96,7 +96,7 @@ class TestDeprecate < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_deprecated_method_calls_the_old_method
|
def test_deprecated_method_calls_the_old_method
|
||||||
capture_io do
|
capture_output do
|
||||||
thing = Thing.new
|
thing = Thing.new
|
||||||
thing.foo
|
thing.foo
|
||||||
assert_equal "foo", thing.message
|
assert_equal "foo", thing.message
|
||||||
|
@ -108,7 +108,7 @@ class TestDeprecate < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_deprecated_method_outputs_a_warning
|
def test_deprecated_method_outputs_a_warning
|
||||||
out, err = capture_io do
|
out, err = capture_output do
|
||||||
thing = Thing.new
|
thing = Thing.new
|
||||||
thing.foo
|
thing.foo
|
||||||
thing.foo_arg("msg")
|
thing.foo_arg("msg")
|
||||||
|
|
|
@ -1389,7 +1389,7 @@ class TestGem < Gem::TestCase
|
||||||
io.write spec.to_ruby_for_cache
|
io.write spec.to_ruby_for_cache
|
||||||
end
|
end
|
||||||
|
|
||||||
_, err = capture_io do
|
_, err = capture_output do
|
||||||
refute Gem.try_activate 'nonexistent'
|
refute Gem.try_activate 'nonexistent'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1414,7 +1414,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_setting_paths_does_not_warn_about_unknown_keys
|
def test_setting_paths_does_not_warn_about_unknown_keys
|
||||||
stdout, stderr = capture_io do
|
stdout, stderr = capture_output do
|
||||||
Gem.paths = { 'foo' => [],
|
Gem.paths = { 'foo' => [],
|
||||||
'bar' => Object.new,
|
'bar' => Object.new,
|
||||||
'GEM_HOME' => Gem.paths.home,
|
'GEM_HOME' => Gem.paths.home,
|
||||||
|
@ -1432,7 +1432,7 @@ class TestGem < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_deprecated_paths=
|
def test_deprecated_paths=
|
||||||
stdout, stderr = capture_io do
|
stdout, stderr = capture_output do
|
||||||
Gem.paths = { 'GEM_HOME' => Gem.paths.home,
|
Gem.paths = { 'GEM_HOME' => Gem.paths.home,
|
||||||
'GEM_PATH' => [Gem.paths.home, 'foo'] }
|
'GEM_PATH' => [Gem.paths.home, 'foo'] }
|
||||||
end
|
end
|
||||||
|
@ -2073,7 +2073,7 @@ You may need to `gem install -g` to install missing gems
|
||||||
refute_includes $LOAD_PATH, test_plugin_path
|
refute_includes $LOAD_PATH, test_plugin_path
|
||||||
$LOAD_PATH.unshift test_plugin_path
|
$LOAD_PATH.unshift test_plugin_path
|
||||||
|
|
||||||
capture_io do
|
capture_output do
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
|
|
|
@ -208,7 +208,7 @@ class TestGemCommandsBuildCommand < Gem::TestCase
|
||||||
@cmd.options[:args] = [gemspec_file]
|
@cmd.options[:args] = [gemspec_file]
|
||||||
|
|
||||||
out, err = use_ui @ui do
|
out, err = use_ui @ui do
|
||||||
capture_io do
|
capture_output do
|
||||||
assert_raises Gem::MockGemUi::TermError do
|
assert_raises Gem::MockGemUi::TermError do
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
end
|
end
|
||||||
|
|
|
@ -55,7 +55,7 @@ class TestGemCommandsCheckCommand < Gem::TestCase
|
||||||
|
|
||||||
Gem.use_paths @gemhome
|
Gem.use_paths @gemhome
|
||||||
|
|
||||||
capture_io do
|
capture_output do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
@cmd.doctor
|
@cmd.doctor
|
||||||
end
|
end
|
||||||
|
|
|
@ -253,7 +253,7 @@ if you believe they were disclosed to a third party.
|
||||||
|
|
||||||
args = %w[--debug]
|
args = %w[--debug]
|
||||||
|
|
||||||
_, err = capture_io do
|
_, err = capture_output do
|
||||||
@cfg.handle_arguments args
|
@cfg.handle_arguments args
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ class TestGemDoctor < Gem::TestCase
|
||||||
|
|
||||||
doctor = Gem::Doctor.new @gemhome
|
doctor = Gem::Doctor.new @gemhome
|
||||||
|
|
||||||
capture_io do
|
capture_output do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
doctor.doctor
|
doctor.doctor
|
||||||
end
|
end
|
||||||
|
@ -91,7 +91,7 @@ Removed directory gems/c-2
|
||||||
|
|
||||||
doctor = Gem::Doctor.new @gemhome, true
|
doctor = Gem::Doctor.new @gemhome, true
|
||||||
|
|
||||||
capture_io do
|
capture_output do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
doctor.doctor
|
doctor.doctor
|
||||||
end
|
end
|
||||||
|
@ -127,7 +127,7 @@ Extra directory gems/c-2
|
||||||
|
|
||||||
doctor = Gem::Doctor.new @tempdir
|
doctor = Gem::Doctor.new @tempdir
|
||||||
|
|
||||||
capture_io do
|
capture_output do
|
||||||
use_ui @ui do
|
use_ui @ui do
|
||||||
doctor.doctor
|
doctor.doctor
|
||||||
end
|
end
|
||||||
|
|
|
@ -81,7 +81,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
|
||||||
def test_gem_duplicate
|
def test_gem_duplicate
|
||||||
@gda.gem 'a'
|
@gda.gem 'a'
|
||||||
|
|
||||||
_, err = capture_io do
|
_, err = capture_output do
|
||||||
@gda.gem 'a'
|
@gda.gem 'a'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gem_git_branch
|
def test_gem_git_branch
|
||||||
_, err = capture_io do
|
_, err = capture_output do
|
||||||
@gda.gem 'a', :git => 'git/a', :branch => 'other', :tag => 'v1'
|
@gda.gem 'a', :git => 'git/a', :branch => 'other', :tag => 'v1'
|
||||||
end
|
end
|
||||||
expected = "Gem dependencies file gem.deps.rb includes git reference for both ref/branch and tag but only ref/branch is used."
|
expected = "Gem dependencies file gem.deps.rb includes git reference for both ref/branch and tag but only ref/branch is used."
|
||||||
|
@ -150,7 +150,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_gem_git_ref
|
def test_gem_git_ref
|
||||||
_, err = capture_io do
|
_, err = capture_output do
|
||||||
@gda.gem 'a', :git => 'git/a', :ref => 'abcd123', :branch => 'other'
|
@gda.gem 'a', :git => 'git/a', :ref => 'abcd123', :branch => 'other'
|
||||||
end
|
end
|
||||||
expected = "Gem dependencies file gem.deps.rb includes git reference for both ref and branch but only ref is used."
|
expected = "Gem dependencies file gem.deps.rb includes git reference for both ref and branch but only ref is used."
|
||||||
|
@ -518,7 +518,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
|
||||||
FileUtils.touch 'a.gemspec'
|
FileUtils.touch 'a.gemspec'
|
||||||
|
|
||||||
e = assert_raises ArgumentError do
|
e = assert_raises ArgumentError do
|
||||||
capture_io do
|
capture_output do
|
||||||
@gda.gemspec
|
@gda.gemspec
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -133,7 +133,7 @@ class TestGemServer < Gem::TestCase
|
||||||
def test_listen
|
def test_listen
|
||||||
util_listen
|
util_listen
|
||||||
|
|
||||||
capture_io do
|
capture_output do
|
||||||
@server.listen
|
@server.listen
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ class TestGemServer < Gem::TestCase
|
||||||
def test_listen_addresses
|
def test_listen_addresses
|
||||||
util_listen
|
util_listen
|
||||||
|
|
||||||
capture_io do
|
capture_output do
|
||||||
@server.listen %w[a b]
|
@server.listen %w[a b]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class TestGemSilentUI < Gem::TestCase
|
||||||
|
|
||||||
def test_ask
|
def test_ask
|
||||||
value = nil
|
value = nil
|
||||||
out, err = capture_io do
|
out, err = capture_output do
|
||||||
use_ui @sui do
|
use_ui @sui do
|
||||||
value = @sui.ask 'Problem?'
|
value = @sui.ask 'Problem?'
|
||||||
end
|
end
|
||||||
|
@ -30,7 +30,7 @@ class TestGemSilentUI < Gem::TestCase
|
||||||
|
|
||||||
def test_ask_for_password
|
def test_ask_for_password
|
||||||
value = nil
|
value = nil
|
||||||
out, err = capture_io do
|
out, err = capture_output do
|
||||||
use_ui @sui do
|
use_ui @sui do
|
||||||
value = @sui.ask_for_password 'Problem?'
|
value = @sui.ask_for_password 'Problem?'
|
||||||
end
|
end
|
||||||
|
@ -44,7 +44,7 @@ class TestGemSilentUI < Gem::TestCase
|
||||||
|
|
||||||
def test_ask_yes_no
|
def test_ask_yes_no
|
||||||
value = nil
|
value = nil
|
||||||
out, err = capture_io do
|
out, err = capture_output do
|
||||||
use_ui @sui do
|
use_ui @sui do
|
||||||
assert_raises(Gem::OperationNotSupportedError) do
|
assert_raises(Gem::OperationNotSupportedError) do
|
||||||
@sui.ask_yes_no 'Problem?'
|
@sui.ask_yes_no 'Problem?'
|
||||||
|
@ -55,7 +55,7 @@ class TestGemSilentUI < Gem::TestCase
|
||||||
assert_empty out, 'No output'
|
assert_empty out, 'No output'
|
||||||
assert_empty err, 'No output'
|
assert_empty err, 'No output'
|
||||||
|
|
||||||
out, err = capture_io do
|
out, err = capture_output do
|
||||||
use_ui @sui do
|
use_ui @sui do
|
||||||
value = @sui.ask_yes_no 'Problem?', true
|
value = @sui.ask_yes_no 'Problem?', true
|
||||||
end
|
end
|
||||||
|
@ -66,7 +66,7 @@ class TestGemSilentUI < Gem::TestCase
|
||||||
|
|
||||||
assert value, 'Value is true'
|
assert value, 'Value is true'
|
||||||
|
|
||||||
out, err = capture_io do
|
out, err = capture_output do
|
||||||
use_ui @sui do
|
use_ui @sui do
|
||||||
value = @sui.ask_yes_no 'Problem?', false
|
value = @sui.ask_yes_no 'Problem?', false
|
||||||
end
|
end
|
||||||
|
@ -80,7 +80,7 @@ class TestGemSilentUI < Gem::TestCase
|
||||||
|
|
||||||
def test_choose_from_list
|
def test_choose_from_list
|
||||||
value = nil
|
value = nil
|
||||||
out, err = capture_io do
|
out, err = capture_output do
|
||||||
use_ui @sui do
|
use_ui @sui do
|
||||||
value = @sui.choose_from_list 'Problem?', %w[yes no]
|
value = @sui.choose_from_list 'Problem?', %w[yes no]
|
||||||
end
|
end
|
||||||
|
@ -93,7 +93,7 @@ class TestGemSilentUI < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_progress_reporter
|
def test_progress_reporter
|
||||||
out, err = capture_io do
|
out, err = capture_output do
|
||||||
use_ui @sui do
|
use_ui @sui do
|
||||||
@sui.progress_reporter 10, 'hi'
|
@sui.progress_reporter 10, 'hi'
|
||||||
end
|
end
|
||||||
|
@ -104,7 +104,7 @@ class TestGemSilentUI < Gem::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_download_reporter
|
def test_download_reporter
|
||||||
out, err = capture_io do
|
out, err = capture_output do
|
||||||
use_ui @sui do
|
use_ui @sui do
|
||||||
@sui.download_reporter.fetch 'a.gem', 1024
|
@sui.download_reporter.fetch 'a.gem', 1024
|
||||||
end
|
end
|
||||||
|
|
|
@ -240,7 +240,7 @@ class TestGemSourceGit < Gem::TestCase
|
||||||
|
|
||||||
specs = nil
|
specs = nil
|
||||||
|
|
||||||
capture_io do
|
capture_output do
|
||||||
specs = source.specs
|
specs = source.specs
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ class TestGemSourceGit < Gem::TestCase
|
||||||
source = Gem::Source::Git.new @name, @repository, 'master', true
|
source = Gem::Source::Git.new @name, @repository, 'master', true
|
||||||
source.remote = false
|
source.remote = false
|
||||||
|
|
||||||
capture_io do
|
capture_output do
|
||||||
assert_empty source.specs
|
assert_empty source.specs
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1669,7 +1669,7 @@ dependencies: []
|
||||||
skip "extensions don't quite work on jruby" if Gem.java_platform?
|
skip "extensions don't quite work on jruby" if Gem.java_platform?
|
||||||
ext_spec
|
ext_spec
|
||||||
|
|
||||||
_, err = capture_io do
|
_, err = capture_output do
|
||||||
refute @ext.contains_requirable_file? 'nonexistent'
|
refute @ext.contains_requirable_file? 'nonexistent'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1682,7 +1682,7 @@ dependencies: []
|
||||||
def test_contains_requirable_file_eh_extension_java_platform
|
def test_contains_requirable_file_eh_extension_java_platform
|
||||||
ext_spec(platform: Gem::Platform.new("java"))
|
ext_spec(platform: Gem::Platform.new("java"))
|
||||||
|
|
||||||
_, err = capture_io do
|
_, err = capture_output do
|
||||||
refute @ext.contains_requirable_file? 'nonexistent'
|
refute @ext.contains_requirable_file? 'nonexistent'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3515,7 +3515,7 @@ Did you mean 'Ruby'?
|
||||||
specfile.write "raise 'boom'"
|
specfile.write "raise 'boom'"
|
||||||
specfile.close
|
specfile.close
|
||||||
begin
|
begin
|
||||||
capture_io do
|
capture_output do
|
||||||
Gem::Specification.load(specfile.path)
|
Gem::Specification.load(specfile.path)
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
|
|
|
@ -67,7 +67,7 @@ class TestStubSpecification < Gem::TestCase
|
||||||
def test_contains_requirable_file_eh_extension
|
def test_contains_requirable_file_eh_extension
|
||||||
skip "I guess making the stub match the running platform should work" if Gem.java_platform?
|
skip "I guess making the stub match the running platform should work" if Gem.java_platform?
|
||||||
stub_with_extension do |stub|
|
stub_with_extension do |stub|
|
||||||
_, err = capture_io do
|
_, err = capture_output do
|
||||||
refute stub.contains_requirable_file? 'nonexistent'
|
refute stub.contains_requirable_file? 'nonexistent'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ class TestStubSpecification < Gem::TestCase
|
||||||
def test_to_spec_missing_extensions
|
def test_to_spec_missing_extensions
|
||||||
stub = stub_with_extension
|
stub = stub_with_extension
|
||||||
|
|
||||||
capture_io do
|
capture_output do
|
||||||
stub.contains_requirable_file? 'nonexistent'
|
stub.contains_requirable_file? 'nonexistent'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue