byebug 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/GUIDE.md +231 -0
  4. data/README.md +195 -7
  5. data/bin/byebug +1 -5
  6. data/byebug.gemspec +34 -35
  7. data/lib/byebug.rb +2 -5
  8. data/lib/byebug/command.rb +13 -13
  9. data/lib/byebug/commands/breakpoints.rb +1 -1
  10. data/lib/byebug/commands/control.rb +1 -1
  11. data/lib/byebug/commands/frame.rb +1 -1
  12. data/lib/byebug/commands/info.rb +1 -1
  13. data/lib/byebug/commands/list.rb +5 -5
  14. data/lib/byebug/commands/reload.rb +7 -10
  15. data/lib/byebug/commands/{irb.rb → repl.rb} +49 -13
  16. data/lib/byebug/commands/set.rb +10 -6
  17. data/lib/byebug/commands/show.rb +4 -7
  18. data/lib/byebug/commands/trace.rb +2 -2
  19. data/lib/byebug/context.rb +3 -5
  20. data/lib/byebug/helper.rb +2 -2
  21. data/lib/byebug/interface.rb +3 -0
  22. data/lib/byebug/processor.rb +2 -2
  23. data/lib/byebug/version.rb +1 -1
  24. data/old_doc/byebug.1 +1 -2
  25. data/old_doc/byebug.texi +125 -126
  26. data/old_doc/hanoi.rb +2 -3
  27. data/old_doc/triangle.rb +6 -7
  28. data/test/breakpoints_test.rb +43 -33
  29. data/test/display_test.rb +1 -1
  30. data/test/edit_test.rb +20 -15
  31. data/test/eval_test.rb +32 -26
  32. data/test/examples/list.rb +12 -1
  33. data/test/frame_test.rb +56 -43
  34. data/test/help_test.rb +11 -8
  35. data/test/info_test.rb +18 -13
  36. data/test/list_test.rb +74 -80
  37. data/test/method_test.rb +1 -3
  38. data/test/reload_test.rb +3 -3
  39. data/test/repl_test.rb +112 -0
  40. data/test/restart_test.rb +72 -70
  41. data/test/set_test.rb +43 -27
  42. data/test/show_test.rb +97 -102
  43. data/test/source_test.rb +6 -10
  44. data/test/stepping_test.rb +45 -49
  45. data/test/support/test_dsl.rb +47 -55
  46. data/test/test_helper.rb +2 -2
  47. data/test/trace_test.rb +4 -4
  48. data/test/variables_test.rb +10 -8
  49. metadata +9 -10
  50. data/old_doc/Makefile +0 -20
  51. data/test/examples/edit2.rb +0 -3
  52. data/test/irb_test.rb +0 -85
@@ -3,18 +3,14 @@ require_relative 'test_helper'
3
3
  describe 'Source Command' do
4
4
  include TestDsl
5
5
 
6
- let(:filename) { 'source_example.txt' }
6
+ before { File.open(filename, 'w') do |f|
7
+ f.puts 'break 2'
8
+ f.puts 'break 3 if true'
9
+ end }
7
10
 
8
- def after_setup
9
- File.open(filename, 'w') do |f|
10
- f.puts 'break 2'
11
- f.puts 'break 3 if true'
12
- end
13
- end
11
+ after { FileUtils.rm(filename) }
14
12
 
15
- def before_teardown
16
- FileUtils.rm(filename)
17
- end
13
+ let(:filename) { 'source_example.txt' }
18
14
 
19
15
  it 'must run commands from file' do
20
16
  enter "source #{filename}"
@@ -6,33 +6,13 @@ describe 'Stepping Commands' do
6
6
  describe 'Next Command' do
7
7
 
8
8
  describe 'Usual mode' do
9
- before do
10
- enter 'break 10', 'cont'
11
- end
12
-
13
- it 'must go to the next line if forced by a setting' do
14
- Byebug::Command.settings[:force_stepping] = true
15
- enter 'next'
16
- debug_file('stepping') { state.line.must_equal 11 }
17
- end
18
-
19
- it 'must go to the next line if forced by a setting (by shortcut)' do
20
- Byebug::Command.settings[:force_stepping] = true
21
- enter 'n'
22
- debug_file('stepping') { state.line.must_equal 11 }
23
- end
9
+ before { enter 'break 10', 'cont' }
24
10
 
25
11
  it 'must leave on the same line by default' do
26
12
  enter 'next'
27
13
  debug_file('stepping') { state.line.must_equal 10 }
28
14
  end
29
15
 
30
- it 'must go the specified number of lines forward by default' do
31
- Byebug::Command.settings[:force_stepping] = true
32
- enter 'next 2'
33
- debug_file('stepping') { state.line.must_equal 21 }
34
- end
35
-
36
16
  it 'must go to the next line if forced by "plus" sign' do
