1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Re-commit r65722

which was accidentally reverted by r65904

158562dabb

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
k0kubun 2018-12-04 11:45:05 +00:00
parent 49efa01579
commit 70a385a4f6

View file

@ -4,6 +4,7 @@ require 'rubygems/user_interaction'
require 'timeout'
class TestGemStreamUI < Gem::TestCase
SHORT_TIMEOUT = (defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?) ? 1.0 : 0.1 # increase timeout with MJIT for --jit-wait testing
module IsTty
attr_accessor :tty
@ -47,7 +48,7 @@ class TestGemStreamUI < Gem::TestCase
def test_ask_no_tty
@in.tty = false
Timeout.timeout(0.1) do
Timeout.timeout(SHORT_TIMEOUT) do
answer = @sui.ask("what is your favorite color?")
assert_nil answer
end
@ -65,7 +66,7 @@ class TestGemStreamUI < Gem::TestCase
def test_ask_for_password_no_tty
@in.tty = false
Timeout.timeout(0.1) do
Timeout.timeout(SHORT_TIMEOUT) do
answer = @sui.ask_for_password("what is the airspeed velocity of an unladen swallow?")
assert_nil answer
end
@ -74,7 +75,7 @@ class TestGemStreamUI < Gem::TestCase
def test_ask_yes_no_no_tty_with_default
@in.tty = false
Timeout.timeout(0.1) do
Timeout.timeout(SHORT_TIMEOUT) do
answer = @sui.ask_yes_no("do coconuts migrate?", false)
assert_equal false, answer
@ -86,7 +87,7 @@ class TestGemStreamUI < Gem::TestCase
def test_ask_yes_no_no_tty_without_default
@in.tty = false
Timeout.timeout(0.1) do
Timeout.timeout(SHORT_TIMEOUT) do
assert_raises(Gem::OperationNotSupportedError) do
@sui.ask_yes_no("do coconuts migrate?")
end