byebug 2.1.1 → 2.2.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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +9 -0
  4. data/CONTRIBUTING.md +13 -1
  5. data/GUIDE.md +181 -1
  6. data/README.md +67 -211
  7. data/Rakefile +1 -0
  8. data/bin/byebug +1 -8
  9. data/ext/byebug/byebug.c +66 -25
  10. data/ext/byebug/context.c +16 -20
  11. data/ext/byebug/extconf.rb +2 -1
  12. data/lib/byebug.rb +16 -9
  13. data/lib/byebug/command.rb +3 -3
  14. data/lib/byebug/commands/condition.rb +2 -2
  15. data/lib/byebug/commands/edit.rb +12 -9
  16. data/lib/byebug/commands/eval.rb +0 -16
  17. data/lib/byebug/commands/frame.rb +7 -17
  18. data/lib/byebug/commands/info.rb +2 -9
  19. data/lib/byebug/commands/list.rb +1 -1
  20. data/lib/byebug/commands/reload.rb +11 -0
  21. data/lib/byebug/commands/repl.rb +3 -6
  22. data/lib/byebug/commands/set.rb +5 -5
  23. data/lib/byebug/commands/show.rb +5 -0
  24. data/lib/byebug/commands/threads.rb +4 -4
  25. data/lib/byebug/commands/trace.rb +2 -1
  26. data/lib/byebug/context.rb +14 -5
  27. data/lib/byebug/interface.rb +1 -1
  28. data/lib/byebug/processor.rb +1 -1
  29. data/lib/byebug/remote.rb +1 -24
  30. data/lib/byebug/version.rb +1 -1
  31. data/old_doc/byebug.1 +0 -3
  32. data/old_doc/byebug.texi +2 -3
  33. data/test/breakpoints_test.rb +75 -52
  34. data/test/conditions_test.rb +2 -3
  35. data/test/continue_test.rb +6 -0
  36. data/test/edit_test.rb +3 -3
  37. data/test/eval_test.rb +14 -5
  38. data/test/examples/breakpoint.rb +4 -13
  39. data/test/examples/breakpoint_deep.rb +1 -21
  40. data/test/examples/conditions.rb +1 -1
  41. data/test/examples/continue.rb +2 -1
  42. data/test/examples/edit.rb +1 -0
  43. data/test/examples/eval.rb +1 -11
  44. data/test/examples/finish.rb +0 -17
  45. data/test/examples/frame.rb +2 -26
  46. data/test/examples/frame_deep.rb +0 -19
  47. data/test/examples/help.rb +0 -1
  48. data/test/examples/info.rb +4 -36
  49. data/test/examples/kill.rb +1 -1
  50. data/test/examples/list.rb +1 -1
  51. data/test/examples/method.rb +2 -13
  52. data/test/examples/post_mortem.rb +1 -16
  53. data/test/examples/quit.rb +1 -1
  54. data/test/examples/reload.rb +1 -1
  55. data/test/examples/restart.rb +1 -1
  56. data/test/examples/show.rb +0 -1
  57. data/test/examples/stepping.rb +2 -19
  58. data/test/examples/thread.rb +0 -27
  59. data/test/examples/variables.rb +0 -22
  60. data/test/finish_test.rb +22 -6
  61. data/test/frame_test.rb +89 -56
  62. data/test/info_test.rb +71 -46
  63. data/test/kill_test.rb +6 -1
  64. data/test/list_test.rb +1 -2
  65. data/test/method_test.rb +32 -13
  66. data/test/post_mortem_test.rb +34 -21
  67. data/test/quit_test.rb +0 -1
  68. data/test/restart_test.rb +6 -0
  69. data/test/set_test.rb +1 -1
  70. data/test/show_test.rb +17 -17
  71. data/test/source_test.rb +2 -3
  72. data/test/stepping_test.rb +31 -7
  73. data/test/support/test_dsl.rb +11 -1
  74. data/test/test_helper.rb +9 -0
  75. data/test/thread_test.rb +57 -23
  76. data/test/trace_test.rb +0 -1
  77. data/test/variables_test.rb +36 -17
  78. metadata +3 -9
  79. data/test/examples/breakpoint2.rb +0 -7
  80. data/test/examples/jump.rb +0 -14
  81. data/test/examples/set_annotate.rb +0 -12
@@ -4,23 +4,7 @@ module Byebug
4
4
  module EvalFunctions
5
5
  def run_with_binding