37
17
  enter 'next+'
38
18
  debug_file('stepping') { state.line.must_equal 11 }
@@ -43,15 +23,33 @@ describe 'Stepping Commands' do
43
23
  debug_file('stepping') { state.line.must_equal 10 }
44
24
  end
45
25
 
46
- it 'must ignore the setting if "minus" is specified' do
47
- Byebug::Command.settings[:force_stepping] = true
48
- enter 'next-'
49
- debug_file('stepping') { state.line.must_equal 10 }
26
+ describe 'when force_stepping is set' do
27
+ temporary_change_hash Byebug::Command.settings, :force_stepping, true
28
+
29
+ it 'must go to the next line' do
30
+ enter 'next'
31
+ debug_file('stepping') { state.line.must_equal 11 }
32
+ end
33
+
34
+ it 'must go to the next line (by shortcut)' do
35
+ enter 'n'
36
+ debug_file('stepping') { state.line.must_equal 11 }
37
+ end
38
+
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
45
+ enter 'next-'
46
+ debug_file('stepping') { state.line.must_equal 10 }
47
+ end
50
48
  end
51
49
  end
52
50
 
53
51
  describe 'Post Mortem' do
54
- before { Byebug::Command.settings[:autoeval] = false }
52
+ temporary_change_hash Byebug::Command.settings, :autoeval, false
55
53
 
56
54
  it 'must not work in post-mortem mode' do
57
55
  enter 'cont', 'next'
@@ -65,34 +63,13 @@ describe 'Stepping Commands' do
65
63
  describe 'Step Command' do
66
64
 
67
65
  describe 'Usual mode' do
68
-
69
- before do
70
- enter 'break 10', 'cont'
71
- end
72
-
73
- it 'must go to the step line if forced by a setting' do
74
- Byebug::Command.settings[:force_stepping] = true
75
- enter 'step'
76
- debug_file('stepping') { state.line.must_equal 11 }
77
- end
78
-
79
- it 'must go to the next line if forced by a setting (by shortcut)' do
80
- Byebug::Command.settings[:force_stepping] = true
81
- enter 's'
82
- debug_file('stepping') { state.line.must_equal 11 }
83
- end
66
+ before { enter 'break 10', 'cont' }
84
67
 
85
68
  it 'must leave on the same line if forced by a setting' do
86
69
  enter 'step'
87
70
  debug_file('stepping') { state.line.must_equal 10 }
88
71
  end
89
72
 
90
- it 'must go the specified number of lines forward by default' do
91
- Byebug::Command.settings[:force_stepping] = true
92
- enter 'step 2'
93
- debug_file('stepping') { state.line.must_equal 15 }
94
- end
95
-
96
73
  it 'must go to the step line if forced to do that by "plus" sign' do
97
74
  enter 'step+'
98
75
  debug_file('stepping') { state.line.must_equal 11 }
@@ -102,10 +79,29 @@ describe 'Stepping Commands' do
102
79
  enter 'step-'
103
80
  debug_file('stepping') { state.line.must_equal 10 }
104
81
  end
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
87
+ enter 'step'
88
+ debug_file('stepping') { state.line.must_equal 11 }
89
+ end
90
+
91
+ it 'must go to the next line if forced by a setting (by shortcut)' do
92
+ enter 's'
93
+ debug_file('stepping') { state.line.must_equal 11 }
94
+ end
95
+
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 }
99
+ end
100
+ end
105
101
  end
106
102
 
107
103
  describe 'Post Mortem' do
108
- before { Byebug::Command.settings[:autoeval] = false }
104
+ temporary_change_hash Byebug::Command.settings, :autoeval, false
109
105
 
110
106
  it 'must not work in post-mortem mode' do
111
107
  enter 'cont', 'step'
@@ -1,17 +1,9 @@
1
1
  module TestDsl
2
2
 
3
- module Shared
4
- def fullpath(filename)
5
- (Pathname.new(__FILE__) + "../../examples/#{filename}.rb").cleanpath.to_s
6
- end
7
- end
8
-
9
- include Shared
10
-
11
3
  def self.included(base)
12
4
  base.class_eval do
5
+ extend ClassUtils
13
6
  before do
14
- load_defaults
15
7
  Byebug.interface = TestInterface.new
16
8
  Byebug.handler.display.clear
17
9
  end
@@ -19,30 +11,10 @@ module TestDsl
19
11
  end
20
12
 
21
13
  ##
22
- # Loads byebug default settings
14
+ # Expand fullpath of a given example file
23
15
  #
