byebug 1.0.2 → 1.0.3

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/README.md +1 -1
  4. data/bin/byebug +1 -2
  5. data/byebug.gemspec +1 -1
  6. data/ext/byebug/byebug.c +50 -35
  7. data/ext/byebug/context.c +99 -45
  8. data/lib/byebug.rb +5 -10
  9. data/lib/byebug/command.rb +20 -12
  10. data/lib/byebug/commands/breakpoints.rb +1 -1
  11. data/lib/byebug/commands/control.rb +14 -21
  12. data/lib/byebug/commands/display.rb +4 -4
  13. data/lib/byebug/commands/enable.rb +20 -19
  14. data/lib/byebug/commands/eval.rb +1 -1
  15. data/lib/byebug/commands/finish.rb +4 -5
  16. data/lib/byebug/commands/info.rb +118 -116
  17. data/lib/byebug/commands/list.rb +72 -48
  18. data/lib/byebug/commands/reload.rb +4 -3
  19. data/lib/byebug/commands/set.rb +7 -16
  20. data/lib/byebug/commands/show.rb +2 -2
  21. data/lib/byebug/commands/threads.rb +7 -6
  22. data/lib/byebug/context.rb +10 -2
  23. data/lib/byebug/helper.rb +3 -3
  24. data/lib/byebug/processor.rb +1 -1
  25. data/lib/byebug/version.rb +1 -1
  26. data/old_doc/byebug.texi +45 -51
  27. data/test/breakpoints_test.rb +180 -195
  28. data/test/display_test.rb +59 -53
  29. data/test/eval_test.rb +0 -2
  30. data/test/examples/info.rb +5 -5
  31. data/test/examples/info_threads.rb +1 -1
  32. data/test/finish_test.rb +16 -15
  33. data/test/info_test.rb +9 -10
  34. data/test/irb_test.rb +64 -65
  35. data/test/list_test.rb +76 -50
  36. data/test/method_test.rb +10 -5
  37. data/test/post_mortem_test.rb +27 -25
  38. data/test/reload_test.rb +31 -31
  39. data/test/restart_test.rb +106 -110
  40. data/test/show_test.rb +8 -16
  41. data/test/stepping_test.rb +4 -2
  42. data/test/support/test_dsl.rb +37 -76
  43. data/test/test_helper.rb +0 -1
  44. data/test/variables_test.rb +9 -12
  45. metadata +4 -4
@@ -4,33 +4,27 @@ describe "Show Command" do
4
4
  include TestDsl
5
5
 
6
6
  describe "annotate" do
7
- temporary_change_method_value(Byebug, :annotate, nil)
8
-
9
- it "must show annotate setting" do
10
- enter 'show annotate'
11
- debug_file 'show'
12
- check_output_includes "Annotation level is 0"
13
- end
14
-
15
7
  it "must show annotate setting" do
16
8
  enter 'show annotate'
17
9
  debug_file 'show'
18
10
  Byebug.annotate.must_equal 0
11
+ check_output_includes "Annotation level is 0"
19
12
  end
20
13
  end
21
14
 
22
15
  describe "args" do
23
- temporary_change_hash_value(Byebug::Command.settings, :argv, %w{foo bar})
16
+ before do
17
+ Byebug::Command.settings[:argv] = %w{foo bar}
18
+ end
24
19
 
25
20
  it "must show args" do
26
- Byebug.send(:remove_const, "RDEBUG_SCRIPT") if Byebug.const_defined?("RDEBUG_SCRIPT")
27
21
  enter 'show args'
28
22
  debug_file 'show'
29
23
  check_output_includes 'Argument list to give program being debugged when it is started is "foo bar".'
30
24
  end
31
25
 
32
- it "must not show the first arg if RDEBUG_SCRIPT is defined" do
33
- temporary_set_const(Byebug, "RDEBUG_SCRIPT", "bla") do
26
+ it "must not show the first arg if BYEBUG_SCRIPT is defined" do
27
+ temporary_set_const(Byebug, "BYEBUG_SCRIPT", "bla") do
34
28
  enter 'show args'
35
29
  debug_file 'show'
36
30
  check_output_includes 'Argument list to give program being debugged when it is started is "bar".'
@@ -133,7 +127,7 @@ describe "Show Command" do
133
127
  temporary_change_hash_value(Byebug::Command.settings, :listsize, 10) do