6
6
  binding = get_binding
7
- $__dbg_interface = @state.interface
8
- eval(<<-EOC, binding)
9
- __dbg_verbose_save=$VERBOSE; $VERBOSE=false
10
- def dbg_print(*args)
11
- $__dbg_interface.print(*args)
12
- end
13
- remove_method :puts if self.respond_to?(:puts) &&
14
- defined?(remove_method)
15
- def dbg_puts(*args)
16
- $__dbg_interface.print(*args)
17
- $__dbg_interface.print("\n")
18
- end
19
- $VERBOSE=__dbg_verbose_save
20
- EOC
21
7
  yield binding
22
- ensure
23
- $__dbg_interface = nil
24
8
  end
25
9
  end
26
10
 
@@ -43,14 +43,10 @@ module Byebug
43
43
  return errmsg "Can't navigate beyond the newest frame\n" if
44
44
  abs_frame_pos < 0
45
45
 
46
- if @state.frame_pos != abs_frame_pos
47
- @state.previous_line = nil
48
- @state.frame_pos = abs_frame_pos
49
- end
50
-
46
+ @state.frame_pos = abs_frame_pos
51
47
  @state.file = @state.context.frame_file @state.frame_pos
52
48
  @state.line = @state.context.frame_line @state.frame_pos
53
-
49
+ @state.previous_line = nil
54
50
  ListCommand.new(@state).execute
55
51
  end
56
52
 
@@ -103,17 +99,11 @@ module Byebug
103
99
  end
104
100
 
105
101
  def print_backtrace
106
- if Byebug.post_mortem?
107
- realsize = @state.context.stack_size
108
- else
109
- realsize = Thread.current.backtrace_locations(1).
110
- drop_while{ |l| IGNORED_FILES.include?(l.path) || l.path == '(eval)' }.
111
- take_while{ |l| !IGNORED_FILES.include?(l.path) }.size
112
- size = @state.context.stack_size
113
- if size != realsize
114
- errmsg "Byebug's stacksize (#{size}) should be #{realsize}. " \
115
- "This might be a bug in byebug or ruby's debugging API's\n"
116
- end
102
+ realsize = Context.real_stack_size
103
+ size = @state.context.stack_size
104
+ if size != realsize
105
+ errmsg "Byebug's stacksize (#{size}) should be #{realsize}. " \
106
+ "This might be a bug in byebug or ruby's debugging API's\n"
117
107
  end
118
108
  (0...realsize).each do |idx|
119
109
  print_frame(idx)
@@ -134,7 +134,7 @@ module Byebug
134
134
 
135
135
  def info_file_path(file)
136
136
  print "File #{file}"
137
- path = LineCache.path(file)
137
+ path = File.expand_path(file)
138
138
  print " - #{path}\n" if path and path != file
139
139
  end
140
140
  private :info_file_path
@@ -171,12 +171,6 @@ module Byebug
171
171
  subcmd = Command.find(InfoFileSubcommands, args[1] || 'basic')
172
172
  return errmsg "Invalid parameter #{args[1]}\n" unless subcmd
173
173
 
174
- unless LineCache::cached?(args[0])
175
- return print "File #{args[0]} is not cached\n" unless
176
- LineCache::cached_script?(args[0])
177
- LineCache::cache(args[0], Command.settings[:autoreload])
178
- end
179
-
180
174
  if %w(all basic).member?(subcmd.name)
181
175
  info_file_path(args[0])
182
176
  info_file_lines(args[0])
@@ -192,8 +186,7 @@ module Byebug
192
186
  end
193
187
 
194
188
  def info_files(*args)
195
- files = LineCache::cached_files
196
- files += SCRIPT_LINES__.keys unless 'stat' == args[0]
189
+ files = SCRIPT_LINES__.keys
197
190
  files.uniq.sort.each do |file|
198
191
  info_file_path(file)
199
192
  info_file_mtime(file)
@@ -19,7 +19,7 @@ module Byebug
19
19
 
20
20
  def execute
21
21
  Byebug.source_reload if Command.settings[:autoreload]
22
- lines = LineCache::getlines @state.file, Command.settings[:autoreload]
22
+ lines = getlines(@state.file, @state.line)
23
23
  if !lines
24
24
  errmsg "No sourcefile available for #{@state.file}\n"
25
25
  return @state.previous_line
@@ -1,5 +1,16 @@
1
1
  module Byebug