24
- def load_defaults
25
- Byebug::Command.settings[:testing] = true
26
- Byebug::Command.settings[:basename] = false
27
- Byebug::Command.settings[:callstyle] = :last
28
- Byebug::Command.settings[:force_stepping] = false
29
- Byebug::Command.settings[:full_path] = true
30
- Byebug::Command.settings[:listsize] = 10
31
- Byebug::Command.settings[:stack_trace_on_error] = false
32
- Byebug::Command.settings[:tracing_plus] = false
33
- Byebug::Command.settings[:width] =
34
- ENV['COLUMNS'].to_i > 10 ? ENV['COLUMNS'].to_i : 80
35
- Byebug::Command.settings[:argv] = Byebug::ARGV
36
- Byebug::Command.settings[:autolist] = 1
37
- Byebug::Command.settings[:autoeval] = true
38
- Byebug::Command.settings[:reload_source_on_change] = 1
39
- force_unset_const Byebug, 'BYEBUG_SCRIPT'
40
- force_set_const Byebug, 'DEFAULT_START_SETTINGS',
41
- init: true, post_mortem: false, tracing: nil
42
- force_set_const Byebug, 'ARGV', ARGV.clone
43
- force_set_const Byebug, 'PROG_SCRIPT', $0
44
- force_set_const Byebug, 'INITIAL_DIR', Dir.pwd
45
- Byebug.annotate = 0
16
+ def fullpath(filename)
17
+ (Pathname.new(__FILE__) + "../../examples/#{filename}.rb").cleanpath.to_s
46
18
  end
47
19
 
48
20
  ##
@@ -164,31 +136,51 @@ module TestDsl
164
136
  File.open(file, 'w') { |f| f.write(new_content) }
165
137
  end
166
138
 
167
- def temporary_change_method_value(item, method, value)
168
- old = item.send(method)
169
- item.send("#{method}=", value)
170
- yield
171
- ensure
172
- item.send("#{method}=", old)
173
- end
174
139
 
175
- def temporary_change_hash_value(item, key, value)
176
- old_value = item[key]
177
- item[key] = value
178
- yield
179
- ensure
180
- item[key] = old_value
181
- end
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
182
 
183
- def temporary_set_const(klass, const, value)
184
- old_value = klass.const_defined?(const) ? klass.const_get(const) : :__undefined__
185
- force_set_const(klass, const, value)
186
- yield
187
- ensure
188
- if old_value == :__undefined__
189
- klass.send(:remove_const, const)
190
- else
191
- force_set_const(klass, const, old_value)
183
+ include mod
192
184
  end
193
185
  end
194
186
 
@@ -1,9 +1,9 @@
1
1
  require 'rubygems'
2
- require 'pathname'
3
2
  require 'minitest/autorun'
3
+ require 'pathname'
4
4
  require 'mocha/setup'
5
5
  require 'byebug'
6
6
 
7
7
  Dir.glob(File.expand_path("../support/*.rb", __FILE__)).each { |f| require f }
8
8
 
9
- Byebug.annotate = 2
9
+ Byebug::Command.settings[:testing] = true
@@ -16,7 +16,7 @@ describe 'Trace Command' do
16
16
  it 'must trace execution by setting trace to on' do
17
17
  enter 'trace on', 'cont 7', 'trace off'
18
18
  debug_file 'trace'
19
- check_output_includes 'Tracing is on',
19
+ check_output_includes 'line tracing is on.',
20
20
  "Tracing: #{fullpath('trace')}:4 $bla = 4",
21
21
  "Tracing: #{fullpath('trace')}:7 $bla = 7"
22
22
  end
@@ -24,7 +24,7 @@ describe 'Trace Command' do
24
24
  it 'must be able to use a shortcut' do
25
25
  enter 'tr on', 'cont 7', 'trace off'
26
26
  debug_file 'trace'
27
- check_output_includes 'Tracing is on',
27
+ check_output_includes 'line tracing is on.',
28
28
  "Tracing: #{fullpath('trace')}:4 $bla = 4",
29
29
  "Tracing: #{fullpath('trace')}:7 $bla = 7"
30
30
  end
@@ -49,7 +49,7 @@ describe 'Trace Command' do
49
49
  it 'must show a message when turned off' do
50
50
  enter 'trace off'
51
51
  debug_file 'trace'
52
- check_output_includes 'Tracing is off'
52
+ check_output_includes 'line tracing is off.'
53
53
  end
54
54
  end
55
55
  end
@@ -99,7 +99,7 @@ describe 'Trace Command' do
99
99
  it 'must work in post-mortem mode' do
100
100
  enter 'cont', 'trace on'
101
101
  debug_file 'post_mortem'
102
- check_output_includes 'Tracing is on'
102
+ check_output_includes 'line tracing is on.'
103
103
  end
104
104
  end
105
105
 
