byebug 3.0.0 → 3.1.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 (125) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/GUIDE.md +2 -2
  4. data/LICENSE +3 -3
  5. data/README.md +5 -4
  6. data/byebug.gemspec +1 -1
  7. data/ext/byebug/byebug.c +20 -19
  8. data/lib/byebug.rb +2 -53
  9. data/lib/byebug/command.rb +9 -109
  10. data/lib/byebug/commands/breakpoints.rb +1 -1
  11. data/lib/byebug/commands/control.rb +20 -21
  12. data/lib/byebug/commands/display.rb +2 -3
  13. data/lib/byebug/commands/eval.rb +6 -16
  14. data/lib/byebug/commands/finish.rb +1 -1
  15. data/lib/byebug/commands/frame.rb +9 -9
  16. data/lib/byebug/commands/help.rb +2 -3
  17. data/lib/byebug/commands/history.rb +28 -0
  18. data/lib/byebug/commands/info.rb +3 -3
  19. data/lib/byebug/commands/list.rb +2 -13
  20. data/lib/byebug/commands/method.rb +5 -45
  21. data/lib/byebug/commands/reload.rb +1 -12
  22. data/lib/byebug/commands/repl.rb +6 -15
  23. data/lib/byebug/commands/save.rb +2 -7
  24. data/lib/byebug/commands/set.rb +45 -116
  25. data/lib/byebug/commands/show.rb +22 -126
  26. data/lib/byebug/commands/stepping.rb +1 -1
  27. data/lib/byebug/commands/trace.rb +14 -25
  28. data/lib/byebug/commands/variables.rb +3 -41
  29. data/lib/byebug/helper.rb +11 -42
  30. data/lib/byebug/history.rb +5 -13
  31. data/lib/byebug/processors/command_processor.rb +6 -6
  32. data/lib/byebug/setting.rb +82 -0
  33. data/lib/byebug/settings/autoeval.rb +20 -0
  34. data/lib/byebug/settings/autoirb.rb +19 -0
  35. data/lib/byebug/settings/autolist.rb +19 -0
  36. data/lib/byebug/settings/autoreload.rb +11 -0
  37. data/lib/byebug/settings/autosave.rb +11 -0
  38. data/lib/byebug/settings/basename.rb +7 -0
  39. data/lib/byebug/settings/callstyle.rb +15 -0
  40. data/lib/byebug/settings/forcestep.rb +11 -0
  41. data/lib/byebug/settings/fullpath.rb +11 -0
  42. data/lib/byebug/settings/histfile.rb +16 -0
  43. data/lib/byebug/settings/histsize.rb +18 -0
  44. data/lib/byebug/settings/linetrace.rb +15 -0
  45. data/lib/byebug/settings/listsize.rb +15 -0
  46. data/lib/byebug/settings/post_mortem.rb +15 -0
  47. data/lib/byebug/settings/stack_on_error.rb +7 -0
  48. data/lib/byebug/settings/testing.rb +7 -0
  49. data/lib/byebug/settings/tracing_plus.rb +7 -0
  50. data/lib/byebug/settings/verbose.rb +7 -0
  51. data/lib/byebug/settings/width.rb +29 -0
  52. data/lib/byebug/version.rb +1 -1
  53. data/test/breakpoints_test.rb +345 -324
  54. data/test/conditions_test.rb +61 -48
  55. data/test/continue_test.rb +38 -27
  56. data/test/debugger_alias_test.rb +5 -3
  57. data/test/display_test.rb +103 -92
  58. data/test/edit_test.rb +42 -34
  59. data/test/eval_test.rb +91 -75
  60. data/test/finish_test.rb +51 -40
  61. data/test/frame_test.rb +197 -184
  62. data/test/help_test.rb +47 -38
  63. data/test/history_test.rb +54 -0
  64. data/test/info_test.rb +306 -293
  65. data/test/interrupt_test.rb +44 -38
  66. data/test/kill_test.rb +40 -31
  67. data/test/list_test.rb +166 -133
  68. data/test/method_test.rb +67 -60
  69. data/test/post_mortem_test.rb +56 -48
  70. data/test/quit_test.rb +44 -35
  71. data/test/reload_test.rb +36 -24
  72. data/test/repl_test.rb +57 -47
  73. data/test/restart_test.rb +56 -69
  74. data/test/save_test.rb +62 -53
  75. data/test/set_test.rb +140 -118
  76. data/test/show_test.rb +68 -201
  77. data/test/source_test.rb +39 -29
  78. data/test/stepping_test.rb +163 -136
  79. data/test/support/test_dsl.rb +9 -11
  80. data/test/test_helper.rb +2 -7
  81. data/test/thread_test.rb +121 -107
  82. data/test/trace_test.rb +86 -83
  83. data/test/variables_test.rb +104 -98
  84. metadata +27 -86
  85. data/test/examples/breakpoint.rb +0 -6
  86. data/test/examples/breakpoint_deep.rb +0 -4
  87. data/test/examples/conditions.rb +0 -4
  88. data/test/examples/continue.rb +0 -5
  89. data/test/examples/display.rb +0 -5
  90. data/test/examples/edit.rb +0 -4
  91. data/test/examples/eval.rb +0 -4
  92. data/test/examples/finish.rb +0 -3
  93. data/test/examples/frame.rb +0 -4
  94. data/test/examples/frame_deep.rb +0 -1
  95. data/test/examples/gcd.rb +0 -15
  96. data/test/examples/hanoi.rb +0 -34
  97. data/test/examples/help.rb +0 -1
  98. data/test/examples/info.rb +0 -6
  99. data/test/examples/info2.rb +0 -3
  100. data/test/examples/interrupt.rb +0 -8
  101. data/test/examples/kill.rb +0 -2
  102. data/test/examples/list.rb +0 -23
  103. data/test/examples/method.rb +0 -4
  104. data/test/examples/post_mortem.rb +0 -4
  105. data/test/examples/primes.rb +0 -25
  106. data/test/examples/quit.rb +0 -2
  107. data/test/examples/reload.rb +0 -6
  108. data/test/examples/repl.rb +0 -6
  109. data/test/examples/restart.rb +0 -6
  110. data/test/examples/save.rb +0 -3
  111. data/test/examples/set.rb +0 -3
  112. data/test/examples/settings.rb +0 -1
  113. data/test/examples/show.rb +0 -1
  114. data/test/examples/source.rb +0 -3
  115. data/test/examples/stepping.rb +0 -8
  116. data/test/examples/stepping_raise_from_c_method.rb +0 -3
  117. data/test/examples/stepping_raise_from_ruby_method.rb +0 -3
  118. data/test/examples/test-triangle.rb +0 -14
  119. data/test/examples/thread.rb +0 -5
  120. data/test/examples/tmate.rb +0 -10
  121. data/test/examples/trace.rb +0 -8
  122. data/test/examples/tri3.rb +0 -6
  123. data/test/examples/triangle.rb +0 -13
  124. data/test/examples/variables.rb +0 -4
  125. data/test/timeout_test.rb +0 -9
