File: script_processor_test.rb

package info (click to toggle)
ruby-byebug 11.1.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,252 kB
  • sloc: ruby: 8,835; ansic: 1,662; sh: 6; makefile: 4
file content (42 lines) | stat: -rw-r--r-- 912 bytes parent folder | download | duplicates (3)
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