@@ -3,9 +3,7 @@ require_relative 'test_helper'
3
3
  describe 'Variables Command' do
4
4
  include TestDsl
5
5
 
6
- def after_setup
7
- Byebug::Command.settings[:width] = 40
8
- end
6
+ temporary_change_hash Byebug::Command.settings, :width, 40
9
7
 
10
8
  describe 'class variables' do
11
9
  it 'must show variables' do
@@ -80,14 +78,18 @@ describe 'Variables Command' do
80
78
  check_output_includes '@inst_a = 1', '@inst_b = 2'
81
79
  end
82
80
 
83
- it 'must cut long variable values according to :width setting' do
84
- enter 'set width 20', 'break 25', 'cont', 'var instance v'
85
- debug_file 'variables'
86
- check_output_includes '@inst_c = "1111111111111111...'
81
+ describe 'when width is too small' do
82
+ temporary_change_hash Byebug::Command.settings, :width, 20
83
+
84
+ it 'must cut long variable values according it' do
85
+ enter 'break 25', 'cont', 'var instance v'
86
+ debug_file 'variables'
87
+ check_output_includes '@inst_c = "1111111111111111...'
88
+ end
87
89
  end
88
90
 
89
91
  it 'must show error if value doesn\'t have #to_s/#inspect methods' do
90
- enter 'set width 21', 'break 25', 'cont', 'var instance v'
92
+ enter 'break 25', 'cont', 'var instance v'
91
93
  debug_file 'variables'
92
94
  check_output_includes '@inst_d = *Error in evaluation*'
93
95
  end
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: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rodríguez
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-05-07 00:00:00.000000000 Z
13
+ date: 2013-05-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: columnize
@@ -74,28 +74,28 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 0.13.3
77
+ version: 0.14.0
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - ~>
83
83
  - !ruby/object:Gem::Version
84
- version: 0.13.3
84
+ version: 0.14.0
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: minitest
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - ~>
90
90
  - !ruby/object:Gem::Version
91
- version: 4.7.4
91
+ version: 5.0.1
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - ~>
97
97
  - !ruby/object:Gem::Version
98
- version: 4.7.4
98
+ version: 5.0.1
99
99
  description: |-
100
100
  Byebug is a Ruby 2.0 debugger. It's implemented using the
101
101
  Ruby 2.0 TracePoint C API. The C extension was forked from debase whereas
@@ -114,6 +114,7 @@ files:
114
114
  - .travis.yml
115
115
  - CHANGELOG.md
116
116
  - CONTRIBUTING.md
117
+ - GUIDE.md
117
118
  - Gemfile
118
119
  - LICENSE
119
120
  - README.md
@@ -140,13 +141,13 @@ files:
140
141
  - lib/byebug/commands/frame.rb
141
142
  - lib/byebug/commands/help.rb
142
143
  - lib/byebug/commands/info.rb
143
- - lib/byebug/commands/irb.rb
144
144
  - lib/byebug/commands/jump.rb
145
145
  - lib/byebug/commands/kill.rb
146
146
  - lib/byebug/commands/list.rb
147
147
  - lib/byebug/commands/method.rb
148
148
  - lib/byebug/commands/quit.rb
149
149
  - lib/byebug/commands/reload.rb
150
+ - lib/byebug/commands/repl.rb
150
151
  - lib/byebug/commands/save.rb
151
152
  - lib/byebug/commands/set.rb
152
153
  - lib/byebug/commands/show.rb
@@ -160,7 +161,6 @@ files:
160
161
  - lib/byebug/interface.rb
161
162
  - lib/byebug/processor.rb
162
163
  - lib/byebug/version.rb
163
- - old_doc/Makefile
164
164
  - old_doc/byebug.1
165
165
  - old_doc/byebug.texi
166
166
  - old_doc/hanoi.rb
@@ -180,7 +180,6 @@ files:
180
180
  - test/examples/continue.rb
181
181
  - test/examples/display.rb
182
182
  - test/examples/edit.rb
183
- - test/examples/edit2.rb
184
183
  - test/examples/eval.rb
185
184
  - test/examples/finish.rb
186
185
  - test/examples/frame.rb
@@ -210,7 +209,6 @@ files:
210
209
  - test/frame_test.rb
211
210
  - test/help_test.rb
212
211
  - test/info_test.rb
213
- - test/irb_test.rb
214
212
  - test/jump_test.rb
215
213
  - test/kill_test.rb
216
214
  - test/list_test.rb
@@ -218,6 +216,7 @@ files:
218
216
  - test/post_mortem_test.rb
219
217
  - test/quit_test.rb
220
218
  - test/reload_test.rb
219
+ - test/repl_test.rb
221
220
  - test/restart_test.rb
222
221
  - test/save_test.rb
223
222
  - test/set_test.rb