134
128
  enter 'show listsize'
135
129
  debug_file 'show'
136
- check_output_includes 'Number of source lines to list by default is 10.'
130
+ check_output_includes 'Number of source lines to list is 10.'
137
131
  end
138
132
  end
139
133
 
@@ -276,13 +270,11 @@ describe "Show Command" do
276
270
  end
277
271
 
278
272
  describe "Post Mortem" do
279
- temporary_change_hash_value(Byebug::Command.settings, :autolist, 0)
280
-
281
273
  it "must work in post-mortem mode" do
282
274
  skip("No post morten mode for now")
283
275
  enter 'cont', "show autolist"
284
276
  debug_file 'post_mortem'
285
- check_output_includes "autolist is off."
277
+ check_output_includes "autolist is on."
286
278
  end
287
279
  end
288
280
 
@@ -52,7 +52,8 @@ describe "Stepping Commands" do
52
52
  end
53
53
 
54
54
  describe "Post Mortem" do
55
- temporary_change_hash_value(Byebug::Command.settings, :autoeval, false)
55
+ before { Byebug::Command.settings[:autoeval] = 0 }
56
+
56
57
  it "must not work in post-mortem mode" do
57
58
  skip("No post morten mode for now")
58
59
  enter 'cont', "next"
@@ -106,7 +107,8 @@ describe "Stepping Commands" do
106
107
  end
107
108
 
108
109
  describe "Post Mortem" do
109
- temporary_change_hash_value(Byebug::Command.settings, :autoeval, false)
110
+ before { Byebug::Command.settings[:autoeval] = 0 }
111
+
110
112
  it "must not work in post-mortem mode" do
111
113
  skip("No post morten mode for now")
112
114
  enter 'cont', "step"
@@ -10,18 +10,41 @@ module TestDsl
10
10
 
11
11
  def self.included(base)
12
12
  base.class_eval do
13
- extend ClassMethods
14
13
  before do
15
- Byebug::Command.settings[:byebugtesting] = true
14
+ load_defaults
16
15
  Byebug.interface = TestInterface.new
17
16
  Byebug.handler.display.clear
18
17
  end
19
- after do
20
- Byebug.handler.display.clear
21
- end
22
18
  end
23
19
  end
24
20
 
21
+ ##
22
+ # Loads byebug default settings
23
+ #
24
+ def load_defaults
25
+ Byebug::Command.settings[:byebugtesting] = 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] = 1
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
46
+ end
47
+
25
48
  ##
26
49
  # Adds commands to the input queue, so they will be later retrieved by
27
50
  # Processor, i.e., it emulates user's input.
@@ -102,6 +125,10 @@ module TestDsl
102
125
  queue_messages.send(check_method, messages)
103
126
  end
104
127
 
128
+ def check_error_includes(*args)
129
+ check_output :must_include_in_order, *args, interface.error_queue
130
+ end
131
+
105
132
  def check_output_includes(*args)
106
133
  check_output :must_include_in_order, *args
107
134
  end
@@ -123,10 +150,14 @@ module TestDsl
123
150
  end
124
151
 
125
152
  def force_set_const(klass, const, value)
126
- klass.send(:remove_const, const) if klass.const_defined?(const)
153
+ force_unset_const(klass, const)
127
154
  klass.const_set(const, value)
128
155
  end
129
156
 
157
+ def force_unset_const(klass, const)
158
+ klass.send(:remove_const, const) if klass.const_defined?(const)
159
+ end
160
+
130
161
  def change_line_in_file(file, line, new_line_content)
131
162
  old_content = File.read(file)
132
163
  new_content = old_content.split("\n").tap { |c| c[line - 1] = new_line_content }.join("\n")
@@ -161,74 +192,4 @@ module TestDsl
161
192
  end
162
193
  end
163
194
 
