byebug 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/GUIDE.md +210 -4
  4. data/README.md +93 -64
  5. data/bin/byebug +10 -4
  6. data/byebug.gemspec +1 -1
  7. data/ext/byebug/breakpoint.c +22 -20
  8. data/lib/byebug/command.rb +5 -3
  9. data/lib/byebug/commands/frame.rb +2 -1
  10. data/lib/byebug/commands/kill.rb +0 -1
  11. data/lib/byebug/commands/set.rb +5 -6
  12. data/lib/byebug/commands/show.rb +11 -11
  13. data/lib/byebug/version.rb +1 -1
  14. data/logo.png +0 -0
  15. data/old_doc/byebug.texi +2 -2
  16. data/old_doc/{test-tri2.rb → test-triangle.rb} +4 -5
  17. data/old_doc/tri3.rb +3 -5
  18. data/old_doc/triangle.rb +4 -2
  19. data/test/breakpoints_test.rb +1 -2
  20. data/test/conditions_test.rb +3 -4
  21. data/test/continue_test.rb +6 -8
  22. data/test/display_test.rb +1 -2
  23. data/test/edit_test.rb +1 -2
  24. data/test/eval_test.rb +1 -2
  25. data/test/examples/stepping.rb +4 -0
  26. data/test/finish_test.rb +1 -2
  27. data/test/frame_test.rb +1 -2
  28. data/test/help_test.rb +1 -2
  29. data/test/info_test.rb +1 -2
  30. data/test/jump_test.rb +1 -2
  31. data/test/kill_test.rb +1 -2
  32. data/test/list_test.rb +1 -2
  33. data/test/method_test.rb +1 -2
  34. data/test/post_mortem_test.rb +1 -2
  35. data/test/quit_test.rb +1 -2
  36. data/test/reload_test.rb +1 -2
  37. data/test/repl_test.rb +1 -2
  38. data/test/restart_test.rb +1 -2
  39. data/test/save_test.rb +1 -2
  40. data/test/set_test.rb +6 -11
  41. data/test/show_test.rb +5 -4
  42. data/test/source_test.rb +1 -2
  43. data/test/stepping_test.rb +81 -55
  44. data/test/support/test_dsl.rb +54 -54
  45. data/test/test_helper.rb +0 -1
  46. data/test/trace_test.rb +75 -80
  47. data/test/variables_test.rb +1 -2
  48. metadata +6 -5
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'Frame Command' do
4
- include TestDsl
3
+ class TestFrame < TestDsl::TestCase
5
4
 
6
5
  # XXX: Calculate magic number dinamically, like
7
6
  # "longest_string_in_test_output".size
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'Help Command' do
4
- include TestDsl
3
+ class TestHelp < TestDsl::TestCase
5
4
  include Columnize
6
5
 