@@ -5,7 +5,6 @@ module TestDsl
5
5
 
6
6
  def setup
7
7
  Byebug.handler = Byebug::CommandProcessor.new(Byebug::TestInterface.new)
8
- Byebug.tracing = false
9
8
  Byebug.breakpoints.clear if Byebug.breakpoints
10
9
  end
11
10
 
@@ -78,7 +77,7 @@ module TestDsl
78
77
  end
79
78
 
80
79
  #
81
- # Runs byebug with the provided basename for a file.
80
+ # Runs the provided Proc.
82
81
  #
83
82
  # You also can specify a block, which will be executed when Processor extracts
84
83
  # all the commands from the input queue. You can use that for making asserts
@@ -86,16 +85,20 @@ module TestDsl
86
85
  # the test will fail.
87
86
  #
88
87
  # Usage:
89
- # debug_file '/path/to/ex1.rb'
88
+ # debug_proc -> { byebug; puts 'Hello' }
90
89
  #
91
90
  # enter 'b 4', 'cont'
92
- # debug_file('/path/to/ex2.rb') { state.line.must_equal 4 }
91
+ # code = -> do
92
+ # byebug
93
+ # puts 'hello'
94
+ # end
95
+ # debug_proc(code) { state.line.must_equal 4 }
93
96
  #
