pry-moves 0.1.6 → 0.1.7
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +6 -9
- data/README.md +2 -0
- data/lib/pry-moves.rb +4 -1
- data/lib/pry-moves/backtrace.rb +1 -1
- data/lib/pry-moves/commands.rb +13 -12
- data/lib/pry-moves/pry_ext.rb +0 -3
- data/lib/pry-moves/pry_wrapper.rb +5 -3
- data/lib/pry-moves/trace_commands.rb +96 -0
- data/lib/pry-moves/tracer.rb +29 -59
- data/lib/pry-moves/version.rb +1 -1
- data/playground/Gemfile.lock +2 -2
- data/playground/playground.rb +10 -0
- data/playground/sand.rb +24 -9
- data/playground/test.rb +5 -0
- data/playground/threads.rb +15 -18
- data/spec/backtrace_spec.rb +12 -12
- data/spec/blocks_spec.rb +5 -6
- data/spec/commands_spec.rb +6 -6
- data/spec/pry_debugger.rb +3 -3
- data/spec/redirection_spec.rb +34 -0
- data/spec/spec_helper.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6153285cad4b74e4f713aa6a39220ffccdba822
|
4
|
+
data.tar.gz: a71792935b64874e19544c929d550ee720df99ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25310e06f4523f1b50a610e4ab896521d8747ce5fc775d80d38b9937c9c91665300cb82e671bc38f0da5aadd22acb3539037a07e72919d686eeb37a3890ab208
|
7
|
+
data.tar.gz: a00fc3b9880df6f65524cc804a677e2a209d0f0d5f9a207e1b06c0b1735bb731d68ffb3da5b706f43ae629d4bfe95352bd47de82d9b09d95a86ce16df80d0dda
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,7 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ../pry
|
3
|
-
specs:
|
4
|
-
pry (0.10.4)
|
5
|
-
coderay (~> 1.1.0)
|
6
|
-
method_source (~> 0.8.1)
|
7
|
-
|
8
1
|
PATH
|
9
2
|
remote: .
|
10
3
|
specs:
|
11
|
-
pry-moves (0.1.
|
4
|
+
pry-moves (0.1.6)
|
12
5
|
binding_of_caller (~> 0.7)
|
13
6
|
pry (>= 0.9.10, < 0.11.0)
|
14
7
|
|
@@ -21,6 +14,10 @@ GEM
|
|
21
14
|
debug_inspector (0.0.3)
|
22
15
|
diff-lcs (1.3)
|
23
16
|
method_source (0.8.2)
|
17
|
+
pry (0.10.4)
|
18
|
+
coderay (~> 1.1.0)
|
19
|
+
method_source (~> 0.8.1)
|
20
|
+
slop (~> 3.4)
|
24
21
|
pry-remote (0.1.8)
|
25
22
|
pry (~> 0.9)
|
26
23
|
slop (~> 3.0)
|
@@ -43,7 +40,7 @@ PLATFORMS
|
|
43
40
|
ruby
|
44
41
|
|
45
42
|
DEPENDENCIES
|
46
|
-
pry
|
43
|
+
pry
|
47
44
|
pry-moves!
|
48
45
|
pry-remote (~> 0.1.6)
|
49
46
|
rspec
|
data/README.md
CHANGED
@@ -10,8 +10,10 @@ _An execution control add-on for [Pry][pry]._
|
|
10
10
|
## Commands:
|
11
11
|
|
12
12
|
* `n` - **next** line in current frame, including block lines (moving to next line goes as naturally expected)
|
13
|
+
* `nn` - **next** line in current frame, skipping block lines
|
13
14
|
* `s` - **step** into function execution
|
14
15
|
* `s method_name` - step into method `method_name` (For example from `User.new.method_name`). Partial name match supported.
|
16
|
+
* `s +` - step into function, including hidden frames
|
15
17
|
* `f` - **finish** execution of current frame (block or method) and stop at next line on higher level
|
16
18
|
* `c` - **continue**
|
17
19
|
* `bt` - show latest 5 lines from backtrace
|
data/lib/pry-moves.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
require 'pry' unless defined? Pry
|
2
|
+
|
1
3
|
require 'pry-moves/version'
|
4
|
+
require 'pry-moves/trace_commands'
|
5
|
+
require 'pry-moves/tracer'
|
2
6
|
require 'pry-moves/pry_ext'
|
3
7
|
require 'pry-moves/commands'
|
4
8
|
require 'pry-moves/pry_wrapper'
|
5
|
-
require 'pry-moves/tracer'
|
6
9
|
require 'pry-moves/backtrace'
|
7
10
|
require 'pry-moves/watch'
|
8
11
|
require 'pry-moves/helpers'
|
data/lib/pry-moves/backtrace.rb
CHANGED
@@ -85,7 +85,7 @@ class PryMoves::Backtrace
|
|
85
85
|
file.gsub!( /^#{Rails.root.to_s}/, '') if defined? Rails
|
86
86
|
|
87
87
|
signature = PryMoves::Helpers.method_signature binding
|
88
|
-
signature =
|
88
|
+
signature = ":#{binding.frame_type}" if !signature or signature.length < 1
|
89
89
|
|
90
90
|
indent = frame_manager.current_frame == binding ?
|
91
91
|
' => ': ' '
|
data/lib/pry-moves/commands.rb
CHANGED
@@ -3,20 +3,25 @@ require 'pry' unless defined? Pry
|
|
3
3
|
module PryMoves
|
4
4
|
Commands = Pry::CommandSet.new do
|
5
5
|
block_command 'step', 'Step execution into the next line or method.' do |param|
|
6
|
-
check_file_context
|
7
6
|
breakout_navigation :step, param
|
8
7
|
end
|
9
8
|
|
10
|
-
block_command 'finish', 'Finish xule tut neponyatnogo.' do |param|
|
11
|
-
check_file_context
|
9
|
+
block_command 'finish', 'Finish - xule tut neponyatnogo.' do |param|
|
12
10
|
breakout_navigation :finish, param
|
13
11
|
end
|
14
12
|
|
15
|
-
block_command 'next', 'Execute the next line
|
16
|
-
check_file_context
|
13
|
+
block_command 'next', 'Execute the next line stepping into blocks' do |param|
|
17
14
|
breakout_navigation :next, param
|
18
15
|
end
|
19
16
|
|
17
|
+
block_command 'nn', 'Execute the next line skipping blocks.' do |param|
|
18
|
+
breakout_navigation :next, 'blockless'
|
19
|
+
end
|
20
|
+
|
21
|
+
block_command 'iterate', 'Stop on next iteration of this method.' do |param|
|
22
|
+
breakout_navigation :iterate, param
|
23
|
+
end
|
24
|
+
|
20
25
|
block_command 'continue', 'Continue program execution and end the Pry session.' do
|
21
26
|
check_file_context
|
22
27
|
run 'exit-all'
|
@@ -36,7 +41,8 @@ module PryMoves
|
|
36
41
|
end
|
37
42
|
|
38
43
|
block_command 'debug', '' do
|
39
|
-
debug
|
44
|
+
cmd = arg_string.gsub(/^debug/, '').strip
|
45
|
+
breakout_navigation :debug, cmd
|
40
46
|
end
|
41
47
|
|
42
48
|
block_command '!', 'exit' do
|
@@ -51,6 +57,7 @@ module PryMoves
|
|
51
57
|
|
52
58
|
helpers do
|
53
59
|
def breakout_navigation(action, param)
|
60
|
+
check_file_context
|
54
61
|
_pry_.binding_stack.clear # Clear the binding stack.
|
55
62
|
throw :breakout_nav, { # Break out of the REPL loop and
|
56
63
|
action: action, # signal the tracer.
|
@@ -60,12 +67,6 @@ module PryMoves
|
|
60
67
|
}
|
61
68
|
end
|
62
69
|
|
63
|
-
def debug
|
64
|
-
check_file_context
|
65
|
-
cmd = arg_string.gsub(/^debug/, '').strip
|
66
|
-
breakout_navigation :debug, cmd
|
67
|
-
end
|
68
|
-
|
69
70
|
# Ensures that a command is executed in a local file context.
|
70
71
|
def check_file_context
|
71
72
|
unless PryMoves.check_file_context(target)
|
data/lib/pry-moves/pry_ext.rb
CHANGED
@@ -59,13 +59,14 @@ class PryWrapper
|
|
59
59
|
|
60
60
|
Thread.current[:pry_moves_debug] = true
|
61
61
|
#@command[:binding].eval 'puts "###########"'
|
62
|
-
start_tracing
|
62
|
+
tracer = start_tracing
|
63
63
|
begin
|
64
64
|
@command[:binding].eval @command[:param]
|
65
65
|
rescue => e
|
66
66
|
Thread.current.set_trace_func nil
|
67
67
|
puts e
|
68
68
|
end
|
69
|
+
tracer.stop_tracing
|
69
70
|
end.join
|
70
71
|
binding_ = @last_runtime_binding || @init_binding
|
71
72
|
Pry.start(binding_, @pry_start_options)
|
@@ -73,8 +74,9 @@ class PryWrapper
|
|
73
74
|
|
74
75
|
def start_tracing
|
75
76
|
@last_runtime_binding = @command[:binding]
|
76
|
-
|
77
|
-
|
77
|
+
tracer = PryMoves::Tracer.new @command, @pry_start_options
|
78
|
+
tracer.trace
|
79
|
+
tracer
|
78
80
|
end
|
79
81
|
|
80
82
|
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module PryMoves::TraceCommands
|
2
|
+
|
3
|
+
private
|
4
|
+
|
5
|
+
def trace_step(event, file, line, binding_)
|
6
|
+
return unless event == 'line'
|
7
|
+
|
8
|
+
if @step_in_everywhere
|
9
|
+
true
|
10
|
+
elsif @step_into_funcs
|
11
|
+
|
12
|
+
if @recursion_level < 0
|
13
|
+
pry_puts "⚠️ Unable to find function with name #{@step_into_funcs.join(',')}"
|
14
|
+
return true
|
15
|
+
end
|
16
|
+
|
17
|
+
method = binding_.eval('__callee__').to_s
|
18
|
+
return false unless method_matches?(method)
|
19
|
+
|
20
|
+
func_reached = (not @caller_digest or
|
21
|
+
# if we want to step-in only into straight descendant
|
22
|
+
@caller_digest == frame_digest(binding_.of_caller(3 + 1)))
|
23
|
+
|
24
|
+
if func_reached
|
25
|
+
@caller_digest = nil
|
26
|
+
not redirect_step_into? binding_
|
27
|
+
end
|
28
|
+
|
29
|
+
elsif redirect_step_into? binding_
|
30
|
+
false
|
31
|
+
else
|
32
|
+
not binding_.local_variable_defined? :hide_from_stack
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def trace_next(event, file, line, binding_)
|
37
|
+
traced_method_exit = (@recursion_level < 0 and %w(line call).include? event)
|
38
|
+
if traced_method_exit
|
39
|
+
# Set new traced method, because we left previous one
|
40
|
+
set_traced_method binding_
|
41
|
+
throw :skip if event == 'call'
|
42
|
+
end
|
43
|
+
|
44
|
+
if @recursion_level == 0 and
|
45
|
+
within_current_method?(file, line)
|
46
|
+
|
47
|
+
if event == 'line'
|
48
|
+
return (
|
49
|
+
not @stay_at_frame or
|
50
|
+
@stay_at_frame == frame_digest(binding_.of_caller(3))
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
if event == 'return' and before_end?(line)
|
55
|
+
@pry_start_options[:exit_from_method] = true
|
56
|
+
true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def trace_finish(event, file, line, binding_)
|
62
|
+
return unless event == 'line'
|
63
|
+
if @recursion_level < 0 or @method_to_finish != @method
|
64
|
+
if redirect_step_into?(binding_)
|
65
|
+
@action = :step
|
66
|
+
return false
|
67
|
+
end
|
68
|
+
return true
|
69
|
+
end
|
70
|
+
|
71
|
+
# for finishing blocks inside current method
|
72
|
+
if @block_to_finish
|
73
|
+
@recursion_level == 0 and
|
74
|
+
within_current_method?(file, line) and
|
75
|
+
@block_to_finish != frame_digest(binding_.of_caller(3))
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def trace_debug(event, file, line, binding_)
|
80
|
+
return unless event == 'line'
|
81
|
+
if @first_line_skipped
|
82
|
+
true
|
83
|
+
else
|
84
|
+
@first_line_skipped = true
|
85
|
+
false
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def trace_iteration(event, file, line, binding_)
|
90
|
+
raise 'not implemented'
|
91
|
+
# implementation:
|
92
|
+
# 1) ставить метки там, где происходит сама итерация?
|
93
|
+
# 2) можно догадываться по имени методов в стеке вверху: each / each_with_index
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
data/lib/pry-moves/tracer.rb
CHANGED
@@ -3,6 +3,8 @@ require 'pry' unless defined? Pry
|
|
3
3
|
module PryMoves
|
4
4
|
class Tracer
|
5
5
|
|
6
|
+
include PryMoves::TraceCommands
|
7
|
+
|
6
8
|
def initialize(command, pry_start_options)
|
7
9
|
@command = command
|
8
10
|
@pry_start_options = pry_start_options
|
@@ -18,10 +20,13 @@ class Tracer
|
|
18
20
|
|
19
21
|
case @action
|
20
22
|
when :step
|
21
|
-
@
|
22
|
-
|
23
|
-
|
24
|
-
@
|
23
|
+
@step_into_funcs = nil
|
24
|
+
func = @command[:param]
|
25
|
+
if func == '+'
|
26
|
+
@step_in_everywhere = true
|
27
|
+
elsif func
|
28
|
+
@step_into_funcs = [func]
|
29
|
+
@step_into_funcs << '=initialize' if func == 'new' or func == '=new'
|
25
30
|
@caller_digest = frame_digest(binding_)
|
26
31
|
end
|
27
32
|
when :finish
|
@@ -29,11 +34,20 @@ class Tracer
|
|
29
34
|
@block_to_finish =
|
30
35
|
(binding_.frame_type == :block) &&
|
31
36
|
frame_digest(binding_)
|
37
|
+
when :next
|
38
|
+
if @command[:param] == 'blockless'
|
39
|
+
@stay_at_frame = frame_digest(binding_)
|
40
|
+
end
|
32
41
|
end
|
33
42
|
|
34
43
|
start_tracing
|
35
44
|
end
|
36
45
|
|
46
|
+
def stop_tracing
|
47
|
+
trace_obj.set_trace_func nil
|
48
|
+
Pry.config.disable_breakpoints = false
|
49
|
+
end
|
50
|
+
|
37
51
|
private
|
38
52
|
|
39
53
|
def start_tracing
|
@@ -42,11 +56,6 @@ class Tracer
|
|
42
56
|
trace_obj.set_trace_func method(:tracing_func).to_proc
|
43
57
|
end
|
44
58
|
|
45
|
-
def stop_tracing
|
46
|
-
Pry.config.disable_breakpoints = false
|
47
|
-
trace_obj.set_trace_func nil
|
48
|
-
end
|
49
|
-
|
50
59
|
# You can't call set_trace_func or Thread.current.set_trace_func recursively
|
51
60
|
# even in different threads 😪
|
52
61
|
# But! 💡
|
@@ -105,61 +114,22 @@ class Tracer
|
|
105
114
|
end
|
106
115
|
end
|
107
116
|
|
108
|
-
def
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
end
|
115
|
-
method = binding_.eval('__callee__').to_s
|
116
|
-
@step_info_funcs.any? {|pattern| method.include? pattern} and
|
117
|
-
@caller_digest == frame_digest(binding_.of_caller(3 + 1))
|
118
|
-
else
|
119
|
-
true
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
def trace_next(event, file, line, binding_)
|
124
|
-
traced_method_exit = (@recursion_level < 0 and %w(line call).include? event)
|
125
|
-
if traced_method_exit
|
126
|
-
# Set new traced method, because we left previous one
|
127
|
-
set_traced_method binding_
|
128
|
-
throw :skip if event == 'call'
|
129
|
-
end
|
130
|
-
|
131
|
-
if @recursion_level == 0 and
|
132
|
-
within_current_method?(file, line)
|
133
|
-
|
134
|
-
return true if event == 'line'
|
135
|
-
|
136
|
-
if event == 'return' and before_end?(line)
|
137
|
-
@pry_start_options[:exit_from_method] = true
|
138
|
-
true
|
117
|
+
def method_matches?(method)
|
118
|
+
@step_into_funcs.any? do |pattern|
|
119
|
+
if pattern.start_with? '='
|
120
|
+
"=#{method}" == pattern
|
121
|
+
else
|
122
|
+
method.include? pattern
|
139
123
|
end
|
140
124
|
end
|
141
125
|
end
|
142
126
|
|
143
|
-
def
|
144
|
-
return unless
|
145
|
-
return true if @recursion_level < 0 or @method_to_finish != @method
|
146
|
-
|
147
|
-
# for finishing blocks inside current method
|
148
|
-
if @block_to_finish
|
149
|
-
@recursion_level == 0 and
|
150
|
-
within_current_method?(file, line) and
|
151
|
-
@block_to_finish != frame_digest(binding_.of_caller(3))
|
152
|
-
end
|
153
|
-
end
|
127
|
+
def redirect_step_into?(binding_)
|
128
|
+
return false unless binding_.local_variable_defined? :debug_redirect
|
154
129
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
true
|
159
|
-
else
|
160
|
-
@first_line_skipped = true
|
161
|
-
false
|
162
|
-
end
|
130
|
+
debug_redirect = binding_.local_variable_get(:debug_redirect)
|
131
|
+
@step_into_funcs = [debug_redirect.to_s] if debug_redirect
|
132
|
+
true
|
163
133
|
end
|
164
134
|
|
165
135
|
def debug_info(file, line, id)
|
data/lib/pry-moves/version.rb
CHANGED
data/playground/Gemfile.lock
CHANGED
data/playground/playground.rb
CHANGED
@@ -72,6 +72,16 @@ class Playground
|
|
72
72
|
:after_block # after block
|
73
73
|
end
|
74
74
|
|
75
|
+
def method_with_redirection
|
76
|
+
debug_redirect = '=level_a' # at method_with_redirection
|
77
|
+
level_a
|
78
|
+
end
|
79
|
+
|
80
|
+
def redirection_host
|
81
|
+
binding.pry # redirection host
|
82
|
+
method_with_redirection
|
83
|
+
end
|
84
|
+
|
75
85
|
private
|
76
86
|
|
77
87
|
def iterator
|
data/playground/sand.rb
CHANGED
@@ -10,37 +10,52 @@ end
|
|
10
10
|
class A
|
11
11
|
|
12
12
|
def initialize
|
13
|
+
hide_from_stack = true
|
13
14
|
puts :xuilo
|
14
15
|
end
|
15
16
|
|
17
|
+
def kozi
|
18
|
+
puts 'aa2 1'
|
19
|
+
puts 'aa2 2'
|
20
|
+
end
|
21
|
+
|
16
22
|
def aa
|
17
|
-
|
23
|
+
debug_redirect = :kozi
|
24
|
+
puts 'aa: step 1'
|
25
|
+
puts 'aa: step 2'
|
26
|
+
kozi
|
18
27
|
end
|
19
28
|
|
20
29
|
def bb
|
21
|
-
#
|
22
|
-
|
23
|
-
|
24
|
-
|
30
|
+
#debug_redirect = :aa
|
31
|
+
puts 'bb: step 1'
|
32
|
+
puts 'bb: step 2'
|
33
|
+
aa
|
25
34
|
end
|
26
35
|
|
27
36
|
def cc
|
37
|
+
#debug_redirect = :bb
|
38
|
+
hide_from_stack = true
|
28
39
|
koko = :love
|
29
|
-
|
30
|
-
|
40
|
+
bb
|
41
|
+
(2..4).each do |i|
|
42
|
+
puts i
|
43
|
+
end
|
31
44
|
puts :two
|
32
45
|
end
|
33
46
|
alias cc_al cc
|
34
47
|
|
35
48
|
end
|
36
49
|
|
50
|
+
require './playground.rb'
|
51
|
+
Playground.new.basic_next
|
52
|
+
|
37
53
|
puts :prepare
|
38
54
|
|
39
|
-
|
55
|
+
binding.pry
|
40
56
|
A.new.cc_al
|
41
57
|
A.new.cc_al
|
42
58
|
|
43
|
-
a = A.new.aa.bb.cc
|
44
59
|
|
45
60
|
bb = 1
|
46
61
|
|
data/playground/test.rb
ADDED
data/playground/threads.rb
CHANGED
@@ -2,28 +2,25 @@ require 'pry-moves'
|
|
2
2
|
|
3
3
|
Thread.current[:name] = 'main'
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
a = Thread.new do
|
6
|
+
Thread.current[:name] = 'a'
|
7
|
+
sleep 0.2
|
8
|
+
puts 'a'
|
7
9
|
binding.pry
|
10
|
+
puts 'aaaa'
|
11
|
+
sleep 1
|
8
12
|
puts 'aaa'
|
9
13
|
end
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
# что можно сделать - записать в текущий тред ссылку на биндинг
|
16
|
-
# предыдущего треда. А если цепочка тредов - то как? Можно прямо там собирать каллеров предыдущего треда... ??
|
17
|
-
Thread.current[:pre_callers] = pre_callers
|
18
|
-
|
19
|
-
Thread.current[:name] = 'a'
|
20
|
-
inside_thread
|
15
|
+
b = Thread.new do
|
16
|
+
Thread.current[:name] = 'b'
|
17
|
+
20223000.times do
|
18
|
+
432 * 3232
|
21
19
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
def bbb
|
26
|
-
aaa
|
20
|
+
puts '2'
|
21
|
+
binding.pry
|
22
|
+
puts '22'
|
27
23
|
end
|
28
24
|
|
29
|
-
|
25
|
+
a.join
|
26
|
+
b.join
|
data/spec/backtrace_spec.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
require_relative 'spec_helper'
|
2
2
|
|
3
|
-
describe '
|
3
|
+
describe 'backtrace' do
|
4
4
|
|
5
5
|
it 'should backtrace' do
|
6
6
|
breakpoints [
|
7
7
|
[nil, 'stop in level_c'],
|
8
|
-
['bt', lambda{|b,
|
9
|
-
lines =
|
10
|
-
expect(lines[0]).to end_with '
|
11
|
-
expect(lines[1]).to end_with '
|
8
|
+
['bt', lambda{|b, output|
|
9
|
+
lines = output.split("\n").reverse
|
10
|
+
expect(lines[0]).to end_with 'level_c(param=?)'
|
11
|
+
expect(lines[1]).to end_with 'level_a()'
|
12
12
|
expect(lines[2]).to include 'Playground:'
|
13
13
|
expect(lines[3]).to end_with ':block'
|
14
14
|
expect(lines[4]).to include 'RSpec::ExampleGroups'
|
15
15
|
expect(lines.count).to be 5
|
16
16
|
}],
|
17
|
-
['bt all', lambda{|b,
|
18
|
-
lines =
|
17
|
+
['bt all', lambda{|b, output|
|
18
|
+
lines = output.split("\n").reverse
|
19
19
|
# show hidden frame
|
20
|
-
expect(lines[1]).to end_with '
|
20
|
+
expect(lines[1]).to end_with 'level_b()'
|
21
21
|
expect(lines.count).to be 6
|
22
22
|
}],
|
23
|
-
['bt 2', lambda{|b,
|
24
|
-
lines =
|
25
|
-
expect(lines[0]).to end_with '
|
26
|
-
expect(lines[1]).to end_with '
|
23
|
+
['bt 2', lambda{|b, output|
|
24
|
+
lines = output.split("\n").reverse
|
25
|
+
expect(lines[0]).to end_with 'level_c(param=?)'
|
26
|
+
expect(lines[1]).to end_with 'level_a()'
|
27
27
|
expect(lines[3]).to start_with 'Latest 2 lines'
|
28
28
|
expect(lines.count).to be 4
|
29
29
|
}],
|
data/spec/blocks_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require_relative 'spec_helper'
|
2
2
|
|
3
|
-
describe '
|
4
|
-
|
3
|
+
describe 'blocks' do
|
5
4
|
|
6
5
|
it 'should go next over blocks' do
|
7
6
|
breakpoints [
|
@@ -14,15 +13,15 @@ describe 'PryMoves Commands' do
|
|
14
13
|
['s', 'stop in zaloop'],
|
15
14
|
['n', nil],
|
16
15
|
['', 'inside block'],
|
17
|
-
['pass', {
|
16
|
+
['pass', {output: '=> 0'}],
|
18
17
|
|
19
18
|
['f', 'after block'],
|
20
|
-
['pass', {
|
19
|
+
['pass', {output: '=> 0'}],
|
21
20
|
|
22
21
|
['f', 'post_yield'], # Тут хорошо бы, чтобы сразу шёл на "after block",
|
23
22
|
# но пока и не понятно, как это угадать
|
24
23
|
['f', 'after block'],
|
25
|
-
['pass', {
|
24
|
+
['pass', {output: '=> :root'}],
|
26
25
|
]
|
27
26
|
Playground.new.zaloop
|
28
27
|
end
|
@@ -43,7 +42,7 @@ describe 'PryMoves Commands' do
|
|
43
42
|
['n', ''],
|
44
43
|
['', 'inside block'],
|
45
44
|
['f', 'after block'],
|
46
|
-
['pass', {
|
45
|
+
['pass', {output: '=> :root'}],
|
47
46
|
]
|
48
47
|
Playground.new.zaloop
|
49
48
|
end
|
data/spec/commands_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative 'spec_helper'
|
2
2
|
|
3
|
-
describe 'PryMoves
|
3
|
+
describe 'PryMoves commands' do
|
4
4
|
|
5
5
|
it 'should make one step next' do
|
6
6
|
breakpoints [
|
@@ -25,10 +25,10 @@ describe 'PryMoves Commands' do
|
|
25
25
|
['s', 'some internal line'],
|
26
26
|
['up', 'point to step inside'],
|
27
27
|
['up', nil ],
|
28
|
-
['up', {
|
28
|
+
['up', {output_includes: 'top of stack'} ],
|
29
29
|
['down', nil ],
|
30
30
|
['down', 'some internal line'],
|
31
|
-
['down', {
|
31
|
+
['down', {output_includes: 'bottom of stack'} ],
|
32
32
|
]
|
33
33
|
Playground.new.step_into
|
34
34
|
end
|
@@ -37,7 +37,7 @@ describe 'PryMoves Commands' do
|
|
37
37
|
breakpoints [
|
38
38
|
[nil, 'stop in step_by_name'],
|
39
39
|
['s level_c', 'stop in level_c'],
|
40
|
-
['param', {
|
40
|
+
['param', {output: '=> :target'}],
|
41
41
|
['n', nil],
|
42
42
|
]
|
43
43
|
Playground.new.step_by_name
|
@@ -56,7 +56,7 @@ describe 'PryMoves Commands' do
|
|
56
56
|
[nil, nil],
|
57
57
|
['n', 'next step'],
|
58
58
|
['n', 'should stop here after 2 next-s'],
|
59
|
-
['depth', {
|
59
|
+
['depth', {output: '=> 0'}],
|
60
60
|
]
|
61
61
|
Playground.new.recursion
|
62
62
|
end
|
@@ -65,7 +65,7 @@ describe 'PryMoves Commands' do
|
|
65
65
|
breakpoints [
|
66
66
|
[nil, 'basic next stop'],
|
67
67
|
['debug level_a', 'inside of level_a'],
|
68
|
-
['n', 'basic next stop']
|
68
|
+
['n', 'basic next stop']
|
69
69
|
]
|
70
70
|
Playground.new.basic_next
|
71
71
|
end
|
data/spec/pry_debugger.rb
CHANGED
@@ -20,10 +20,10 @@ module PryDebugger
|
|
20
20
|
if subj.is_a? Proc
|
21
21
|
subj.call binding_, output
|
22
22
|
elsif subj.is_a? Hash
|
23
|
-
if subj[:
|
24
|
-
expect(output).to include subj[:
|
23
|
+
if subj[:output_includes]
|
24
|
+
expect(output).to include subj[:output_includes]
|
25
25
|
else
|
26
|
-
expect(output).to eq subj[:
|
26
|
+
expect(output).to eq subj[:output]
|
27
27
|
end
|
28
28
|
elsif not subj.nil?
|
29
29
|
expect(label).to eq subj
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe 'redirection' do
|
4
|
+
|
5
|
+
it 'redirects with debug_redirect' do
|
6
|
+
breakpoints [
|
7
|
+
[nil, 'redirection host'],
|
8
|
+
['n', nil],
|
9
|
+
['s', 'inside of level_a'],
|
10
|
+
['c', 'stop in level_c']
|
11
|
+
]
|
12
|
+
Playground.new.redirection_host
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'redirects within named step in' do
|
16
|
+
breakpoints [
|
17
|
+
[nil, 'redirection host'],
|
18
|
+
['s with_redirection', 'inside of level_a'],
|
19
|
+
['c', 'stop in level_c']
|
20
|
+
]
|
21
|
+
Playground.new.redirection_host
|
22
|
+
end
|
23
|
+
|
24
|
+
it "doesn't redirect for step in everywhere" do
|
25
|
+
breakpoints [
|
26
|
+
[nil, 'redirection host'],
|
27
|
+
['n', nil],
|
28
|
+
['s +', 'at method_with_redirection'],
|
29
|
+
['c', 'stop in level_c']
|
30
|
+
]
|
31
|
+
Playground.new.redirection_host
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -14,7 +14,7 @@ RSpec.configure do |config|
|
|
14
14
|
|
15
15
|
config.after(:example) do |example|
|
16
16
|
unless example.exception
|
17
|
-
expect(PryDebugger.breakpoints.count).to be(0), "not all breakpoints launched"
|
17
|
+
expect(PryDebugger.breakpoints.count).to be(0), "not all breakpoints launched: #{PryDebugger.breakpoints.count}"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-moves
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- garmoshka-mo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- lib/pry-moves/pry_ext.rb
|
82
82
|
- lib/pry-moves/pry_remote_ext.rb
|
83
83
|
- lib/pry-moves/pry_wrapper.rb
|
84
|
+
- lib/pry-moves/trace_commands.rb
|
84
85
|
- lib/pry-moves/tracer.rb
|
85
86
|
- lib/pry-moves/version.rb
|
86
87
|
- lib/pry-moves/watch.rb
|
@@ -95,6 +96,7 @@ files:
|
|
95
96
|
- playground/playground.rb
|
96
97
|
- playground/recursions.rb
|
97
98
|
- playground/sand.rb
|
99
|
+
- playground/test.rb
|
98
100
|
- playground/threads.rb
|
99
101
|
- playground/tracer.rb
|
100
102
|
- pry-moves.gemspec
|
@@ -102,6 +104,7 @@ files:
|
|
102
104
|
- spec/blocks_spec.rb
|
103
105
|
- spec/commands_spec.rb
|
104
106
|
- spec/pry_debugger.rb
|
107
|
+
- spec/redirection_spec.rb
|
105
108
|
- spec/spec_helper.rb
|
106
109
|
homepage: https://github.com/garmoshka-mo/pry-moves
|
107
110
|
licenses:
|
@@ -132,4 +135,5 @@ test_files:
|
|
132
135
|
- spec/blocks_spec.rb
|
133
136
|
- spec/commands_spec.rb
|
134
137
|
- spec/pry_debugger.rb
|
138
|
+
- spec/redirection_spec.rb
|
135
139
|
- spec/spec_helper.rb
|