summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2020-08-19 11:09:18 +0900
committeraycabta <aycabta@gmail.com>2020-08-19 11:18:50 +0900
commite939a5c29f3ca57e852d69cbecac2936035e96c7 (patch)
tree48056be9f5b77b4e7827295f1267c8d55eae52e6
parent7a58ee9b962ad0072e5213d3512c809048e4eba1 (diff)
Use "in" and "out" options of "system" instead of "replace_stdio"
-rw-r--r--test/irb/test_history.rb29
1 files changed, 1 insertions, 28 deletions
diff --git a/test/irb/test_history.rb b/test/irb/test_history.rb
index f9193e553a..b811bbe273 100644
--- a/test/irb/test_history.rb
+++ b/test/irb/test_history.rb
@@ -119,9 +119,7 @@ module TestIRB
yield(stdin, stdout)
stdin.close
stdout.flush
- replace_stdio(stdin.path, stdout.path) do
- system('ruby', '-Ilib', '-Itest', '-W0', '-rirb', '-e', 'IRB.start(__FILE__)')
- end
+ system('ruby', '-Ilib', '-Itest', '-W0', '-rirb', '-e', 'IRB.start(__FILE__)', in: stdin.path, out: stdout.path)
result = stdout.read
stdout.close
end
@@ -147,30 +145,5 @@ module TestIRB
end
end
end
-
- def replace_stdio(stdin_path, stdout_path)
- open(stdin_path, "r") do |stdin|
- open(stdout_path, "w") do |stdout|
- orig_stdin = STDIN.dup
- orig_stdout = STDOUT.dup
- orig_stderr = STDERR.dup
- STDIN.reopen(stdin)
- STDOUT.reopen(stdout)
- STDERR.reopen(stdout)
- begin
- #Readline.input = STDIN
- #Readline.output = STDOUT
- yield
- ensure
- STDERR.reopen(orig_stderr)
- STDIN.reopen(orig_stdin)
- STDOUT.reopen(orig_stdout)
- orig_stdin.close
- orig_stdout.close
- orig_stderr.close
- end
- end
- end
- end
end
end