94
- def debug_file(filename, options = {}, &block)
97
+ def debug_proc(program, &block)
95
98
  Byebug.stubs(:run_init_script)
96
99
  interface.test_block = block
97
100
  begin
98
- load fullpath(filename)
101
+ program.call
99
102
  ensure
100
103
  interface.test_block.call if interface.test_block
101
104
  end
@@ -160,9 +163,4 @@ module TestDsl
160
163
  .join("\n") + "\n"
161
164
  File.open(file, 'w') { |f| f.write(new_content) }
162
165
  end
163
-
164
- def must_restart
165
- Byebug::RestartCommand.any_instance.unstub(:exec)
166
- Byebug::RestartCommand.any_instance.expects(:exec)
167
- end
168
166
  end
@@ -11,14 +11,9 @@ require 'pathname'
11
11
  require 'mocha/mini_test'
12
12
  require 'byebug'
13
13
 
14
- Dir.glob(File.expand_path("../support/*.rb", __FILE__)).each { |f| require f }
14
+ Dir.glob(File.expand_path('../support/*.rb', __FILE__)).each { |f| require f }
15
15
 
16
- Byebug.settings[:testing] = true
17
-
18
- class DummyObject
19
- def initialize(*args)
20
- end
21
- end
16
+ Byebug::Setting[:testing] = true
22
17
 
23
18
  # Init globals to avoid warnings
24
19
  $bla = nil
@@ -1,138 +1,152 @@
1
- class ThreadExample
2
- def initialize
3
- Thread.main[:should_break] = false
4
- end
5
-
6
- def launch
7
- @t1 = Thread.new do
8
- while true
9
- break if Thread.main[:should_break]
10
- sleep 0.02
1
+ module ThreadTest
2
+ class Example
3
+ def initialize
4
+ Thread.main[:should_break] = false
5
+ end
6
+
7
+ def launch
8
+ @t1 = Thread.new do
9
+ while true
10
+ break if Thread.main[:should_break]
11
+ sleep 0.02
12
+ end
11
13
  end
12
- end
13
14
 
14
- @t2 = Thread.new do
15
- while true
16
- sleep 0.02
15
+ @t2 = Thread.new do
16
+ while true
17
+ sleep 0.02
18
+ end
17
19
  end
20
+
21
+ @t1.join
22
+ Thread.main[:should_break]
18
23
  end
19
24
 
20
- @t1.join
21
- Thread.main[:should_break]
25
+ def kill
26
+ @t2.kill
27
+ end
22
28
  end
23
29
 
24
- def kill
25
- @t2.kill
26
- end
27
- end
30
+ class ThreadTestCase < TestDsl::TestCase
31
+ let(:release) { 'eval Thread.main[:should_break] = true' }
28
32
 
29
- class TestThread < TestDsl::TestCase
30
- let(:release) { 'eval Thread.main[:should_break] = true' }
33
+ before do
34
+ @example = -> do
35
+ byebug
31
36
 