2
2
 
3
+ module ReloadFunctions
4
+ def getlines(file, line)
5
+ unless (lines = SCRIPT_LINES__[file]) and lines != true
6
+ Tracer::Single.get_line(file, line) if File.exist?(file)
7
+ lines = SCRIPT_LINES__[file]
8
+ lines = nil if lines == true
9
+ end
10
+ lines
11
+ end
12
+ end
13
+
3
14
  # Implements byebug "reload" command.
4
15
  class ReloadCommand < Command
5
16
  self.allow_in_control = true
@@ -1,5 +1,3 @@
1
- require 'irb'
2
-
3
1
  module IRB
4
2
  module ExtendCommand
5
3
  class Continue
@@ -18,12 +16,14 @@ module IRB
18
16
  end
19
17
  end
20
18
  end
19
+
20
+ require 'irb'
21
21
  ExtendCommandBundle.def_extend_command "cont", :Continue
22
22
  ExtendCommandBundle.def_extend_command "n", :Next
23
23
  ExtendCommandBundle.def_extend_command "step", :Step
24
24
 
25
25
  def self.start_session(binding)
26
- unless @__initialized
26
+ unless @__initialized ||= false
27
27
  args = ARGV.dup
28
28
  ARGV.replace([])
29
29
  IRB.setup(nil)
@@ -51,7 +51,6 @@ module Byebug
51
51
 
52
52
  # Implements byebug's "irb" command.
53
53
  class IRBCommand < Command
54
-
55
54
  register_setting_get(:autoirb) do
56
55
  IRBCommand.always_run
57
56
  end
@@ -82,8 +81,6 @@ module Byebug
82
81
  @state.context.step_over 1, @state.frame_pos, force
83
82
  @state.proceed
84
83
  else
85
- file = @state.context.frame_file(0)
86
- line = @state.context.frame_line(0)
87
84
  print @state.location
88
85
  @state.previous_line = nil
89
86
  end
@@ -21,6 +21,8 @@ module Byebug
21
21
  else
22
22
  print "Invalid callstyle. Should be one of: \"short\" or \"long\"\n"
23
23
  end
24
+ when /^verbose$/
25
+ Byebug.verbose = setting_value
24
26
  when /^history$/
25
27
  try_subcmd = setting_args[0]
26
28
  subcmd = Command.find(SetCommand::SetHistorySubcommands, try_subcmd)
@@ -49,11 +51,7 @@ module Byebug
49
51
  return unless width = get_int(setting_args[0], "Set width", 10, nil, 80)
50
52
  Command.settings[:width] = width
51
53
  when /^post_mortem$/
52
- if setting_value
53
- Byebug.post_mortem
54
- else
55
- Byebug.post_mortem = false
56
- end
54
+ Byebug.post_mortem = setting_value
57
55
  when /^autoeval|autoreload|basename|forcestep|fullpath|linetrace_plus|
58
56
  testing|stack_trace_on_error$/x
59
57
  Command.settings[setting_name.to_sym] = setting_value
@@ -95,6 +93,8 @@ module Byebug
95
93
  ['post_mortem', 2, true, 'Enable post-mortem mode'],
96
94
  ['stack_trace_on_error', 1, true,
97
95
  'Display stack trace when "eval" raises exception'],
96
+ ['verbose', 1, true,
97
+ 'Enable verbose output of TracePoint API events is enabled'],
98
98
  ['width', 1, false,
99
99
  'Number of characters per line for byebug\'s output']
100
100
  ].map do |name, min, is_bool, short_help, long_help|
@@ -131,6 +131,9 @@ module Byebug
131
131
  when /^stack_trace_on_error$/
132
132
  on_off = Command.settings[:stack_trace_on_error]
133
133
  return "Displaying stack trace is #{show_onoff(on_off)}."
134
+ when /^verbose$/
135
+ on_off = Byebug.verbose
136
+ return "Verbose output of TracePoint API events is #{show_onoff(on_off)}."
134
137
  when /^version$/
135
138
  return "Byebug #{Byebug::VERSION}"
136
139
  when /^width$/
@@ -175,6 +178,8 @@ module Byebug
175
178
  'debugging on an uncaught exception'],
176
179
  ['stack_trace_on_error', 1, 'Show whether a stack trace is displayed ' \
177
180
  'when "eval" raises an exception'],
181
+ ['verbose', 4, true,
182
+ 'Show whether verbose output for debugging byebug itself is enabled'],
178
183
  ['version', 1, 'Show byebug\'s version'],
