byebug 3.4.2 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,11 +49,11 @@ module Byebug
49
49
  check_output_includes "[1, 12] in #{__FILE__}"
50
50
  end
51
51
 
52
- def test_moves_range_down_when_it_goes_after_the_end_of_file
52
+ def test_does_not_list_after_the_end_of_file
53
53
  n_lines = %x{wc -l #{__FILE__}}.split.first.to_i
54
54
  enter 'break 18', 'cont', "list #{n_lines-3}-#{n_lines+6}"
55
55
  debug_proc(@example)
56
- check_output_includes "[#{n_lines-9}, #{n_lines}] in #{__FILE__}"
56
+ check_output_includes "[#{n_lines-3}, #{n_lines}] in #{__FILE__}"
57
57
  end
58
58
 
59
59
  def test_lists_the_whole_file_if_number_of_lines_is_smaller_than_listsize
@@ -118,13 +118,13 @@ module Byebug
118
118
  debug_proc(@example)
119
119
  check_error_includes 'Invalid line range'
120
120
  check_output_doesnt_include "[500, 505] in #{__FILE__}"
121
- check_output_doesnt_include(/^500 \S/)
122
121
  end
123
122
 
124
123
  def test_lists_nothing_if_invalid_range_is_specified
125
124
  enter 'list 5,4'
126
125
  debug_proc(@example)
127
- check_output_includes "[5, 4] in #{__FILE__}"
126
+ check_error_includes 'Invalid line range'
127
+ check_output_doesnt_include "[5, 4] in #{__FILE__}"
128
128
  end
129
129
 
130
130
  def test_list_proper_lines_when_range_around_specific_line_with_hyphen
@@ -150,17 +150,9 @@ module Byebug
150
150
  debug_proc(@example)
151
151
  check_output_includes "26: a = '%26'"
152
152
  end
153
- end
154
-
155
- class ListTestCaseAutoreload < ListTestCase
156
- def setup
157
- super
158
- Setting[:autoreload] = true
159
- enter 'list' # force first reading of file
160
- end
161
153
 
162
- def test_lists_file_changes_with_autoreload_enabled
163
- enter -> do
154
+ def test_lists_file_changes_by_default
155
+ enter 'list', -> do
164
156
  change_line_in_file(__FILE__, 7, ' a = 100')
165
157
  'list 7-7'
166
158
  end
@@ -168,20 +160,12 @@ module Byebug
168
160
  check_output_includes(/7:\s+a = 100/)
169
161
  change_line_in_file(__FILE__, 7, ' a = 7')
170
162
  end
171
- end
172
-
173
- class ListTestCaseNoAutoreload < ListTestCase
174
- def setup
175
- super
176
- Setting[:autoreload] = false
177
- enter 'list' # force first reading of file
178
- end
179
163
 
180
164
  def test_does_not_list_file_changes_with_autoreload_disabled
181
- enter -> do
165
+ enter 'set noautoreload', 'list', -> do
182
166
  change_line_in_file(__FILE__, 7, ' a = 100')
183
167
  'list 7-7'
184
- end
168
+ end, 'set autoreload'
185
169
  debug_proc(@example)
186
170
  check_output_doesnt_include(/7:\s+a = 100/)
187
171
  change_line_in_file(__FILE__, 7, ' a = 7')
@@ -1,10 +1,3 @@
1
- begin
2
- require 'pry'
3
- has_pry = true
4
- rescue LoadError
5
- has_pry = false
6
- end
7
-
8
1
  module Byebug
9
2
  class PryTestCase < TestCase
10
3
  def setup
@@ -30,4 +23,4 @@ module Byebug
30
23
  skip 'TODO'
31
24
  end
32
25
  end
33
- end if has_pry
26
+ end if defined?(Pry)
@@ -21,7 +21,6 @@ module Byebug
21
21
  def must_restart(cmd = nil)
22
22
  expectation = RestartCommand.any_instance.expects(:exec)
23
23
  expectation = expectation.with(cmd) if cmd
24
- expectation
25
24
  end
26
25
 
27
26
  def test_restarts_with_manual_arguments
@@ -32,35 +31,18 @@ module Byebug
32
31
  enter 'restart 1 2 3'
33
32
  debug_proc(@example)
34
33
  check_output_includes "Re exec'ing:\n\t#{cmd}"
35
- end
36
-
37
- def test_restart_with_a_default_script_if_nil_script_specified
38
- force_set_const(Byebug, 'BYEBUG_SCRIPT', 'byebug_script')
39
- Byebug.debugged_program = nil
40
- must_restart
41
-
42
- enter 'restart'
43
- debug_proc(@example)
44
- check_output_includes(/Re exec'ing:\s*#{BYEBUG_SCRIPT} #{$PROGRAM_NAME}/)
45
- end
46
-
47
- def test_does_not_restart_when_script_specified_does_not_exist
48
- Byebug.debugged_program = 'blabla'
49
- must_restart.never
50
- enter 'restart'
51
- debug_proc(@example)
52
- check_error_includes 'Ruby program blabla doesn\'t exist'
34
+ force_unset_const(Byebug, 'BYEBUG_SCRIPT')
53
35
  end
54
36
 
55
37
  def test_still_restarts_when_byebug_attached_to_running_program
56
- force_unset_const(Byebug, 'BYEBUG_SCRIPT')
57
38
  must_restart
58
39
  enter 'restart'
40
+
59
41
  debug_proc(@example)
60
42
  check_output_includes 'Byebug was not called from the outset...'
61
43
  check_output_includes \
62
- "Ruby program #{Byebug.debugged_program} not executable... " \
63
- "We'll wrap it in a ruby call"
44
+ "Program #{Byebug.debugged_program} not executable... " \
45
+ "Wrapping it in a ruby call"
64
46
  end
65
47
  end
66
48
  end
@@ -53,15 +53,15 @@ module Byebug
53
53
  def test_save_without_a_filename_uses_a_default_file
54
54
  enter 'save'
55
55
  debug_proc(@example)
56
- assert_includes File.read(interface.restart_file), 'set autoirb false'
57
- File.delete(interface.restart_file)
56
+ assert_includes File.read(RESTART_FILE), 'set autoirb false'
57
+ File.delete(RESTART_FILE)
58
58
  end
59
59
 
60
60
  def test_save_without_a_filename_shows_a_message_with_the_file_used
61
61
  enter 'save'
62
62
  debug_proc(@example)
63
- check_output_includes "Saved to '#{interface.restart_file}'"
64
- File.delete(interface.restart_file)
63
+ check_output_includes "Saved to '#{RESTART_FILE}'"
64
+ File.delete(RESTART_FILE)
65
65
  end
66
66
  end
67
67
  end
@@ -105,6 +105,7 @@ module Byebug
105
105
  debug_proc(@example)
106
106
  assert_equal filename, Setting[:histfile]
107
107
  check_output_includes "The command history file is #{filename}"
108
+ Setting[:histfile] = HistfileSetting::DEFAULT
108
109
  end
109
110
 
110
111
  def test_set_histfile_shows_an_error_message_if_no_filename_is_provided
@@ -47,49 +47,56 @@ module Byebug
47
47
 
48
48
  assert_raises(SystemExit) { @runner.run }
49
49
 
50
- check_output_includes(/You must specify a program to debug.../)
50
+ check_error_includes(/You must specify a program to debug.../)
51
51
  end
52
52
 
53
- def expect_it_debugs_script
53
+ def test_run_with_an_nonexistent_script
54
+ ARGV.replace(%w(non_existent_script.rb))
55
+
56
+ assert_raises(SystemExit) { @runner.run }
57
+
58
+ check_error_includes("The script doesn't exist")
59
+ end
60
+
61
+ def expect_it_debugs_script(rc = true)
54
62
  Byebug.expects(:start)
55
- Byebug::Runner.any_instance.expects(:debug_program)
56
- Byebug.expects(:run_init_script)
63
+ rc_expectation = Byebug.expects(:run_init_script)
64
+ rc_expectation.never unless rc
65
+ @runner.expects(:debug_program)
57
66
  end
58
67
 
59
68
  def test_run_with_a_script_to_debug
60
- ARGV.replace(%w(my_script))
69
+ ARGV.replace(%w(lib/byebug.rb))
61
70
  expect_it_debugs_script
62
71
 
63
72
  @runner.run
64
73
  end
65
74
 
66
75
  def test_run_with_a_script_and_params_does_not_consume_script_params
67
- ARGV.replace(%w(-- my_script -opt value))
76
+ ARGV.replace(%w(-- lib/byebug.rb -opt value))
68
77
  expect_it_debugs_script
69
78
 
70
79
  @runner.run
71
- assert_equal %w(my_script -opt value), ARGV
80
+ assert_equal %w(lib/byebug.rb -opt value), ARGV
72
81
  end
73
82
 
74
83
  def test_run_with_ruby_script_ruby_is_ignored_and_script_passed_instead
75
- ARGV.replace(%w(-- ruby ruby_script))
84
+ ARGV.replace(%w(-- ruby lib/byebug.rb))
76
85
  expect_it_debugs_script
77
86
 
78
87
  @runner.run
79
- assert_equal %w(ruby_script), ARGV
88
+ assert_equal %w(lib/byebug.rb), ARGV
80
89
  end
81
90
 
82
91
  def test_run_with_no_rc_option
83
- ARGV.replace(%w(--no-rc my_script))
84
- Byebug.expects(:start)
85
- Byebug::Runner.any_instance.expects(:debug_program)
86
- Byebug.expects(:run_init_script).never
92
+ ARGV.replace(%w(--no-rc lib/byebug.rb))
93
+ expect_it_debugs_script(false)
87
94
 
88
95
  @runner.run
89
96
  end
90
97
 
91
98
  def test_run_with_post_mortem_mode_flag
92
- ARGV.replace(%w(-m my_script))
99
+ ARGV.replace(%w(-m lib/byebug.rb))
93
100
  expect_it_debugs_script
94
101
  @runner.run
95
102
 
@@ -98,7 +105,7 @@ module Byebug
98
105
  end
99
106
 
100
107
  def test_run_with_linetracing_flag
101
- ARGV.replace(%w(-t my_script))
108
+ ARGV.replace(%w(-t lib/byebug.rb))
102
109
  expect_it_debugs_script
103
110
  @runner.run
104
111
 
@@ -108,14 +115,14 @@ module Byebug
108
115
 
109
116
  def test_run_with_no_quit_flag
110
117
  skip 'for now'
111
- ARGV.replace(%w(--no-quit my_script))
118
+ ARGV.replace(%w(--no-quit lib/byebug.rb))
112
119
  @runner.run
113
120
 
114
121
  check_output_includes('(byebug:ctrl)')
115
122
  end
116
123
 
117
124
  def test_run_with_require_flag
118
- ARGV.replace(%w(-r abbrev my_script))
125
+ ARGV.replace(%w(-r abbrev lib/byebug.rb))
119
126
  expect_it_debugs_script
120
127
  @runner.run
121
128
 
@@ -124,7 +131,7 @@ module Byebug
124
131
  end
125
132
 
126
133
  def test_run_with_include_flag
127
- ARGV.replace(%w(-I custom_dir my_script))
134
+ ARGV.replace(%w(-I custom_dir lib/byebug.rb))
128
135
  expect_it_debugs_script
129
136
  @runner.run
130
137
 
@@ -132,7 +139,7 @@ module Byebug
132
139
  end
133
140
 
134
141
  def test_run_with_debug_flag
135
- ARGV.replace(%w(-d my_script))
142
+ ARGV.replace(%w(-d lib/byebug.rb))
136
143
  expect_it_debugs_script
137
144
  @runner.run
138
145
 
@@ -1,18 +1,16 @@
1
- require 'byebug/history'
2
-
3
1
  module Byebug
4
2
  #
5
3
  # Custom interface for easier assertions
6
4
  #
7
5
  class TestInterface < Interface
8
- attr_reader :input_queue, :output_queue, :error_queue, :confirm_queue,
9
- :history
6
+ attr_reader :input_queue, :output_queue, :error_queue, :confirm_queue
10
7
 
11
8
  attr_accessor :test_block
12
9
 
13
10
  def initialize
14
- @input_queue, @output_queue, @error_queue = [], [], []
15
- @confirm_queue, @command_queue, @history = [], [], History.new
11
+ super()
12
+ @input_queue, @output_queue = [], []
13
+ @error_queue, @confirm_queue = [], []
16
14
  end
17
15
 
18
16
  def errmsg(*args)
@@ -20,14 +18,11 @@ module Byebug
20
18
  end
21
19
 
22
20
  def read_command(*)
23
- if @input_queue.empty?
24
- if test_block
25
- test_block.call
26
- self.test_block = nil
27
- end
28
- else
29
- result = @input_queue.shift
30
- result.is_a?(Proc) ? result.call : result
21
+ return readline(true) unless @input_queue.empty?
22
+
23
+ if test_block
24
+ test_block.call
25
+ self.test_block = nil
31
26
  end
32
27
  end
33
28
 
@@ -37,7 +32,7 @@ module Byebug
37
32
 
38
33
  def confirm(message)
39
34
  @confirm_queue << message
40
- read_command message
35
+ readline(false)
41
36
  end
42
37
 
43
38
  def close
@@ -51,5 +46,14 @@ module Byebug
51
46
  "confirm_queue: #{confirm_queue.inspect}"
52
47
  ].join("\n")
53
48
  end
49
+
50
+ private
51
+
52
+ def readline(hist)
53
+ cmd = @input_queue.shift
54
+ cmd = cmd.is_a?(Proc) ? cmd.call : cmd
55
+ save_history(cmd) unless !hist
56
+ cmd
57
+ end
54
58
  end
55
59
  end
@@ -28,14 +28,11 @@ module Byebug
28
28
 
29
29
  Byebug::Setting.load
30
30
  Byebug::Setting[:autolist] = false
31
+ Byebug::Setting[:autosave] = false
31
32
  Byebug::Setting[:testing] = true
32
33
  Byebug::Setting[:width] = 80
33
34
 
34
- byebug_bin = File.expand_path('../../../bin/byebug', __FILE__)
35
- force_set_const(Byebug, 'BYEBUG_SCRIPT', byebug_bin)
36
- Byebug.debugged_program = $PROGRAM_NAME
37
-
38
- # include test files as ignored files
35
+ # Include test files as ignored files
39
36
  glob_exp = File.expand_path('../../{lib,test/support}/**/*.rb', __FILE__)
40
37
  ignored_files = Dir.glob(glob_exp) + ['test/test_helper.rb']
41
38
  force_set_const(Byebug, 'IGNORED_FILES', ignored_files)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: byebug
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.2
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rodriguez
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-09-26 00:00:00.000000000 Z
13
+ date: 2014-09-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: columnize