mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test/readline/test_readline.rb: suppress bell
* test/readline/test_readline.rb (replace_stdio, with_pipe): suppress bell. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c746b6fa42
commit
664a13b732
1 changed files with 10 additions and 0 deletions
|
@ -372,13 +372,16 @@ class TestReadline < Test::Unit::TestCase
|
||||||
open(stdout_path, "w"){|stdout|
|
open(stdout_path, "w"){|stdout|
|
||||||
orig_stdin = STDIN.dup
|
orig_stdin = STDIN.dup
|
||||||
orig_stdout = STDOUT.dup
|
orig_stdout = STDOUT.dup
|
||||||
|
orig_stderr = STDERR.dup
|
||||||
STDIN.reopen(stdin)
|
STDIN.reopen(stdin)
|
||||||
STDOUT.reopen(stdout)
|
STDOUT.reopen(stdout)
|
||||||
|
STDERR.reopen(stdout)
|
||||||
begin
|
begin
|
||||||
Readline.input = STDIN
|
Readline.input = STDIN
|
||||||
Readline.output = STDOUT
|
Readline.output = STDOUT
|
||||||
yield
|
yield
|
||||||
ensure
|
ensure
|
||||||
|
STDERR.reopen(orig_stderr)
|
||||||
STDIN.reopen(orig_stdin)
|
STDIN.reopen(orig_stdin)
|
||||||
STDOUT.reopen(orig_stdout)
|
STDOUT.reopen(orig_stdout)
|
||||||
orig_stdin.close
|
orig_stdin.close
|
||||||
|
@ -398,13 +401,20 @@ class TestReadline < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_pipe
|
def with_pipe
|
||||||
|
stderr = nil
|
||||||
IO.pipe do |r, w|
|
IO.pipe do |r, w|
|
||||||
yield(r, w)
|
yield(r, w)
|
||||||
Readline.input = r
|
Readline.input = r
|
||||||
Readline.output = w.reopen(IO::NULL)
|
Readline.output = w.reopen(IO::NULL)
|
||||||
|
stderr = STDERR.dup
|
||||||
|
STDERR.reopen(w)
|
||||||
Readline.readline
|
Readline.readline
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
|
if stderr
|
||||||
|
STDERR.reopen(stderr)
|
||||||
|
stderr.close
|
||||||
|
end
|
||||||
Readline.input = STDIN
|
Readline.input = STDIN
|
||||||
Readline.output = STDOUT
|
Readline.output = STDOUT
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue