Suppress leak of file descriptors

`Bundler.ui=` in `Gem::TestCase#setup` creates `Bundler::UI::RGProxy`
which inherites `::Gem::SilentUI` whose `initialize` opens `/dev/null`,
and assigns it to `Gem::DefaultUserInteraction.ui`.
After that, `Gem::TestCase#setup` forces to overwrite
`Gem::DefaultUserInteraction.ui` with a mock.
Thus, the instance of `::Gem::SilentUI` is not closed, which leads to
the leak.

This commit keeps `Gem::DefaultUserInteraction.ui` and manually close it
in `teardown`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2017-10-17 07:41:03 +00:00
Родитель 6b4cd8a996
Коммит 16b6fe17a3
1 изменённых файлов: 3 добавлений и 0 удалений

Просмотреть файл

@ -236,6 +236,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
@fetcher = nil @fetcher = nil
Bundler.ui = Bundler::UI::Silent.new Bundler.ui = Bundler::UI::Silent.new
@back_ui = Gem::DefaultUserInteraction.ui
@ui = Gem::MockGemUi.new @ui = Gem::MockGemUi.new
# This needs to be a new instance since we call use_ui(@ui) when we want to # This needs to be a new instance since we call use_ui(@ui) when we want to
# capture output # capture output
@ -420,6 +421,8 @@ class Gem::TestCase < MiniTest::Unit::TestCase
Gem::Specification._clear_load_cache Gem::Specification._clear_load_cache
Gem::Specification.unresolved_deps.clear Gem::Specification.unresolved_deps.clear
Gem::refresh Gem::refresh
@back_ui.close
end end
def common_installer_setup def common_installer_setup