byebug 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/GUIDE.md +231 -0
- data/README.md +195 -7
- data/bin/byebug +1 -5
- data/byebug.gemspec +34 -35
- data/lib/byebug.rb +2 -5
- data/lib/byebug/command.rb +13 -13
- data/lib/byebug/commands/breakpoints.rb +1 -1
- data/lib/byebug/commands/control.rb +1 -1
- data/lib/byebug/commands/frame.rb +1 -1
- data/lib/byebug/commands/info.rb +1 -1
- data/lib/byebug/commands/list.rb +5 -5
- data/lib/byebug/commands/reload.rb +7 -10
- data/lib/byebug/commands/{irb.rb → repl.rb} +49 -13
- data/lib/byebug/commands/set.rb +10 -6
- data/lib/byebug/commands/show.rb +4 -7
- data/lib/byebug/commands/trace.rb +2 -2
- data/lib/byebug/context.rb +3 -5
- data/lib/byebug/helper.rb +2 -2
- data/lib/byebug/interface.rb +3 -0
- data/lib/byebug/processor.rb +2 -2
- data/lib/byebug/version.rb +1 -1
- data/old_doc/byebug.1 +1 -2
- data/old_doc/byebug.texi +125 -126
- data/old_doc/hanoi.rb +2 -3
- data/old_doc/triangle.rb +6 -7
- data/test/breakpoints_test.rb +43 -33
- data/test/display_test.rb +1 -1
- data/test/edit_test.rb +20 -15
- data/test/eval_test.rb +32 -26
- data/test/examples/list.rb +12 -1
- data/test/frame_test.rb +56 -43
- data/test/help_test.rb +11 -8
- data/test/info_test.rb +18 -13
- data/test/list_test.rb +74 -80
- data/test/method_test.rb +1 -3
- data/test/reload_test.rb +3 -3
- data/test/repl_test.rb +112 -0
- data/test/restart_test.rb +72 -70
- data/test/set_test.rb +43 -27
- data/test/show_test.rb +97 -102
- data/test/source_test.rb +6 -10
- data/test/stepping_test.rb +45 -49
- data/test/support/test_dsl.rb +47 -55
- data/test/test_helper.rb +2 -2
- data/test/trace_test.rb +4 -4
- data/test/variables_test.rb +10 -8
- metadata +9 -10
- data/old_doc/Makefile +0 -20
- data/test/examples/edit2.rb +0 -3
- data/test/irb_test.rb +0 -85
data/old_doc/hanoi.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Solves the classic Towers of Hanoi puzzle.
|
3
2
|
def hanoi(n,a,b,c)
|
4
3
|
if n-1 > 0
|
5
4
|
hanoi(n-1, a, c, b)
|
@@ -21,7 +20,7 @@ n=3
|
|
21
20
|
if i_args > 0
|
22
21
|
begin
|
23
22
|
n = ARGV[0].to_i
|
24
|
-
rescue ValueError, msg
|
23
|
+
rescue ValueError, :msg
|
25
24
|
print "** Expecting an integer, got: %s" % ARGV[0].to_s
|
26
25
|
exit 2
|
27
26
|
end
|
data/old_doc/triangle.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
|
2
|
-
# Compute the n'th triangle number - the hard way
|
3
|
-
# triangle(n) == (n * (n+1)) / 2
|
1
|
+
# Compute the n'th triangle number, the hard way: triangle(n) == (n*(n+1))/2
|
4
2
|
def triangle(n)
|
5
3
|
tri = 0
|
6
4
|
0.upto(n) do |i|
|
7
5
|
tri += i
|
8
6
|
end
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
tri
|
8
|
+
end
|
9
|
+
|
10
|
+
t = triangle(3)
|
11
|
+
puts t
|
data/test/breakpoints_test.rb
CHANGED
@@ -77,47 +77,57 @@ describe 'Breakpoints' do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
describe 'show a message' do
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
describe 'with full filename' do
|
81
|
+
temporary_change_hash Byebug::Command.settings, :basename, false
|
82
|
+
|
83
|
+
it 'must show a message with full filename' do
|
84
|
+
enter 'break 14', 'cont'
|
85
|
+
debug_file('breakpoint1') { @id = Byebug.breakpoints.first.id }
|
86
|
+
check_output_includes \
|
87
|
+
"Created breakpoint #{@id} at #{fullpath('breakpoint1')}:14"
|
88
|
+
end
|
85
89
|
end
|
86
90
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
+
describe 'with basename' do
|
92
|
+
temporary_change_hash Byebug::Command.settings, :basename, true
|
93
|
+
|
94
|
+
it 'must show a message with basename' do
|
95
|
+
enter 'break 14', 'cont'
|
96
|
+
debug_file('breakpoint1') { @id = Byebug.breakpoints.first.id }
|
97
|
+
check_output_includes "Created breakpoint #{@id} at breakpoint1.rb:14"
|
98
|
+
end
|
91
99
|
end
|
92
100
|
end
|
93
101
|
end
|
94
102
|
|
95
103
|
describe 'reloading source on change' do
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
104
|
+
describe 'autoreload not set' do
|
105
|
+
temporary_change_hash Byebug::Command.settings, :autoreload, false
|
106
|
+
|
107
|
+
it 'must not reload source' do
|
108
|
+
id = nil
|
109
|
+
enter \
|
110
|
+
->{change_line_in_file(fullpath('breakpoint1'), 14, ''); 'break 14'},
|
111
|
+
->{change_line_in_file(fullpath('breakpoint1'), 14, 'c = a + b');
|
102
112
|
'cont'}
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
'
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
113
|
+
debug_file('breakpoint1') { id = Byebug.breakpoints.first.id }
|
114
|
+
check_output_includes \
|
115
|
+
"Created breakpoint #{id} at #{fullpath('breakpoint1')}:14"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe 'autoreload set' do
|
120
|
+
it 'must reload source' do
|
121
|
+
enter \
|
122
|
+
->{change_line_in_file(fullpath('breakpoint1'), 14, ''); 'break 14'},
|
123
|
+
# 2nd breakpoint just to reload source code after rolling changes back
|
124
|
+
->{change_line_in_file(fullpath('breakpoint1'), 14, 'c = a + b');
|
125
|
+
'break 15'}, 'cont'
|
126
|
+
debug_file 'breakpoint1'
|
127
|
+
check_output_includes \
|
128
|
+
"Line 14 is not a stopping point in file #{fullpath('breakpoint1')}",
|
129
|
+
interface.error_queue
|
130
|
+
end
|
121
131
|
end
|
122
132
|
end
|
123
133
|
|
data/test/display_test.rb
CHANGED
@@ -136,7 +136,7 @@ describe 'Display Command' do
|
|
136
136
|
end
|
137
137
|
|
138
138
|
describe 'Post Mortem' do
|
139
|
-
|
139
|
+
temporary_change_hash Byebug::Command.settings, :autoeval, false
|
140
140
|
|
141
141
|
it 'must be able to set display expressions in post-mortem mode' do
|
142
142
|
enter 'cont', 'display 2 + 2'
|
data/test/edit_test.rb
CHANGED
@@ -3,8 +3,10 @@ require_relative 'test_helper'
|
|
3
3
|
describe 'Edit Command' do
|
4
4
|
include TestDsl
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
describe 'open configured editor' do
|
7
|
+
temporary_change_hash ENV, 'EDITOR', 'editr'
|
8
|
+
|
9
|
+
it 'must open current file in current line in configured editor' do
|
8
10
|
Byebug::Edit.any_instance.expects(:system).
|
9
11
|
with("editr +2 #{fullpath('edit')}")
|
10
12
|
enter 'edit'
|
@@ -12,8 +14,10 @@ describe 'Edit Command' do
|
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
+
describe 'open default editor' do
|
18
|
+
temporary_change_hash ENV, 'EDITOR', nil
|
19
|
+
|
20
|
+
it 'must call "ex" with current line and file if EDITOR env not set' do
|
17
21
|
Byebug::Edit.any_instance.expects(:system).
|
18
22
|
with("ex +2 #{fullpath('edit')}")
|
19
23
|
enter 'edit'
|
@@ -21,11 +25,13 @@ describe 'Edit Command' do
|
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
24
|
-
|
25
|
-
|
28
|
+
describe 'open configured editor specifying line and file' do
|
29
|
+
temporary_change_hash ENV, 'EDITOR', 'editr'
|
30
|
+
|
31
|
+
it 'must open specified line in specified file with configured editor' do
|
26
32
|
Byebug::Edit.any_instance.expects(:system).
|
27
|
-
with("editr +3 #{fullpath('
|
28
|
-
enter "edit #{fullpath('
|
33
|
+
with("editr +3 #{fullpath('breakpoint1')}")
|
34
|
+
enter "edit #{fullpath('breakpoint1')}:3"
|
29
35
|
debug_file 'edit'
|
30
36
|
end
|
31
37
|
end
|
@@ -44,15 +50,14 @@ describe 'Edit Command' do
|
|
44
50
|
'Invalid file/line number specification: blabla', interface.error_queue
|
45
51
|
end
|
46
52
|
|
47
|
-
|
48
53
|
describe 'Post Mortem' do
|
54
|
+
temporary_change_hash ENV, 'EDITOR', 'editr'
|
55
|
+
|
49
56
|
it 'must work in post-mortem mode' do
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
debug_file 'post_mortem'
|
55
|
-
end
|
57
|
+
Byebug::Edit.any_instance.expects(:system).
|
58
|
+
with("editr +2 #{fullpath('edit')}")
|
59
|
+
enter 'cont', "edit #{fullpath('edit')}:2", 'cont'
|
60
|
+
debug_file 'post_mortem'
|
56
61
|
end
|
57
62
|
end
|
58
63
|
|
data/test/eval_test.rb
CHANGED
@@ -38,51 +38,57 @@ describe 'Eval Command' do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe 'stack trace on error' do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
describe 'when enabled' do
|
42
|
+
temporary_change_hash Byebug::Command.settings, :stack_trace_on_error, true
|
43
|
+
|
44
|
+
it 'must show a stack trace' do
|
45
|
+
enter 'eval 2 / 0'
|
46
|
+
debug_file 'eval'
|
47
|
+
check_output_includes /\S+:\d+:in `eval':divided by 0/
|
48
|
+
check_output_doesnt_include 'ZeroDivisionError Exception: divided by 0'
|
49
|
+
end
|
46
50
|
end
|
47
51
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
52
|
+
describe 'when disabled' do
|
53
|
+
temporary_change_hash Byebug::Command.settings, :stack_trace_on_error, false
|
54
|
+
|
55
|
+
it 'must only show exception' do
|
56
|
+
enter 'eval 2 / 0'
|
57
|
+
debug_file 'eval'
|
58
|
+
check_output_includes 'ZeroDivisionError Exception: divided by 0'
|
59
|
+
check_output_doesnt_include /\S+:\d+:in `eval':divided by 0/
|
60
|
+
end
|
53
61
|
end
|
54
62
|
end
|
55
63
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
64
|
+
describe 'pp' do
|
65
|
+
it 'must pretty print the expression result' do
|
66
|
+
enter 'pp {a: \'3\' * 40, b: \'4\' * 30}'
|
67
|
+
debug_file 'eval'
|
68
|
+
check_output_includes "{:a=>\"#{'3' * 40}\",\n :b=>\"#{'4' * 30}\"}"
|
69
|
+
end
|
60
70
|
end
|
61
71
|
|
62
|
-
|
63
|
-
|
72
|
+
describe 'putl' do
|
73
|
+
temporary_change_hash Byebug::Command.settings, :width, 20
|
74
|
+
|
75
|
+
it 'must print expression and columnize the result' do
|
64
76
|
enter 'putl [1, 2, 3, 4, 5, 9, 8, 7, 6]'
|
65
77
|
debug_file 'eval'
|
66
78
|
check_output_includes "1 3 5 8 6\n2 4 9 7"
|
67
79
|
end
|
68
80
|
end
|
69
81
|
|
70
|
-
|
71
|
-
|
82
|
+
describe 'ps' do
|
83
|
+
temporary_change_hash Byebug::Command.settings, :width, 20
|
84
|
+
|
85
|
+
it 'must print expression and sort and columnize the result' do
|
72
86
|
enter 'ps [1, 2, 3, 4, 5, 9, 8, 7, 6]'
|
73
87
|
debug_file 'eval'
|
74
88
|
check_output_includes "1 3 5 7 9\n2 4 6 8"
|
75
89
|
end
|
76
90
|
end
|
77
91
|
|
78
|
-
it 'must set width by the "set" command' do
|
79
|
-
temporary_change_hash_value(Byebug::PSCommand.settings, :width, 20) do
|
80
|
-
enter 'set width 10', 'ps [1, 2, 3, 4, 5, 9, 8, 7, 6]'
|
81
|
-
debug_file 'eval'
|
82
|
-
check_output_includes "1 4 7\n2 5 8\n3 6 9"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
92
|
describe 'Post Mortem' do
|
87
93
|
it 'must work in post-mortem mode' do
|
88
94
|
enter 'cont', 'eval 2 + 2'
|
data/test/examples/list.rb
CHANGED
data/test/frame_test.rb
CHANGED
@@ -3,10 +3,9 @@ require_relative 'test_helper'
|
|
3
3
|
describe 'Frame Command' do
|
4
4
|
include TestDsl
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
6
|
+
# XXX: Calculate magic number dinamically, like
|
7
|
+
# "longest_string_in_test_output".size
|
8
|
+
temporary_change_hash Byebug::Command.settings, :width, 96
|
10
9
|
|
11
10
|
it 'must go up' do
|
12
11
|
enter 'break 16', 'cont', 'up'
|
@@ -40,7 +39,8 @@ describe 'Frame Command' do
|
|
40
39
|
|
41
40
|
it 'must print current stack frame when without arguments' do
|
42
41
|
enter 'break A.d', 'cont', 'up', 'frame'
|
43
|
-
debug_file('frame') {
|
42
|
+
debug_file('frame') {
|
43
|
+
check_output_includes "#0 A.d(e#String) at #{fullpath('frame')}:15" }
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'must set frame to the first one' do
|
@@ -70,64 +70,77 @@ describe 'Frame Command' do
|
|
70
70
|
interface.error_queue
|
71
71
|
end
|
72
72
|
|
73
|
-
describe '
|
73
|
+
describe 'fullpath' do
|
74
74
|
def short_path(fullpath)
|
75
75
|
separator = File::ALT_SEPARATOR || File::SEPARATOR
|
76
76
|
"...#{separator}" + fullpath.split(separator)[-3..-1].join(separator)
|
77
77
|
end
|
78
78
|
|
79
|
-
|
80
|
-
Byebug::Command.settings
|
81
|
-
end
|
79
|
+
describe 'when set' do
|
80
|
+
temporary_change_hash Byebug::Command.settings, :frame_fullpath, true
|
82
81
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
82
|
+
it 'must display current backtrace with fullpaths' do
|
83
|
+
enter 'break 16', 'cont', 'where'
|
84
|
+
debug_file 'frame'
|
85
|
+
check_output_includes \
|
86
|
+
"--> #0 A.d(e#String) at #{fullpath('frame')}:16",
|
87
|
+
" #1 A.c at #{fullpath('frame')}:12"
|
88
|
+
end
|
88
89
|
end
|
89
90
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
91
|
+
describe 'when unset' do
|
92
|
+
temporary_change_hash Byebug::Command.settings, :frame_fullpath, false
|
93
|
+
|
94
|
+
it 'must display current backtrace with shortpaths' do
|
95
|
+
enter 'set nofullpath', 'break 16', 'cont', 'where'
|
96
|
+
debug_file 'frame'
|
97
|
+
check_output_includes \
|
98
|
+
"--> #0 A.d(e#String) at #{short_path(fullpath('frame'))}:16",
|
99
|
+
" #1 A.c at #{short_path(fullpath('frame'))}:12"
|
100
|
+
end
|
96
101
|
end
|
97
102
|
end
|
98
103
|
|
99
|
-
describe '
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
104
|
+
describe 'callstyle' do
|
105
|
+
describe 'last' do
|
106
|
+
temporary_change_hash Byebug::Command.settings, :callstyle, :last
|
107
|
+
|
108
|
+
it 'displays current backtrace with callstyle "last"' do
|
109
|
+
enter 'break 16', 'cont', 'where'
|
110
|
+
debug_file 'frame'
|
111
|
+
check_output_includes \
|
112
|
+
"--> #0 A.d(e#String) at #{fullpath('frame')}:16",
|
113
|
+
" #1 A.c at #{fullpath('frame')}:12" ,
|
114
|
+
" #2 A.b at #{fullpath('frame')}:8" ,
|
115
|
+
" #3 A.a at #{fullpath('frame')}:5"
|
116
|
+
end
|
107
117
|
end
|
108
118
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
119
|
+
describe 'short' do
|
120
|
+
temporary_change_hash Byebug::Command.settings, :callstyle, :short
|
121
|
+
|
122
|
+
it 'displays current backtrace with callstyle "short"' do
|
123
|
+
enter 'break 16', 'cont', 'where'
|
124
|
+
debug_file 'frame'
|
125
|
+
check_output_includes "--> #0 d(e) at #{fullpath('frame')}:16",
|
126
|
+
" #1 c at #{fullpath('frame')}:12" ,
|
127
|
+
" #2 b at #{fullpath('frame')}:8" ,
|
128
|
+
" #3 a at #{fullpath('frame')}:5"
|
129
|
+
end
|
116
130
|
end
|
117
131
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
132
|
+
describe 'tracked' do
|
133
|
+
temporary_change_hash Byebug::Command.settings, :callstyle, :tracked
|
134
|
+
|
135
|
+
it 'displays current backtrace with callstyle "tracked"' do
|
136
|
+
skip 'XXX: Style supported but not working....'
|
137
|
+
debug_file 'frame'
|
138
|
+
end
|
125
139
|
end
|
126
140
|
end
|
127
141
|
|
128
142
|
describe 'Post Mortem' do
|
129
143
|
it 'must work in post-mortem mode' do
|
130
|
-
#skip 'TODO: This test fails with \'Segmentation fault\'.'
|
131
144
|
enter 'cont', 'frame'
|
132
145
|
debug_file('post_mortem') { state.line.must_equal 8 }
|
133
146
|
end
|
data/test/help_test.rb
CHANGED
@@ -5,15 +5,18 @@ describe 'Help Command' do
|
|
5
5
|
include Columnize
|
6
6
|
|
7
7
|
let(:available_commands) {
|
8
|
-
Byebug::Command.commands.select(&:event).map(&:names).flatten.uniq.sort
|
9
|
-
}
|
8
|
+
Byebug::Command.commands.select(&:event).map(&:names).flatten.uniq.sort }
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
'
|
16
|
-
|
10
|
+
describe 'when typed alone' do
|
11
|
+
temporary_change_hash Byebug::Command.settings, :width, 50
|
12
|
+
|
13
|
+
it 'must show self help when typed alone' do
|
14
|
+
enter 'help'
|
15
|
+
debug_file 'help'
|
16
|
+
check_output_includes \
|
17
|
+
'Type "help <command-name>" for help on a specific command',
|
18
|
+
'Available commands:', columnize(available_commands, 50)
|
19
|
+
end
|
17
20
|
end
|
18
21
|
|
19
22
|
it 'must work when shortcut used' do
|