32
- describe 'list' do
33
- it 'must show current thread by "plus" sign' do
34
- thnum = nil
35
- enter "break #{__FILE__}:7", 'cont', 'thread list', release
36
- debug_file('thread') { thnum = Byebug.contexts.first.thnum }
37
- check_output_includes(/\+ #{thnum} #<Thread:\S+ run>\t#{__FILE__}:7/)
37
+ t = Example.new
38
+ t.launch
39
+ t.kill
40
+ end
38
41
  end
39
42
 
40
- it 'must work with shortcut' do
41
- thnum = nil
42
- enter "break #{__FILE__}:7", 'cont', 'th list', release
43
- debug_file('thread') { thnum = Byebug.contexts.first.thnum }
44
- check_output_includes(/\+ #{thnum} #<Thread:\S+ run>\t#{__FILE__}:7/)
43
+ def first_thnum
44
+ Byebug.contexts.first.thnum
45
45
  end
46
46
 
47
- it 'must show 3 available threads' do
48
- enter "break #{__FILE__}:20", 'cont', 'thread list', release
49
- debug_file 'thread'
50
- check_output_includes(/(\+)?\d+ #<Thread:\S+ (sleep|run)>/,
51
- /(\+)?\d+ #<Thread:\S+ (sleep|run)>/,
52
- /(\+)?\d+ #<Thread:\S+ (sleep|run)>/)
47
+ def last_thnum
48
+ Byebug.contexts.last.thnum
53
49
  end
54
- end
55
50
 
56
- describe 'stop' do
57
- it 'must mark thread as suspended' do
58
- thnum = nil
59
- enter "break #{__FILE__}:20", 'cont',
60
- ->{ "thread stop #{Byebug.contexts.last.thnum}" }, release
61
- debug_file('thread') { thnum = Byebug.contexts.last.thnum }
62
- check_output_includes(/\$ #{thnum} #<Thread:/)
63
- end
51
+ describe 'list' do
52
+ it 'must show current thread by "plus" sign' do
53
+ thnum = nil
54
+ enter 'break 8', 'cont', 'thread list', release
55
+ debug_proc(@example) { thnum = first_thnum }
56
+ check_output_includes(/\+ #{thnum} #<Thread:\S+ run>\t#{__FILE__}:8/)
57
+ end
64
58
 
65
- it 'must actually suspend thread execution' do
66
- enter "break #{__FILE__}:20", 'cont', 'trace on',
67
- ->{ "thread stop #{Byebug.contexts.last.thnum}" }, release
68
- debug_file('thread')
69
- check_output_doesnt_include(/Tracing: #{__FILE__}:15/,
70
- /Tracing: #{__FILE__}:16/)
71
- end
59
+ it 'must work with shortcut' do
60
+ thnum = nil
61
+ enter 'break 8', 'cont', 'th list', release
62
+ debug_proc(@example) { thnum = first_thnum }
63
+ check_output_includes(/\+ #{thnum} #<Thread:\S+ run>\t#{__FILE__}:8/)
64
+ end
72
65
 
73
- it 'must show error message if thread number is not specified' do
74
- enter "break #{__FILE__}:7", 'cont', 'thread stop', release
75
- debug_file 'thread'
76
- check_error_includes '"thread stop" needs a thread number'
66
+ it 'must show 3 available threads' do
67
+ enter 'break 21', 'cont', 'thread list', release
68
+ debug_proc(@example)
69
+ check_output_includes(/(\+)?\d+ #<Thread:\S+ (sleep|run)>/,
70
+ /(\+)?\d+ #<Thread:\S+ (sleep|run)>/,
71
+ /(\+)?\d+ #<Thread:\S+ (sleep|run)>/)
72
+ end
77
73
  end
78
74
 
79
- it 'must show error message when trying to stop current thread' do
80
- enter "break #{__FILE__}:7", 'cont',
81
- ->{"thread stop #{Byebug.contexts.first.thnum}"}, release
82
- debug_file 'thread'
83
- check_error_includes "It's the current thread"
84
- end
85
- end
75
+ describe 'stop' do
76
+ it 'must mark thread as suspended' do
77
+ thnum = nil
78
+ enter 'break 21', 'cont', ->{ "thread stop #{last_thnum}" }, release
79
+ debug_proc(@example) { thnum = last_thnum }
80
+ check_output_includes(/\$ #{thnum} #<Thread:/)
81
+ end
86
82
 
87
- describe 'resume' do
88
- it 'must mark remove thread from the suspended state' do
89
- thnum = nil
90
- enter "break #{__FILE__}:20", 'cont',
91
- -> { thnum = Byebug.contexts.last.thnum ; "thread stop #{thnum}" },
92
- -> { "thread resume #{thnum}" }, release
93
- debug_file('thread') { Byebug.contexts.last.suspended?.must_equal false }
94
- check_output_includes(/\$ #{thnum} #<Thread:/, /#{thnum} #<Thread:/)
95
- end
83
+ it 'must actually suspend thread execution' do
84
+ enter 'break 21', 'cont', 'trace on',
85
+ ->{ "thread stop #{last_thnum}" }, release
86
+ debug_proc(@example)
87
+ check_output_doesnt_include(/Tracing: #{__FILE__}:16/,
88
+ /Tracing: #{__FILE__}:17/)
89
+ end
96
90
 
97
- it 'must show error message if thread number is not specified' do
98
- enter "break #{__FILE__}:7", 'cont', 'thread resume', release
99
- debug_file 'thread'
100
- check_error_includes '"thread resume" needs a thread number'
101
- end
91
+ it 'must show error message if thread number is not specified' do
92
+ enter 'break 8', 'cont', 'thread stop', release
93
+ debug_proc(@example)
94
+ check_error_includes '"thread stop" needs a thread number'
95
+ end
102
96
 
103
- it 'must show error message when trying to resume current thread' do
104
- enter "break #{__FILE__}:7", 'cont',
105
- ->{ "thread resume #{Byebug.contexts.first.thnum}" }, release
106
- debug_file 'thread'
107
- check_error_includes "It's the current thread"
97
+ it 'must show error message when trying to stop current thread' do
98
+ enter 'break 8', 'cont', -> { "thread stop #{first_thnum}" }, release
99
+ debug_proc(@example)
100
+ check_error_includes "It's the current thread"
101
+ end
108
102
  end
109
103
 
110
- it 'must show error message if it is not stopped' do
111
- enter "break #{__FILE__}:20", 'cont',
112
- ->{ "thread resume #{Byebug.contexts.last.thnum}" }, release
113
- debug_file 'thread'
114
- check_error_includes 'Already running'
115
- end
116
- end
104
+ describe 'resume' do
105
+ it 'must mark remove thread from the suspended state' do
106
+ thnum = nil
107
+ enter 'break 21', 'cont',
108
+ -> { thnum = last_thnum ; "thread stop #{thnum}" },
109
+ -> { "thread resume #{thnum}" }, release
110
+ debug_proc(@example) { Byebug.contexts.last.suspended?.must_equal false }
111
+ check_output_includes(/\$ #{thnum} #<Thread:/, /#{thnum} #<Thread:/)
112
+ end
117
113
 
118
- describe 'switch' do
119
- it 'must switch to another thread' do
120
- enter "break #{__FILE__}:20", 'cont',
121
- ->{ "thread switch #{Byebug.contexts.last.thnum}" }, release
122
- debug_file('thread') { assert_equal state.line, 15 }
123
- end
114
+ it 'must show error message if thread number is not specified' do
115
+ enter 'break 8', 'cont', 'thread resume', release
116
+ debug_proc(@example)
117
+ check_error_includes '"thread resume" needs a thread number'
118
+ end
124
119
 
125
- it 'must show error message if thread number is not specified' do
126
- enter "break #{__FILE__}:7", 'cont', 'thread switch', release
127
- debug_file 'thread'
128
- check_error_includes '"thread switch" needs a thread number'
120
+ it 'must show error message when trying to resume current thread' do
121
+ enter 'break 8', 'cont', ->{ "thread resume #{first_thnum}" }, release
122
+ debug_proc(@example)
123
+ check_error_includes "It's the current thread"
124
+ end
125
+
126
+ it 'must show error message if it is not stopped' do
127
+ enter 'break 21', 'cont', ->{ "thread resume #{last_thnum}" }, release
128
+ debug_proc(@example)
129
+ check_error_includes 'Already running'
130
+ end
129
131
  end
130
132
 
131
- it 'must show error message when trying to switch current thread' do
132
- enter "break #{__FILE__}:7", 'cont',
133
- ->{ "thread switch #{Byebug.contexts.first.thnum}" }, release
134
- debug_file 'thread'
135
- check_error_includes "It's the current thread"
133
+ describe 'switch' do
134
+ it 'must switch to another thread' do
135
+ enter 'break 21', 'cont', ->{ "thread switch #{last_thnum}" }, release
136
+ debug_proc(@example) { assert_equal state.line, 16 }
137
+ end
138
+
139
+ it 'must show error message if thread number is not specified' do
140
+ enter 'break 8', 'cont', 'thread switch', release
141
+ debug_proc(@example)
142
+ check_error_includes '"thread switch" needs a thread number'
143
+ end
144
+
145
+ it 'must show error message when trying to switch current thread' do
146
+ enter 'break 8', 'cont', ->{ "thread switch #{first_thnum}" }, release
147
+ debug_proc(@example)
148
+ check_error_includes "It's the current thread"
149
+ end
136
150
  end
137
151
  end
138
152
  end
@@ -1,104 +1,107 @@
1
- class TestTrace < TestDsl::TestCase
2
- before do
3
- untrace_var(:$bla) if defined?($bla)
4
- end
1
+ module TraceTest
2
+ class TraceTestCase < TestDsl::TestCase
3
+ before do
4
+ @example = -> do
5
+ $bla = 5
6
+ byebug
7
+ $bla = 7
8
+ $bla = 8
9
+ $bla = 9
10
+ $bla = 10
11
+ $bla = (0 == (10 % $bla))
12
+ end
13
+ untrace_var(:$bla) if defined?($bla)
14
+ end
5
15
 
6
- describe 'tracing' do
16
+ describe 'line tracing' do
17
+ describe 'enabling' do
18
+ it 'must trace execution by setting trace to on' do
19
+ enter 'set linetrace', 'cont 10', 'set nolinetrace'
20
+ debug_proc(@example)
21
+ check_output_includes 'linetrace is on',
22
+ "Tracing: #{__FILE__}:8 $bla = 8",
23
+ "Tracing: #{__FILE__}:10 $bla = 10"
24
+ end
7
25
 
8
- describe 'enabling' do
9
- it 'must trace execution by setting trace to on' do
10
- enter 'trace on', 'cont 7', 'trace off'
11
- debug_file 'trace'
12
- check_output_includes 'line tracing is on.',
13
- "Tracing: #{fullpath('trace')}:4 $bla = 4",
14
- "Tracing: #{fullpath('trace')}:7 $bla = 7"
15
- end
26
+ it 'must be able to use a shortcut' do
27
+ enter 'set lin on', 'cont 10', 'set nolin'
28
+ debug_proc(@example)
29
+ check_output_includes 'linetrace is on',
30
+ "Tracing: #{__FILE__}:8 $bla = 8",
31
+ "Tracing: #{__FILE__}:10 $bla = 10"
32
+ end
16
33
 
17
- it 'must be able to use a shortcut' do
18
- enter 'tr on', 'cont 7', 'trace off'
19
- debug_file 'trace'
20
- check_output_includes 'line tracing is on.',
21
- "Tracing: #{fullpath('trace')}:4 $bla = 4",
22
- "Tracing: #{fullpath('trace')}:7 $bla = 7"
23
- end
34
+ it 'must correctly print lines containing % sign' do
35
+ enter 'cont 10', 'set linetrace', 'next', 'set nolinetrace'
36
+ debug_proc(@example)
37
+ check_output_includes "Tracing: #{__FILE__}:11 $bla = (0 == (10 % $bla))"
38
+ end
24
39
 
25
- it 'must correctly print lines containing % sign' do
26
- enter 'cont 7', 'trace on', 'next', 'trace off'
27
- debug_file 'trace'
28
- check_output_includes \
29
- "Tracing: #{fullpath('trace')}:8 $bla = (0 == (7 % $bla))"
40
+ describe 'when basename set' do
41
+ temporary_change_hash Byebug::Setting, :basename, true
42
+
43
+ it 'must correctly print file lines' do
44
+ enter 'set linetrace on', 'cont 10', 'set nolinetrace'
45
+ debug_proc(@example)
46
+ check_output_includes \
47
+ "Tracing: #{File.basename(__FILE__)}:10 $bla = 10"
48
+ end
49
+ end
30
50
  end
31
51
 
32
- describe 'when basename set' do
33
- temporary_change_hash Byebug.settings, :basename, true
52
+ describe 'disabling' do
53
+ it 'must stop tracing by setting trace to off' do
54
+ enter 'set linetrace', 'next', 'set nolinetrace'
55
+ debug_proc(@example)
56
+ check_output_includes "Tracing: #{__FILE__}:8 $bla = 8"
57
+ check_output_doesnt_include "Tracing: #{__FILE__}:9 $bla = 9"
58
+ end
34
59
 
35
- it 'must correctly print file lines' do
36
- enter 'tr on', 'cont 7', 'trace off'
37
- debug_file 'trace'
38
- check_output_includes \
39
- "Tracing: #{File.basename(fullpath('trace'))}:7 $bla = 7"
60
+ it 'must show a message when turned off' do
61
+ enter 'set nolinetrace'
62
+ debug_proc(@example)
63
+ check_output_includes 'linetrace is off'
40
64
  end
41
65
  end
42
66
  end
43
67
 
44
- it 'must show an error message if given subcommand is incorrect' do
45
- enter 'trace bla'
46
- debug_file 'trace'
47
- check_error_includes \
48
- 'expecting "on", "off", "var" or "variable"; got: "bla"'
49
- end
50
-
51
- describe 'disabling' do
52
- it 'must stop tracing by setting trace to off' do
53
- enter 'trace on', 'next', 'trace off'
54
- debug_file 'trace'
55
- check_output_includes "Tracing: #{fullpath('trace')}:4 $bla = 4"
56
- check_output_doesnt_include "Tracing: #{fullpath('trace')}:5 $bla = 5"
68
+ describe 'global variable tracing' do
69
+ it 'must track global variable' do
70
+ enter 'tracevar bla'
71
+ debug_proc(@example)
72
+ check_output_includes "traced global variable 'bla' has value '7'",
73
+ "traced global variable 'bla' has value '10'"
57
74
  end
58
75
 
59
- it 'must show a message when turned off' do
60
- enter 'trace off'
61
- debug_file 'trace'
62
- check_output_includes 'line tracing is off.'
76
+ it 'must be able to use a shortcut' do
77
+ enter 'tracevar bla'
78
+ debug_proc(@example)
79
+ check_output_includes "traced global variable 'bla' has value '7'"
80
+ "traced global variable 'bla' has value '10'"
63
81
  end
64
- end
65
- end
66
-
67
- describe 'tracing global variables' do
68
- it 'must track global variable' do
69
- enter 'trace variable bla'
70
- debug_file 'trace'
71
- check_output_includes "traced global variable 'bla' has value '3'",
72
- "traced global variable 'bla' has value '7'"
73
- end
74
-
75
- it 'must be able to use a shortcut' do
76
- enter 'trace var bla'
77
- debug_file 'trace'
78
- check_output_includes "traced global variable 'bla' has value '3'"
79
- end
80
82
 
81
- it 'must track global variable with stop' do
82
- enter 'trace variable bla stop', 'break 7', 'cont'
83
- debug_file('trace') { state.line.must_equal 4 }
84
- end
85
-
86
- it 'must track global variable with nostop' do
87
- enter 'trace variable bla nostop', 'break 7', 'cont'
88
- debug_file('trace') { state.line.must_equal 7 }
89
- end
83
+ it 'must track global variable with stop' do
84
+ enter 'tracevar bla stop', 'break 10', 'cont'
85
+ debug_proc(@example) { state.line.must_equal 8 }
86
+ end
90
87
 
91
- describe 'errors' do
92
- it 'must show an error message if there is no such global variable' do
93
- enter 'trace variable foo'
94
- debug_file 'trace'
95
- check_error_includes "'foo' is not a global variable."
88
+ it 'must track global variable with nostop' do
89
+ enter 'tracevar bla nostop', 'break 10', 'cont'
90
+ debug_proc(@example) { state.line.must_equal 10 }
96
91
  end
97
92
 
98
- it 'must show an error message if subcommand is invalid' do
99
- enter 'trace variable bla foo'
100
- debug_file 'trace'
101
- check_error_includes 'expecting "stop" or "nostop"; got "foo"'
93
+ describe 'errors' do
94
+ it 'must show an error message if there is no such global variable' do
95
+ enter 'tracevar foo'
96
+ debug_proc(@example)
97
+ check_error_includes "'foo' is not a global variable."
98
+ end
99
+
100
+ it 'must show an error message if subcommand is invalid' do
101
+ enter 'tracevar bla foo'
102
+ debug_proc(@example)
103
+ check_error_includes 'expecting "stop" or "nostop"; got "foo"'
104
+ end
102
105
  end
103
106
  end
104
107
  end