Use "in" and "out" options of "system" instead of "replace_stdio"
This commit is contained in:
parent
7a58ee9b96
commit
e939a5c29f
@ -119,9 +119,7 @@ module TestIRB
|
|||||||
yield(stdin, stdout)
|
yield(stdin, stdout)
|
||||||
stdin.close
|
stdin.close
|
||||||
stdout.flush
|
stdout.flush
|
||||||
replace_stdio(stdin.path, stdout.path) do
|
system('ruby', '-Ilib', '-Itest', '-W0', '-rirb', '-e', 'IRB.start(__FILE__)', in: stdin.path, out: stdout.path)
|
||||||
system('ruby', '-Ilib', '-Itest', '-W0', '-rirb', '-e', 'IRB.start(__FILE__)')
|
|
||||||
end
|
|
||||||
result = stdout.read
|
result = stdout.read
|
||||||
stdout.close
|
stdout.close
|
||||||
end
|
end
|
||||||
@ -147,30 +145,5 @@ module TestIRB
|
|||||||
end
|
end
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user