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

Close leaked file descripters in tests

This commit is contained in:
aycabta 2019-06-03 03:38:39 +09:00
parent 3428922437
commit 1bfba99b79
2 changed files with 7 additions and 1 deletions

View file

@ -5,7 +5,11 @@ class Reline::MacroTest < Reline::TestCase
@config = Reline::Config.new
@line_editor = Reline::LineEditor.new(@config)
@line_editor.instance_variable_set(:@screen_size, [24, 80])
@line_editor.output = File.open(IO::NULL, "w")
@output = @line_editor.output = File.open(IO::NULL, "w")
end
def teardown
@output.close
end
def input_key(char, combined_char = char, with_meta = false)

View file

@ -5,6 +5,7 @@ class Reline::WithinPipeTest < Reline::TestCase
Reline.send(:test_mode)
@reader, @writer = IO.pipe((RELINE_TEST_ENCODING rescue Encoding.default_external))
Reline.input = @reader
@output = Reline.output = File.open(IO::NULL, 'w')
@config = Reline.class_variable_get(:@@config)
@line_editor = Reline.class_variable_get(:@@line_editor)
end
@ -14,6 +15,7 @@ class Reline::WithinPipeTest < Reline::TestCase
Reline.output = STDOUT
@reader.close
@writer.close
@output.close
@config.reset
end