179
184
  ['width', 1, 'Show the number of characters per line for byebug']
180
185
  ].map do |name, min, short_help, long_help|
@@ -18,10 +18,10 @@ module Byebug
18
18
  file = @state.context.frame_file(0)
19
19
  line = @state.context.frame_line(0)
20
20
  else
21
- if context.thread.backtrace_locations(1) &&
22
- context.thread.backtrace_locations(1)[0]
23
- file = context.thread.backtrace_locations(1)[0].path
24
- line = context.thread.backtrace_locations(1)[0].lineno
21
+ if context.thread.backtrace_locations &&
22
+ context.thread.backtrace_locations[0]
23
+ file = context.thread.backtrace_locations[0].path
24
+ line = context.thread.backtrace_locations[0].lineno
25
25
  end
26
26
  end
27
27
  file_line = "#{file}:#{line}"
@@ -21,10 +21,11 @@ module Byebug
21
21
  else
22
22
  dbg_cmd = (@match[3] && @match[3] !~ /nostop/) ? 'byebug(1,0)' : ''
23
23
  end
24
- eval("trace_var(:#{varname}) do |val|
24
+ eval("trace_var(:\"#{varname}\") do |val|
25
25
  print \"traced variable \#{varname} has value \#{val}\n\"
26
26
  #{dbg_cmd}
27
27
  end")
28
+ print "Tracing variable \"#{varname}\".\n"
28
29
  else
29
30
  errmsg "#{varname} is not a global variable.\n"
30
31
  end
@@ -1,13 +1,22 @@
1
1
  module Byebug
2
2
 
3
- class << self
3
+ class Context
4
4
 
5
- # interface modules provide +handler+ object
6
- attr_accessor :handler
5
+ class << self
6
+ def real_stack_size
7
+ if backtrace = Thread.current.backtrace_locations
8
+ backtrace.drop_while { |l| ignored(l.path) || l.path == '(eval)' }
9
+ .take_while { |l| !ignored(l.path) }
10
+ .size
11
+ end
12
+ end
7
13
 
8
- end
14
+ def ignored(path)
15
+ IGNORED_FILES.include?(path)
16
+ end
17
+ private :ignored
18
+ end
9
19
 
10
- class Context
11
20
  def frame_locals frame_no = 0
12
21
  bind = frame_binding frame_no
13
22
  eval "local_variables.inject({}){|h, v| h[v] = eval(v.to_s); h}", bind
@@ -98,7 +98,7 @@ module Byebug
98
98
 
99
99
  def readline(prompt, hist)
100
100
  Readline::readline(prompt, hist)
101
- rescue Interrupt => e
101
+ rescue Interrupt
102
102
  print "^C\n"
103
103
  retry
104
104
  end
@@ -52,7 +52,6 @@ module Byebug
52
52
  if Command.settings[:basename]
53
53
  File.basename(filename)
54
54
  else
55
- # Cache this?
56
55
  Pathname.new(filename).cleanpath.to_s
57
56
  end
58
57
  end
@@ -109,6 +108,7 @@ module Byebug
109
108
  protect :at_tracing
110
109
 
111
110
  def at_line(context, file, line)
111
+ Byebug.source_reload if Command.settings[:autoreload]
112
112
  process_commands(context, file, line)
113
113
  end
114
114
  protect :at_line
@@ -19,21 +19,12 @@ module Byebug
19
19
  self.interface = nil
20
20
  start
21
21
 
22
- if port.kind_of?(Array)
23
- cmd_port, ctrl_port = port
24
- else
25
- cmd_port, ctrl_port = port, port + 1
26
- end
27
-
28
- ctrl_port = start_control(host, ctrl_port)
29
-
30
22
  yield if block_given?
31
23
 
32
24
  mutex = Mutex.new
33
25
  proceed = ConditionVariable.new
34
26
 
35
- server = TCPServer.new(host, cmd_port)
36
- @cmd_port = cmd_port = server.addr[1]
27
+ server = TCPServer.new(host, port)
37
28
  @thread = DebugThread.new do
38
29
  while (session = server.accept)
39
30
  self.interface = RemoteInterface.new(session)
@@ -51,20 +42,6 @@ module Byebug
51
42
  end
52
43
  end
53
44
 
54
- def start_control(host = nil, ctrl_port = PORT + 1)
55
- return @ctrl_port if @control_thread
56
- server = TCPServer.new(host, ctrl_port)
57
- @ctrl_port = server.addr[1]
58
- @control_thread = Thread.new do
59
- while (session = server.accept)
60
- interface = RemoteInterface.new(session)
61
- ControlCommandProcessor.new(interface).process_commands
62
- processor.process_commands
63
- end
64
- end
65
- @ctrl_port
66
- end
67
-
68
45
  #
69
46
  # Connects to the remote byebug
70
47
  #
@@ -1,3 +1,3 @@
1
1
  module Byebug
2
- VERSION = '2.1.1'
2
+ VERSION = '2.2.0'
3
3
  end
@@ -174,9 +174,6 @@ Do not quit when script terminates. Instead rerun the program.
174
174
  .B \-\-version
175
175
  Show the version number and exit.
176
176
  .TP
177
- .B \-\-verbose
178
- Turn on verbose mode.
179
- .TP
180
177
  .B \-\-v
181
178
  Print the version number, then turn on verbose mode if a script name
182
179
  is given. If no script name is given just exit after printing the
@@ -929,7 +929,6 @@ Options:
929
929
  -x, --trace Turn on line tracing
930
930
 
931
931
  Common options:
932
- --verbose Turn on verbose mode
933
932
  --help Show this message
934
933
  --version Print the version
935
934
  -v Print version number, then turn on verbose mode
@@ -1056,8 +1055,8 @@ Here are the default values in @code{options}
1056
1055
  @smallexample
1057
1056
  #<OpenStruct server=false, client=false, frame_bind=false, cport=8990,
1058
1057
  tracing=false, nx=false, post_mortem=false, port=8989,
1059
- verbose_long=false, control=true, restart_script=nil, quit=true,
1060
- stop=true, script=nil, host=nil, wait=false>
1058
+ control=true, restart_script=nil, quit=true, stop=true, script=nil,
1059
+ host=nil, wait=false>
1061
1060
  @end smallexample
1062
1061
 
1063
1062
  @node Command Files
@@ -1,13 +1,39 @@
1
1
  require_relative 'test_helper'
2
2
 
3
+ class BreakpointExample
4
+ def self.a(num)
5
+ 4
6
+ end
7
+ def b
8
+ 3
9
+ end
10
+ end
11
+
12
+ class BreakpointDeepExample
13
+ def a
14
+ z = 2
15
+ b(z)
16
+ end
17
+
18
+ def b(num)
19
+ v2 = 5 if 1 == num ; [1,2,v2].map { |a| a.to_f }
20
+ c
21
+ end
22
+
23
+ def c
24
+ z = 4
25
+ z += 5
26
+ byebug
27
+ end
28
+ end
29
+
3
30
  class TestBreakpoints < TestDsl::TestCase
4
31
  before do
5
32
  @tst_file = fullpath('breakpoint')
6
- @tst_file_2 = fullpath('breakpoint2')
7
33
  end
8
34
 
9
35
  describe 'setting breakpoint in the current file' do
10
- before { enter 'break 10' }
36
+ before { enter 'break 1' }
11
37
 
12
38
  subject { Byebug.breakpoints.first }
13
39
 
@@ -15,7 +41,7 @@ class TestBreakpoints < TestDsl::TestCase
15
41
  debug_file('breakpoint') { subject.send(field).must_equal value }
16
42
  end
17
43
 
18
- it('must have correct pos') { check_subject(:pos, 10) }
44
+ it('must have correct pos') { check_subject(:pos, 1) }
19
45
  it('must have correct source') { check_subject(:source, @tst_file) }
20
46
  it('must have correct expression') { check_subject(:expr, nil) }
21
47
  it('must have correct hit count') { check_subject(:hit_count, 0) }
@@ -25,12 +51,12 @@ class TestBreakpoints < TestDsl::TestCase
25
51
  it('must return right response') do
26
52
  id = nil
27
53
  debug_file('breakpoint') { id = subject.id }
28
- check_output_includes "Created breakpoint #{id} at #{@tst_file}:10"
54
+ check_output_includes "Created breakpoint #{id} at #{@tst_file}:1"
29
55
  end
30
56
  end
31
57
 
32
58
  describe 'using shortcut for the command' do
33
- before { enter 'b 10' }
59
+ before { enter 'b 1' }
34
60
  it 'must set a breakpoint' do
35
61
  debug_file('breakpoint') { Byebug.breakpoints.size.must_equal 1 }
36
62
  end
@@ -52,7 +78,7 @@ class TestBreakpoints < TestDsl::TestCase
52
78
 
53
79
 
54
80
  describe 'setting breakpoint to incorrect line' do
55
- before { enter 'break 11' }
81
+ before { enter 'break 2' }
56
82
 
57
83
  it 'must not create a breakpoint' do
58
84
  debug_file('breakpoint') { Byebug.breakpoints.must_be_empty }
@@ -61,28 +87,27 @@ class TestBreakpoints < TestDsl::TestCase
61
87
  it 'must show an error' do
62
88
  debug_file('breakpoint')
63
89
  check_error_includes \
64
- "Line 11 is not a stopping point in file #{@tst_file}"
90
+ "Line 2 is not a stopping point in file #{@tst_file}"
65
91
  end
66
92
  end
67
93
 
68
94
  describe 'stopping at breakpoint' do
69
95
  it 'must stop at the correct line' do
70
- enter 'break 14', 'cont'
71
- debug_file('breakpoint') { $state.line.must_equal 14 }
96
+ enter 'break 5', 'cont'
97
+ debug_file('breakpoint') { $state.line.must_equal 5 }
72
98
  end
73
99
 
74
100
  it 'must stop at the correct file' do
75
- enter 'break 14', 'cont'
101
+ enter 'break 5', 'cont'
76
102
  debug_file('breakpoint') { $state.file.must_equal @tst_file }
77
103
  end
78
104
 
79
105
  describe 'show a message' do
80
-
81
106
  describe 'with full filename' do
82
107
  it 'must show a message with full filename' do
83
- enter 'break 14', 'cont'
108
+ enter 'break 5', 'cont'
84
109
  debug_file('breakpoint') { @id = Byebug.breakpoints.first.id }
85
- check_output_includes "Created breakpoint #{@id} at #{@tst_file}:14"
110
+ check_output_includes "Created breakpoint #{@id} at #{@tst_file}:5"
86
111
  end
87
112
  end
88
113
 
@@ -90,9 +115,9 @@ class TestBreakpoints < TestDsl::TestCase
90
115
  temporary_change_hash Byebug.settings, :basename, true
91
116
 
92
117
  it 'must show a message with basename' do
93
- enter 'break 14', 'cont'
118
+ enter 'break 5', 'cont'
94
119
  debug_file('breakpoint') { @id = Byebug.breakpoints.first.id }
95
- check_output_includes "Created breakpoint #{@id} at breakpoint.rb:14"
120
+ check_output_includes "Created breakpoint #{@id} at breakpoint.rb:5"
96
121
  end
97
122
  end
98
123
  end
@@ -104,39 +129,37 @@ class TestBreakpoints < TestDsl::TestCase
104
129
 
105
130
  it 'must not reload source' do
106
131
  id = nil
107
- enter \
108
- ->{change_line_in_file(@tst_file, 14, ''); 'break 14'},
109
- ->{change_line_in_file(@tst_file, 14, 'c = a + b');
110
- 'cont'}
132
+ enter ->{ change_line_in_file(@tst_file, 5, ''); 'break 5' },
133
+ ->{ change_line_in_file(@tst_file, 5, 'BreakpointExample.new.b');
134
+ cont }
111
135
  debug_file('breakpoint') { id = Byebug.breakpoints.first.id }
112
- check_output_includes "Created breakpoint #{id} at #{@tst_file}:14"
136
+ check_output_includes "Created breakpoint #{id} at #{@tst_file}:5"
113
137
  end
114
138
  end
115
139
 
116
140
  describe 'autoreload set' do
117
141
  it 'must reload source' do
118
142
  enter \
119
- ->{change_line_in_file(@tst_file, 14, ''); 'break 14'},
120
- # 2nd breakpoint just to reload source code after rolling changes back
121
- ->{change_line_in_file(@tst_file, 14, 'c = a + b');
122
- 'break 15'}, 'cont'
143
+ ->{change_line_in_file(@tst_file, 5, ''); 'break 5'},
144
+ ->{change_line_in_file(@tst_file, 5, 'BreakpointExample.new.b');
145
+ 'next'}
123
146
  debug_file 'breakpoint'
124
147
  check_error_includes \
125
- "Line 14 is not a stopping point in file #{@tst_file}"
148
+ "Line 5 is not a stopping point in file #{@tst_file}"
126
149
  end
127
150
  end
128
151
  end
129
152
 
130
153
  describe 'set breakpoint in a file' do
131
154
  describe 'successfully' do
132
- before { enter "break #{@tst_file_2}:3", 'cont' }
155
+ before { enter "break #{__FILE__}:5", 'cont' }
133
156
 
134
157
  it 'must stop at the correct line' do
135
- debug_file('breakpoint') { $state.line.must_equal 3 }
158
+ debug_file('breakpoint') { $state.line.must_equal 5 }
136
159
  end
137
160
 
138
161
  it 'must stop at the correct file' do
139
- debug_file('breakpoint') { $state.file.must_equal @tst_file_2 }
162
+ debug_file('breakpoint') { $state.file.must_equal __FILE__ }
140
163
  end
141
164
  end
142
165
 
@@ -206,7 +229,7 @@ class TestBreakpoints < TestDsl::TestCase
206
229
 
207
230
  describe 'disabling breakpoints' do
208
231
  describe 'successfully' do
209
- before { enter 'break 14', 'break 15' }
232
+ before { enter 'break 5', 'break 6' }
210
233
 
211
234
  describe 'short syntax' do
212
235
  before { enter ->{ "disable #{Byebug.breakpoints.first.id}" } }
@@ -218,7 +241,7 @@ class TestBreakpoints < TestDsl::TestCase
218
241
 
219
242
  it 'must not stop on the disabled breakpoint' do
220
243
  enter 'cont'
221
- debug_file('breakpoint') { $state.line.must_equal 15 }
244
+ debug_file('breakpoint') { $state.line.must_equal 6 }
222
245
  end
223
246
  end
224
247
 
@@ -267,7 +290,7 @@ class TestBreakpoints < TestDsl::TestCase
267
290
  end
268
291
 
269
292
  it 'must show an error if a number is not provided as an argument' do
270
- enter 'break 14', 'disable foo'
293
+ enter 'break 5', 'disable foo'
271
294
  debug_file('breakpoint')
272
295
  check_output_includes \
273
296
  '"disable breakpoints" argument "foo" needs to be a number.'
@@ -277,7 +300,7 @@ class TestBreakpoints < TestDsl::TestCase
277
300
 
278
301
  describe 'enabling breakpoints' do
279
302
  describe 'successfully' do
280
- before { enter 'break 14', 'break 15', 'disable breakpoints' }
303
+ before { enter 'break 5', 'break 6', 'disable breakpoints' }
281
304
 
282
305
  describe 'short syntax' do
283
306
  before { enter ->{ "enable #{Byebug.breakpoints.first.id}" } }
@@ -289,7 +312,7 @@ class TestBreakpoints < TestDsl::TestCase
289
312
 
290
313
  it 'must stop on the enabled breakpoint' do
291
314
  enter 'cont'
292
- debug_file('breakpoint') { $state.line.must_equal 14 }
315
+ debug_file('breakpoint') { $state.line.must_equal 5 }
293
316
  end
294
317
  end
295
318
 
@@ -306,12 +329,12 @@ class TestBreakpoints < TestDsl::TestCase
306
329
 
307
330
  it 'must stop on the first breakpoint' do
308
331
  enter 'cont'
309
- debug_file('breakpoint') { $state.line.must_be 14 }
332
+ debug_file('breakpoint') { $state.line.must_be 5 }
310
333
  end
311
334
 
312
335
  it 'must stop on the last breakpoint' do
313
336
  enter 'cont', 'cont'
314
- debug_file('breakpoint') { $state.line.must_be 15 }
337
+ debug_file('breakpoint') { $state.line.must_be 6 }
315
338
  end
316
339
  end
317
340
 
@@ -327,7 +350,7 @@ class TestBreakpoints < TestDsl::TestCase
327
350
 
328
351
  it 'must not stop on the enabled breakpoint' do
329
352
  enter 'cont'
330
- debug_file('breakpoint') { $state.line.must_be 15 }
353
+ debug_file('breakpoint') { $state.line.must_be 6 }
331
354
  end
332
355
  end
333
356
  end
@@ -344,8 +367,8 @@ class TestBreakpoints < TestDsl::TestCase
344
367
  end
345
368
 
346
369
  describe 'deleting a breakpoint' do
347
- before { enter 'break 14', ->{"delete #{Byebug.breakpoints.first.id}"},
348
- 'break 15' }
370
+ before { enter 'break 5', ->{"delete #{Byebug.breakpoints.first.id}"},
371
+ 'break 6' }
349
372
 
350
373
  it 'must have only one breakpoint' do
351
374
  debug_file('breakpoint') { Byebug.breakpoints.size.must_equal 1 }
@@ -353,30 +376,30 @@ class TestBreakpoints < TestDsl::TestCase
353
376
 
354
377
  it 'must not stop on the disabled breakpoint' do
355
378
  enter 'cont'
356
- debug_file('breakpoint') { $state.line.must_equal 15 }
379
+ debug_file('breakpoint') { $state.line.must_equal 6 }
357
380
  end
358
381
  end
359
382
 
360
383
  describe 'Conditional breakpoints' do
361
384
  it 'must stop if the condition is true' do
362
- enter 'break 14 if b == 5', 'break 15', 'cont'
363
- debug_file('breakpoint') { $state.line.must_equal 14 }
385
+ enter 'break 5 if b == 5', 'break 6', 'cont'
386
+ debug_file('breakpoint') { $state.line.must_equal 5 }
364
387
  end
365
388
 
366
389
  it 'must skip if the condition is false' do
367
- enter 'break 14 if b == 3', 'break 15', 'cont'
368
- debug_file('breakpoint') { $state.line.must_equal 15 }
390
+ enter 'break 5 if b == 3', 'break 6', 'cont'
391
+ debug_file('breakpoint') { $state.line.must_equal 6 }
369
392
  end
370
393
 
371
394
  it 'must show an error when conditional syntax is wrong' do
372
- enter 'break 14 ifa b == 3', 'break 15', 'cont'
373
- debug_file('breakpoint') { $state.line.must_equal 15 }
395
+ enter 'break 5 ifa b == 3', 'break 6', 'cont'
396
+ debug_file('breakpoint') { $state.line.must_equal 6 }
374
397
  check_error_includes \
375
398
  'Expecting "if" in breakpoint condition; got: ifa b == 3.'
376
399
  end
377
400
 
378
401
  describe 'enabling with wrong conditional syntax' do
379
- before { enter 'break 14',
402
+ before { enter 'break 5',
380
403
  ->{"disable #{Byebug.breakpoints.first.id}"},
381
404
  ->{"cond #{Byebug.breakpoints.first.id} b -=( 3"},
382
405
  ->{"enable #{Byebug.breakpoints.first.id}"} }
@@ -394,14 +417,14 @@ class TestBreakpoints < TestDsl::TestCase
394
417
  end
395
418
 
396
419
  it 'must show an error if no file or line is specified' do
397
- enter 'break ifa b == 3', 'break 15', 'cont'
398
- debug_file('breakpoint') { $state.line.must_equal 15 }
420
+ enter 'break ifa b == 3', 'break 6', 'cont'
421
+ debug_file('breakpoint') { $state.line.must_equal 6 }
399
422
  check_error_includes 'Invalid breakpoint location: ifa b == 3.'
400
423
  end
401
424
 
402
425
  it 'must show an error if expression syntax is invalid' do
403
- enter 'break if b -=) 3', 'break 15', 'cont'
404
- debug_file('breakpoint') { $state.line.must_equal 15 }
426
+ enter 'break if b -=) 3', 'break 6', 'cont'
427
+ debug_file('breakpoint') { $state.line.must_equal 6 }
405
428
  check_error_includes \
406
429
  'Expression "b -=) 3" syntactically incorrect; breakpoint disabled.'
407
430
  end
@@ -410,7 +433,7 @@ class TestBreakpoints < TestDsl::TestCase
410
433
  describe 'Stopping through `byebug` keyword' do
411
434
  describe 'when not the last instruction of a method' do
412
435
  it 'must stop in the next line' do
413
- debug_file('breakpoint') { $state.line.must_equal 13 }
436
+ debug_file('breakpoint') { $state.line.must_equal 4 }
414
437
  end
415
438
  end
416
439
 
@@ -425,7 +448,7 @@ class TestBreakpoints < TestDsl::TestCase
425
448
  it 'must show info about setting breakpoints when using just "break"' do
426
449
  enter 'break', 'cont'
427
450
  debug_file 'breakpoint'
428
- check_output_includes /b\[reak\] file:line \[if expr\]/
451
+ check_output_includes(/b\[reak\] file:line \[if expr\]/)
429
452
  end
430
453
  end
431
454
  end