7
6
  let(:available_commands) {
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'Info Command' do
4
- include TestDsl
3
+ class TestInfo < TestDsl::TestCase
5
4
  include Columnize
6
5
 
7
6
  describe 'Args info' do
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe "Jump Command" do
4
- include TestDsl
3
+ class TestJump < TestDsl::TestCase
5
4
 
6
5
  describe "successful" do
7
6
  it "must jump with absolute line number" do
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'Kill Command' do
4
- include TestDsl
3
+ class TestKill < TestDsl::TestCase
5
4
 
6
5
  it 'must send signal to some pid' do
7
6
  Process.expects(:kill).with('USR1', Process.pid)
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'List Command' do
4
- include TestDsl
3
+ class TestList < TestDsl::TestCase
5
4
 
6
5
  describe 'listsize' do
7
6
  it 'must show lines according to :listsize setting' do
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'Method Command' do
4
- include TestDsl
3
+ class TestMethod < TestDsl::TestCase
5
4
 
6
5
  temporary_change_hash Byebug::Command.settings, :autolist, 0
7
6
 
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'Post Mortem' do
4
- include TestDsl
3
+ class TestPostMortem < TestDsl::TestCase
5
4
 
6
5
  it 'must enter into post mortem mode' do
7
6
  enter 'cont'
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'Quit Command' do
4
- include TestDsl
3
+ class TestQuit < TestDsl::TestCase
5
4
 
6
5
  it 'must quit if user confirmed' do
7
6
  Byebug::QuitCommand.any_instance.expects(:exit!)
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'Reload Command' do
4
- include TestDsl
3
+ class TestReload < TestDsl::TestCase
5
4
 
6
5
  describe 'autoreloading' do
7
6
  after { Byebug::Command.settings[:autoreload] = true }
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'Repl commands' do
4
- include TestDsl
3
+ class TestRepl < TestDsl::TestCase
5
4
 
6
5
  describe 'Irb Command' do
7
6
  before do
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'Restart Command' do
4
- include TestDsl
3
+ class TestRestart < TestDsl::TestCase
5
4
 
6
5
  def must_restart
7
6
  Byebug::RestartCommand.any_instance.unstub(:exec)
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'Save Command' do
4
- include TestDsl
3
+ class TestSave < TestDsl::TestCase
5
4
 
6
5
  describe 'successful saving' do
7
6
  let(:file_name) { 'save_output.txt' }
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'Set Command' do
4
- include TestDsl
3
+ class TestSet < TestDsl::TestCase
5
4
 
6
5
  describe 'setting to on' do
7
6
  temporary_change_hash Byebug::Command.settings, :autolist, 0
@@ -170,15 +169,11 @@ describe 'Set Command' do
170
169
 
171
170
  describe 'width' do
172
171
  temporary_change_hash Byebug::Command.settings, :width, 20
173
- let(:old_columns) { ENV['COLUMNS'] }
174
-
175
- it 'must set ENV[\'COLUMNS\'] by the "set width" command' do
176
- begin
177
- enter 'set width 10'
178
- debug_file('set') { ENV['COLUMNS'].must_equal '10' }
179
- ensure
180
- ENV['COLUMNS'] = old_columns
181
- end
172
+
173
+ it 'must get correctly set' do
174
+ enter 'set width 10'
175
+ debug_file('set')
176
+ Byebug::Command.settings[:width].must_equal 10
182
177
  end
183
178
  end
184
179
 
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'Show Command' do
4
- include TestDsl
3
+ class TestShow < TestDsl::TestCase
5
4
 
6
5
  describe 'annotate' do
7
6
  it 'must show annotate setting' do
@@ -143,10 +142,12 @@ describe 'Show Command' do
143
142
  end
144
143
 
145
144
  describe 'width' do
146
- it 'must show width' do
145
+ let(:cols) { `stty size`.scan(/\d+/)[1].to_i }
146
+
147
+ it 'must show default width' do
147
148
  enter 'show width'
148
149
  debug_file 'show'
149
- check_output_includes 'width is 80.'
150
+ check_output_includes "width is #{cols}."
150
151
  end
151
152
  end
152
153
 
@@ -1,7 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'Source Command' do
4
- include TestDsl
3
+ class TestSource < TestDsl::TestCase
5
4
 
6
5
  before { File.open(filename, 'w') do |f|
7
6
  f.puts 'break 2'
@@ -1,51 +1,63 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe 'Stepping Commands' do
4
- include TestDsl
3
+ class TestStepping < TestDsl::TestCase
5
4
 
6
5
  describe 'Next Command' do
7
6
 
8
7
  describe 'Usual mode' do
9
- before { enter 'break 10', 'cont' }
10
8
 
11
- it 'must leave on the same line by default' do
12
- enter 'next'
13
- debug_file('stepping') { state.line.must_equal 10 }
14
- end
15
-
16
- it 'must go to the next line if forced by "plus" sign' do
17
- enter 'next+'
18
- debug_file('stepping') { state.line.must_equal 11 }
19
- end
20
-
21
- it 'must leave on the same line if forced by "minus" sign' do
22
- enter 'next-'
23
- debug_file('stepping') { state.line.must_equal 10 }
24
- end
25
-
26
- describe 'when force_stepping is set' do
27
- temporary_change_hash Byebug::Command.settings, :force_stepping, true
9
+ describe 'method call behaviour' do
10
+ before { enter 'break 10', 'cont' }
28
11
 
29
- it 'must go to the next line' do
12
+ it 'must leave on the same line by default' do
30
13
  enter 'next'
31
- debug_file('stepping') { state.line.must_equal 11 }
14
+ debug_file('stepping') { state.line.must_equal 10 }
32
15
  end
33
16
 
34
- it 'must go to the next line (by shortcut)' do
35
- enter 'n'
17
+ it 'must go to the next line if forced by "plus" sign' do
18
+ enter 'next+'
36
19
  debug_file('stepping') { state.line.must_equal 11 }
37
20
  end
38
21
 
39
- it 'must go the specified number of lines forward by default' do
40
- enter 'next 2'
41
- debug_file('stepping') { state.line.must_equal 21 }
42
- end
43
-
44
- it 'must ignore it if "minus" is specified' do
22
+ it 'must leave on the same line if forced by "minus" sign' do
45
23
  enter 'next-'
46
24
  debug_file('stepping') { state.line.must_equal 10 }
47
25
  end
26
+
27
+ describe 'when force_stepping is set' do
28
+ temporary_change_hash Byebug::Command.settings, :force_stepping, true
29
+
30
+ it 'must go to the next line' do
31
+ enter 'next'
32
+ debug_file('stepping') { state.line.must_equal 11 }
33
+ end
34
+
35
+ it 'must go to the next line (by shortcut)' do
36
+ enter 'n'
37
+ debug_file('stepping') { state.line.must_equal 11 }
38
+ end
39
+
40
+ it 'must go the specified number of lines forward by default' do
41
+ enter 'next 2'
42
+ debug_file('stepping') { state.line.must_equal 21 }
43
+ end
44
+
45
+ it 'must ignore it if "minus" is specified' do
46
+ enter 'next-'
47
+ debug_file('stepping') { state.line.must_equal 10 }
48
+ end
49
+ end
48
50
  end
51
+
52
+ describe 'block behaviour' do
53
+ before { enter 'break 21', 'cont' }
54
+
55
+ it 'must step over blocks' do
56
+ enter 'next'
57
+ debug_file('stepping') { state.line.must_equal 25 }
58
+ end
59
+ end
60
+
49
61
  end
50
62
 
51
63
  describe 'Post Mortem' do
@@ -58,46 +70,60 @@ describe 'Stepping Commands' do
58
70
  'Unknown command: "next". Try "help".', interface.error_queue
59
71
  end
60
72
  end
73
+
61
74
  end
62
75
 
63
76
  describe 'Step Command' do
64
77
 
65
78
  describe 'Usual mode' do
66
- before { enter 'break 10', 'cont' }
67
-
68
- it 'must leave on the same line if forced by a setting' do
69
- enter 'step'
70
- debug_file('stepping') { state.line.must_equal 10 }
71
- end
72
79
 
73
- it 'must go to the step line if forced to do that by "plus" sign' do
74
- enter 'step+'
75
- debug_file('stepping') { state.line.must_equal 11 }
76
- end
77
-
78
- it 'must leave on the same line if forced to do that by "minus" sign' do
79
- enter 'step-'
80
- debug_file('stepping') { state.line.must_equal 10 }
81
- end
80
+ describe 'method call behaviour' do
81
+ before { enter 'break 10', 'cont' }
82
82
 
83
- describe 'when force_stepping is set' do
84
- temporary_change_hash Byebug::Command.settings, :force_stepping, true
85
-
86
- it 'must go to the step line if forced by a setting' do
83
+ it 'must leave on the same line if forced by a setting' do
87
84
  enter 'step'
88
- debug_file('stepping') { state.line.must_equal 11 }
85
+ debug_file('stepping') { state.line.must_equal 10 }
89
86
  end
90
87
 
91
- it 'must go to the next line if forced by a setting (by shortcut)' do
92
- enter 's'
88
+ it 'must go to the step line if forced to do that by "plus" sign' do
89
+ enter 'step+'
93
90
  debug_file('stepping') { state.line.must_equal 11 }
94
91
  end
95
92
 
96
- it 'must go the specified number of lines forward by default' do
97
- enter 'step 2'
98
- debug_file('stepping') { state.line.must_equal 15 }
93
+ it 'must leave on the same line if forced to do that by "minus" sign' do
94
+ enter 'step-'
95
+ debug_file('stepping') { state.line.must_equal 10 }
96
+ end
97
+
98
+ describe 'when force_stepping is set' do
99
+ temporary_change_hash Byebug::Command.settings, :force_stepping, true
100
+
101
+ it 'must go to the step line if forced by a setting' do
102
+ enter 'step'
103
+ debug_file('stepping') { state.line.must_equal 11 }
104
+ end
105
+
106
+ it 'must go to the next line if forced by a setting (by shortcut)' do
107
+ enter 's'
108
+ debug_file('stepping') { state.line.must_equal 11 }
109
+ end
110
+
111
+ it 'must go the specified number of lines forward by default' do
112
+ enter 'step 2'
113
+ debug_file('stepping') { state.line.must_equal 15 }
114
+ end
115
+ end
116
+ end
117
+
118
+ describe 'block behaviour' do
119
+ before { enter 'break 21', 'cont' }
120
+
121
+ it 'must step into blocks' do
122
+ enter 'step'
123
+ debug_file('stepping') { state.line.must_equal 22 }
99
124
  end
100
125
  end
126
+
101
127
  end
102
128
 
103
129
  describe 'Post Mortem' do
@@ -1,12 +1,60 @@
1
1
  module TestDsl
2
2
 
3
- def self.included(base)
4
- base.class_eval do
5
- extend ClassUtils
6
- before do
7
- Byebug.interface = TestInterface.new
8
- Byebug.handler.display.clear
3
+ module ClassUtils
4
+
5
+ def temporary_change_hash hash, key, value
6
+ mod = Module.new do
7
+ extend Minitest::Spec::DSL
8
+
9
+ before do
10
+ @old_hashes ||= {}
11
+ @old_hashes.merge!({ hash => { key => hash[key] } }) do |k, v1, v2|
12
+ v1.merge(v2)
13
+ end
14
+ hash[key] = value
15
+ end
16
+
17
+ after do
18
+ hash[key] = @old_hashes[hash][key]
19
+ end
20
+ end
21
+
22
+ include mod
23
+ end
24
+
25
+ def temporary_change_const klass, const, value
26
+ mod = Module.new do
27
+ extend Minitest::Spec::DSL
28
+
29
+ before do
30
+ @old_consts ||= {}
31
+ old_value = klass.const_defined?(const) ?
32
+ klass.const_get(const) : :__undefined__
33
+ @old_consts.merge!({ klass => { const => old_value } }) do |k, v1, v2|
34
+ v1.merge(v2)
35
+ end
36
+ klass.send :remove_const, const if klass.const_defined?(const)
37
+ klass.const_set const, value unless value == :__undefined__
38
+ end
39
+
40
+ after do
41
+ klass.send :remove_const, const if klass.const_defined?(const)
42
+ klass.const_set const, @old_consts[klass][const] unless
43
+ @old_consts[klass][const] == :__undefined__
44
+ end
9
45
  end
46
+
47
+ include mod
48
+ end
49
+ end
50
+
51
+ class TestCase < Minitest::Spec
52
+ extend TestDsl::ClassUtils
53
+ include TestDsl
54
+
55
+ def setup
56
+ Byebug.interface = TestInterface.new
57
+ Byebug.handler.display.clear
10
58
  end
11
59
  end
12
60
 
@@ -136,52 +184,4 @@ module TestDsl
136
184
  File.open(file, 'w') { |f| f.write(new_content) }
137
185
  end
138
186
 
139
-
140
- module ClassUtils
141
- def temporary_change_hash hash, key, value
142
- mod = Module.new do
143
- extend Minitest::Spec::DSL
144
-
145
- before do
146
- @old_hashes ||= {}
147
- @old_hashes.merge!({ hash => { key => hash[key] } }) do |k, v1, v2|
148
- v1.merge(v2)
149
- end
150
- hash[key] = value
151
- end
152
-
153
- after do
154
- hash[key] = @old_hashes[hash][key]
155
- end
156
- end
157
-
158
- include mod
159
- end
160
-
161
- def temporary_change_const klass, const, value
162
- mod = Module.new do
163
- extend Minitest::Spec::DSL
164
-
165
- before do
166
- @old_consts ||= {}
167
- old_value = klass.const_defined?(const) ?
168
- klass.const_get(const) : :__undefined__
169
- @old_consts.merge!({ klass => { const => old_value } }) do |k, v1, v2|
170
- v1.merge(v2)
171
- end
172
- klass.send :remove_const, const if klass.const_defined?(const)
173
- klass.const_set const, value unless value == :__undefined__
174
- end
175
-
176
- after do
177
- klass.send :remove_const, const if klass.const_defined?(const)
178
- klass.const_set const, @old_consts[klass][const] unless
179
- @old_consts[klass][const] == :__undefined__
180
- end
181
- end
182
-
183
- include mod
184
- end
185
- end
186
-
187
187
  end