164
- def set_tmp_hash(hash, key, value)
165
- @old_hashes.merge!({ hash => { key => hash[key] } }) do |k, v1, v2|
166
- v1.merge(v2)
167
- end
168
- hash[key] = value
169
- end
170
-
171
- def restore_tmp_hash(hash, key)
172
- hash[key] = @old_hashes[hash][key]
173
- end
174
-
175
- def set_tmp_const(klass, const, value)
176
- @old_consts.merge!({ klass =>
177
- { const => klass.const_defined?(const) ?
178
- klass.const_get(const) : :__undefined__ } }) do |k, v1, v2|
179
- v1.merge(v2)
180
- end
181
- value == :__undefined__ ? klass.send(:remove_const, const) :
182
- force_set_const(klass, const, value)
183
- end
184
-
185
- def restore_tmp_const(klass, const)
186
- @old_consts[klass][const] == :__undefined ?
187
- klass.send(:remove_const, const) :
188
- force_set_const(klass, const, @old_consts[klass][const])
189
- end
190
-
191
-
192
- module ClassMethods
193
-
194
- include Shared
195
-
196
- def temporary_change_method_value(item, method, value)
197
- old_value = nil
198
- before do
199
- old_value = item.send(method)
200
- item.send("#{method}=", value)
201
- end
202
- after do
203
- item.send("#{method}=", old_value)
204
- end
205
- end
206
-
207
- def temporary_change_hash_value(item, key, value)
208
- old_value = nil
209
- before do
210
- old_value = item[key]
211
- item[key] = value
212
- end
213
- after do
214
- item[key] = old_value
215
- end
216
- end
217
-
218
- def temporary_set_const(klass, const, value)
219
- old_value = nil
220
- before do
221
- old_value = klass.const_defined?(const) ? klass.const_get(const) : :__undefined__
222
- force_set_const(klass, const, value)
223
- end
224
- after do
225
- if old_value == :__undefined__
226
- klass.send(:remove_const, const)
227
- else
228
- force_set_const(klass, const, old_value)
229
- end
230
- end
231
- end
232
- end
233
-
234
195
  end
@@ -1,7 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'pathname'
3
3
  require 'minitest/autorun'
4
- require 'minitest/spec'
5
4
  require 'mocha/setup'
6
5
  require 'byebug'
7
6
 
@@ -1,13 +1,12 @@
1
1
  require_relative 'test_helper'
2
2
 
3
3
  describe "Variables Command" do
4
-
5
- extend TestDsl::ClassMethods
6
-
7
- temporary_change_hash_value(Byebug::Command.settings, :width, 40)
8
-
9
4
  include TestDsl
10
5
 
6
+ def after_setup
7
+ Byebug::Command.settings[:width] = 40
8
+ end
9
+
11
10
  describe "class variables" do
12
11
  it "must show variables" do
13
12
  enter 'break 19', 'cont', 'var class'
@@ -82,15 +81,13 @@ describe "Variables Command" do
82
81
  end
83
82
 
84
83
  it "must cut long variable values according to :width setting" do
85
- Byebug::Command.settings[:width] = 20
86
- enter 'break 25', 'cont', 'var instance v'
84
+ enter 'set width 20', 'break 25', 'cont', 'var instance v'
87
85
  debug_file 'variables'
88
86
  check_output_includes '@inst_c = "1111111111111111...'
89
87
  end
90
88
 
91
89
  it "must show fallback message if value doesn't have #to_s or #inspect methods" do
92
- Byebug::Command.settings[:width] = 21
93
- enter 'break 25', 'cont', 'var instance v'
90
+ enter 'set width 21', 'break 25', 'cont', 'var instance v'
94
91
  debug_file 'variables'
95
92
  check_output_includes '@inst_d = *Error in evaluation*'
96
93
  end
@@ -110,9 +107,9 @@ describe "Variables Command" do
110
107
  describe "Post Mortem" do
111
108
  it "must work in post-mortem mode" do
112
109
  skip("No post morten mode for now")
113
- #enter 'cont', 'var local'
114
- #debug_file 'post_mortem'
115
- #check_output_includes "x => nil", "z => 4"
110
+ enter 'cont', 'var local'
111
+ debug_file 'post_mortem'
112
+ check_output_includes "x => nil", "z => 4"
116
113
  end
117
114
  end
118
115
 
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.0.2
4
+ version: 1.0.3
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-04-09 00:00:00.000000000 Z
13
+ date: 2013-04-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: columnize
@@ -88,14 +88,14 @@ dependencies:
88
88
  requirements:
89
89
  - - ~>
90
90
  - !ruby/object:Gem::Version
91
- version: 4.7.0
91
+ version: 4.7.3
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.0
98
+ version: 4.7.3
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