18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/minitest/silence_plugin.rb', line 18
def run_one_method(klass, method_name)
@original_stdin ||= $stdin.dup
@original_stdout ||= $stdout.dup
@original_stderr ||= $stderr.dup
output_reader, output_writer = IO.pipe
output_thread = Thread.new { output_reader.read }
result = begin
$stdout.reopen(output_writer)
$stderr.reopen(output_writer)
$stdin.reopen(File::NULL)
super
ensure
$stdout.reopen(@original_stdout)
$stderr.reopen(@original_stderr)
$stdin.reopen(@original_stdin)
output_writer.close
end
result.output = output_thread.value
result
ensure
output_reader.close
end
|