1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 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
|
# frozen_string_literal: true
require "test_helper"
module Byebug
#
# Tests script processor in isolation
#
class ScriptProcessorTest < Minitest::Test
include TestUtils
def test_script_processor_clears_history
previous_history = Readline::HISTORY.to_a
process_rc_file("set callstyle long")
assert_equal previous_history, Readline::HISTORY.to_a
end
def test_script_processor_closes_files
process_rc_file("set callstyle long")
assert_equal 0, dangling_descriptors.count
end
private
def dangling_descriptors
ObjectSpace.each_object(File).select do |f|
f.path == Byebug.init_file && !f.closed?
end
end
def process_rc_file(content)
with_init_file(content) do
interface = ScriptInterface.new(Byebug.init_file)
ScriptProcessor.new(nil, interface).process_commands
end
end
end
end
|