byebug 3.5.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/.rubocop.yml +18 -1
- data/.travis.yml +21 -1
- data/CHANGELOG.md +356 -308
- data/CONTRIBUTING.md +31 -15
- data/GUIDE.md +859 -475
- data/Gemfile +8 -10
- data/LICENSE +1 -1
- data/README.md +41 -45
- data/Rakefile +30 -28
- data/byebug.gemspec +18 -18
- data/ext/byebug/breakpoint.c +88 -75
- data/ext/byebug/byebug.c +253 -252
- data/ext/byebug/byebug.h +53 -53
- data/ext/byebug/context.c +188 -159
- data/ext/byebug/extconf.rb +9 -6
- data/ext/byebug/locker.c +53 -11
- data/ext/byebug/threads.c +137 -39
- data/lib/byebug/attacher.rb +7 -2
- data/lib/byebug/breakpoint.rb +30 -0
- data/lib/byebug/command.rb +36 -32
- data/lib/byebug/commands/break.rb +49 -48
- data/lib/byebug/commands/catch.rb +64 -0
- data/lib/byebug/commands/condition.rb +13 -9
- data/lib/byebug/commands/continue.rb +8 -4
- data/lib/byebug/commands/delete.rb +10 -4
- data/lib/byebug/commands/display.rb +33 -25
- data/lib/byebug/commands/edit.rb +18 -13
- data/lib/byebug/commands/enable_disable.rb +26 -24
- data/lib/byebug/commands/eval.rb +77 -35
- data/lib/byebug/commands/finish.rb +9 -5
- data/lib/byebug/commands/frame.rb +66 -125
- data/lib/byebug/commands/help.rb +14 -21
- data/lib/byebug/commands/history.rb +5 -1
- data/lib/byebug/commands/info.rb +41 -106
- data/lib/byebug/commands/interrupt.rb +6 -2
- data/lib/byebug/commands/irb.rb +5 -2
- data/lib/byebug/commands/kill.rb +6 -2
- data/lib/byebug/commands/list.rb +21 -14
- data/lib/byebug/commands/method.rb +17 -9
- data/lib/byebug/commands/pry.rb +13 -3
- data/lib/byebug/commands/quit.rb +10 -5
- data/lib/byebug/commands/restart.rb +12 -19
- data/lib/byebug/commands/save.rb +10 -6
- data/lib/byebug/commands/set.rb +15 -14
- data/lib/byebug/commands/show.rb +8 -8
- data/lib/byebug/commands/source.rb +14 -8
- data/lib/byebug/commands/stepping.rb +15 -29
- data/lib/byebug/commands/threads.rb +73 -49
- data/lib/byebug/commands/tracevar.rb +56 -0
- data/lib/byebug/commands/undisplay.rb +8 -4
- data/lib/byebug/commands/untracevar.rb +38 -0
- data/lib/byebug/commands/var.rb +107 -0
- data/lib/byebug/context.rb +78 -42
- data/lib/byebug/core.rb +78 -40
- data/lib/byebug/helper.rb +58 -42
- data/lib/byebug/history.rb +12 -1
- data/lib/byebug/interface.rb +91 -11
- data/lib/byebug/interfaces/local_interface.rb +12 -19
- data/lib/byebug/interfaces/remote_interface.rb +12 -15
- data/lib/byebug/interfaces/script_interface.rb +14 -18
- data/lib/byebug/interfaces/test_interface.rb +54 -0
- data/lib/byebug/printers/base.rb +64 -0
- data/lib/byebug/printers/plain.rb +53 -0
- data/lib/byebug/processor.rb +20 -1
- data/lib/byebug/processors/command_processor.rb +57 -172
- data/lib/byebug/processors/control_command_processor.rb +16 -43
- data/lib/byebug/remote.rb +13 -7
- data/lib/byebug/runner.rb +102 -54
- data/lib/byebug/setting.rb +45 -68
- data/lib/byebug/settings/autoeval.rb +2 -0
- data/lib/byebug/settings/autoirb.rb +3 -0
- data/lib/byebug/settings/autolist.rb +3 -0
- data/lib/byebug/settings/autosave.rb +2 -0
- data/lib/byebug/settings/basename.rb +2 -0
- data/lib/byebug/settings/callstyle.rb +2 -0
- data/lib/byebug/settings/fullpath.rb +2 -0
- data/lib/byebug/settings/histfile.rb +2 -0
- data/lib/byebug/settings/histsize.rb +2 -0
- data/lib/byebug/settings/linetrace.rb +2 -0
- data/lib/byebug/settings/listsize.rb +2 -0
- data/lib/byebug/settings/post_mortem.rb +7 -2
- data/lib/byebug/settings/stack_on_error.rb +2 -0
- data/lib/byebug/settings/verbose.rb +2 -0
- data/lib/byebug/settings/width.rb +2 -0
- data/lib/byebug/state.rb +12 -0
- data/lib/byebug/states/control_state.rb +26 -0
- data/lib/byebug/states/regular_state.rb +178 -0
- data/lib/byebug/version.rb +1 -1
- metadata +24 -109
- data/lib/byebug/commands/catchpoint.rb +0 -53
- data/lib/byebug/commands/reload.rb +0 -29
- data/lib/byebug/commands/trace.rb +0 -50
- data/lib/byebug/commands/variables.rb +0 -206
- data/lib/byebug/options.rb +0 -46
- data/lib/byebug/settings/autoreload.rb +0 -12
- data/lib/byebug/settings/forcestep.rb +0 -14
- data/lib/byebug/settings/testing.rb +0 -12
- data/lib/byebug/settings/tracing_plus.rb +0 -11
- data/test/commands/break_test.rb +0 -364
- data/test/commands/condition_test.rb +0 -85
- data/test/commands/continue_test.rb +0 -47
- data/test/commands/delete_test.rb +0 -26
- data/test/commands/display_test.rb +0 -37
- data/test/commands/edit_test.rb +0 -52
- data/test/commands/eval_test.rb +0 -89
- data/test/commands/finish_test.rb +0 -74
- data/test/commands/frame_test.rb +0 -223
- data/test/commands/help_test.rb +0 -66
- data/test/commands/history_test.rb +0 -61
- data/test/commands/info_test.rb +0 -238
- data/test/commands/interrupt_test.rb +0 -45
- data/test/commands/irb_test.rb +0 -28
- data/test/commands/kill_test.rb +0 -50
- data/test/commands/list_test.rb +0 -174
- data/test/commands/method_test.rb +0 -52
- data/test/commands/post_mortem_test.rb +0 -71
- data/test/commands/pry_test.rb +0 -26
- data/test/commands/quit_test.rb +0 -53
- data/test/commands/reload_test.rb +0 -39
- data/test/commands/restart_test.rb +0 -46
- data/test/commands/save_test.rb +0 -67
- data/test/commands/set_test.rb +0 -140
- data/test/commands/show_test.rb +0 -76
- data/test/commands/source_test.rb +0 -46
- data/test/commands/stepping_test.rb +0 -192
- data/test/commands/thread_test.rb +0 -164
- data/test/commands/trace_test.rb +0 -71
- data/test/commands/undisplay_test.rb +0 -75
- data/test/commands/variables_test.rb +0 -105
- data/test/debugger_alias_test.rb +0 -7
- data/test/runner_test.rb +0 -150
- data/test/support/matchers.rb +0 -65
- data/test/support/test_interface.rb +0 -59
- data/test/support/utils.rb +0 -122
- data/test/test_helper.rb +0 -58
data/test/support/matchers.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
module Minitest
|
2
|
-
#
|
3
|
-
# Custom Minitest assertions
|
4
|
-
#
|
5
|
-
module Assertions
|
6
|
-
# This matcher checks that given collection is included into the original
|
7
|
-
# collection and in correct order. It accepts both strings and regexps.
|
8
|
-
#
|
9
|
-
# Examples:
|
10
|
-
# assert_includes_in_order(%w{1 2 3 4 5}, %w{1 3 5}) # => pass
|
11
|
-
# assert_includes_in_order(%w{1 2 3 4 5}, %w{1 5 3}) # => fail
|
12
|
-
# assert_includes_in_order(w{1 2 3 4 5}, ["1", /\d+/, "5"]) # => pass
|
13
|
-
# assert_includes_in_order(w{1 2 3 4 5}, ["1", /\[a-z]+/, "5"]) # => fail
|
14
|
-
#
|
15
|
-
def assert_includes_in_order(given, original, msg = nil)
|
16
|
-
msg = message(msg) do
|
17
|
-
"Expected #{mu_pp(original)} to include #{mu_pp(given)} in order"
|
18
|
-
end
|
19
|
-
assert _includes_in_order(original, given), msg
|
20
|
-
end
|
21
|
-
|
22
|
-
def refute_includes_in_order(given, original, msg = nil)
|
23
|
-
msg = message(msg) do
|
24
|
-
"Expected #{mu_pp(original)} to not include #{mu_pp(given)} in order"
|
25
|
-
end
|
26
|
-
refute _includes_in_order(original, given), msg
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def _includes_in_order(original_collection, given_collection)
|
32
|
-
result = true
|
33
|
-
given_collection.each do |given_item|
|
34
|
-
result &&=
|
35
|
-
case given_item
|
36
|
-
when String
|
37
|
-
index = original_collection.index(given_item)
|
38
|
-
if index
|
39
|
-
original_collection = original_collection[(index + 1)..-1]
|
40
|
-
true
|
41
|
-
else
|
42
|
-
false
|
43
|
-
end
|
44
|
-
when Regexp
|
45
|
-
index = nil
|
46
|
-
original_collection.each_with_index do |original_item, i|
|
47
|
-
if original_item =~ given_item
|
48
|
-
index = i
|
49
|
-
break
|
50
|
-
end
|
51
|
-
end
|
52
|
-
if index
|
53
|
-
original_collection = original_collection[(index + 1)..-1]
|
54
|
-
true
|
55
|
-
else
|
56
|
-
false
|
57
|
-
end
|
58
|
-
else
|
59
|
-
false
|
60
|
-
end
|
61
|
-
end
|
62
|
-
result
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
module Byebug
|
2
|
-
#
|
3
|
-
# Custom interface for easier assertions
|
4
|
-
#
|
5
|
-
class TestInterface < Interface
|
6
|
-
attr_reader :input_queue, :output_queue, :error_queue, :confirm_queue
|
7
|
-
|
8
|
-
attr_accessor :test_block
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
super()
|
12
|
-
@input_queue, @output_queue = [], []
|
13
|
-
@error_queue, @confirm_queue = [], []
|
14
|
-
end
|
15
|
-
|
16
|
-
def errmsg(*args)
|
17
|
-
@error_queue.push(*args)
|
18
|
-
end
|
19
|
-
|
20
|
-
def read_command(*)
|
21
|
-
return readline(true) unless @input_queue.empty?
|
22
|
-
|
23
|
-
return unless test_block
|
24
|
-
|
25
|
-
test_block.call
|
26
|
-
self.test_block = nil
|
27
|
-
end
|
28
|
-
|
29
|
-
def puts(*args)
|
30
|
-
@output_queue.push(*args)
|
31
|
-
end
|
32
|
-
|
33
|
-
def confirm(message)
|
34
|
-
@confirm_queue << message
|
35
|
-
readline(false)
|
36
|
-
end
|
37
|
-
|
38
|
-
def close
|
39
|
-
end
|
40
|
-
|
41
|
-
def inspect
|
42
|
-
[
|
43
|
-
"input_queue: #{input_queue.inspect}",
|
44
|
-
"output_queue: #{output_queue.inspect}",
|
45
|
-
"error_queue: #{error_queue.inspect}",
|
46
|
-
"confirm_queue: #{confirm_queue.inspect}"
|
47
|
-
].join("\n")
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def readline(hist)
|
53
|
-
cmd = @input_queue.shift
|
54
|
-
cmd = cmd.is_a?(Proc) ? cmd.call : cmd
|
55
|
-
save_history(cmd) if hist
|
56
|
-
cmd
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
data/test/support/utils.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
require_relative 'matchers'
|
2
|
-
require_relative 'test_interface'
|
3
|
-
|
4
|
-
module Byebug
|
5
|
-
#
|
6
|
-
# Misc tools for the test suite
|
7
|
-
#
|
8
|
-
module TestUtils
|
9
|
-
#
|
10
|
-
# Adds commands to the input queue, so they will be later retrieved by
|
11
|
-
# Processor, i.e., it emulates user's input.
|
12
|
-
#
|
13
|
-
# If a command is a Proc object, it will be executed before being retrieved
|
14
|
-
# by Processor. May be handy when you need build a command depending on the
|
15
|
-
# current context/state.
|
16
|
-
#
|
17
|
-
# Usage:
|
18
|
-
# enter 'b 12'
|
19
|
-
# enter 'b 12', 'cont'
|
20
|
-
# enter ['b 12', 'cont']
|
21
|
-
# enter 'b 12', ->{"disable #{breakpoint.id}"}, 'cont'
|
22
|
-
#
|
23
|
-
def enter(*messages)
|
24
|
-
messages = messages.first.is_a?(Array) ? messages.first : messages
|
25
|
-
interface.input_queue.concat(messages)
|
26
|
-
end
|
27
|
-
|
28
|
-
#
|
29
|
-
# Runs the provided Proc
|
30
|
-
#
|
31
|
-
# You also can specify a block, which will be executed when Processor
|
32
|
-
# extracts all the commands from the input queue. You can use that for
|
33
|
-
# making assertions on the current test. If you specified the block and it
|
34
|
-
# was never executed, the test will fail.
|
35
|
-
#
|
36
|
-
# Usage:
|
37
|
-
# debug_proc -> { byebug; puts 'Hello' }
|
38
|
-
#
|
39
|
-
# enter 'b 4', 'cont'
|
40
|
-
# code = -> do
|
41
|
-
# byebug
|
42
|
-
# puts 'hello'
|
43
|
-
# end
|
44
|
-
# debug_proc(code) { assert_equal 4, state.line }
|
45
|
-
#
|
46
|
-
def debug_proc(program, &block)
|
47
|
-
Byebug.stubs(:run_init_script)
|
48
|
-
interface.test_block = block
|
49
|
-
begin
|
50
|
-
program.call
|
51
|
-
ensure
|
52
|
-
interface.test_block.call if interface.test_block
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
#
|
57
|
-
# Checks the output of byebug.
|
58
|
-
#
|
59
|
-
# By default it checks output queue of the current interface, but you can
|
60
|
-
# check again any queue by providing it as a second argument.
|
61
|
-
#
|
62
|
-
# Usage:
|
63
|
-
# enter 'break 4', 'cont'
|
64
|
-
# debug 'ex1'
|
65
|
-
# check_output "Breakpoint 1 at #{fullpath('ex1')}:4"
|
66
|
-
#
|
67
|
-
def check_output(check_method, queue, *args)
|
68
|
-
queue_messages = queue.map(&:strip)
|
69
|
-
messages = Array(args).map { |msg| msg.is_a?(String) ? msg.strip : msg }
|
70
|
-
send(check_method, messages, queue_messages)
|
71
|
-
end
|
72
|
-
|
73
|
-
%w(output error confirm).each do |queue_name|
|
74
|
-
define_method(:"check_#{queue_name}_includes") do |*args|
|
75
|
-
queue = interface.send(:"#{queue_name}_queue")
|
76
|
-
send(:check_output, :assert_includes_in_order, queue, *args)
|
77
|
-
end
|
78
|
-
|
79
|
-
define_method(:"check_#{queue_name}_doesnt_include") do |*args|
|
80
|
-
queue = interface.send(:"#{queue_name}_queue")
|
81
|
-
send(:check_output, :refute_includes_in_order, queue, *args)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
#
|
86
|
-
# Set default settings for testing
|
87
|
-
#
|
88
|
-
def set_defaults
|
89
|
-
Byebug::Setting.load
|
90
|
-
|
91
|
-
Byebug::Setting[:autolist] = false
|
92
|
-
Byebug::Setting[:autosave] = false
|
93
|
-
Byebug::Setting[:testing] = true
|
94
|
-
Byebug::Setting[:width] = 80
|
95
|
-
end
|
96
|
-
|
97
|
-
def interface
|
98
|
-
Byebug.handler.interface
|
99
|
-
end
|
100
|
-
|
101
|
-
def state
|
102
|
-
Thread.current.thread_variable_get('state')
|
103
|
-
end
|
104
|
-
|
105
|
-
def context
|
106
|
-
state.context
|
107
|
-
end
|
108
|
-
|
109
|
-
def force_set_const(klass, const, value)
|
110
|
-
klass.send(:remove_const, const) if klass.const_defined?(const)
|
111
|
-
klass.const_set(const, value)
|
112
|
-
end
|
113
|
-
|
114
|
-
def change_line_in_file(file, line, new_line_content)
|
115
|
-
old_content = File.read(file)
|
116
|
-
new_content = old_content.split("\n")
|
117
|
-
.tap { |c| c[line - 1] = new_line_content }
|
118
|
-
.join("\n") + "\n"
|
119
|
-
File.open(file, 'w') { |f| f.write(new_content) }
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
if ENV['CI']
|
2
|
-
require 'codeclimate-test-reporter'
|
3
|
-
CodeClimate::TestReporter.start
|
4
|
-
else
|
5
|
-
require 'simplecov'
|
6
|
-
SimpleCov.start
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'minitest'
|
10
|
-
require 'pathname'
|
11
|
-
require 'mocha/mini_test'
|
12
|
-
require 'byebug'
|
13
|
-
|
14
|
-
require_relative 'support/utils'
|
15
|
-
|
16
|
-
module Byebug
|
17
|
-
#
|
18
|
-
# Extends Minitest's base test case and provides defaults for all tests
|
19
|
-
#
|
20
|
-
class TestCase < Minitest::Test
|
21
|
-
#
|
22
|
-
# Reset to default state before each test
|
23
|
-
#
|
24
|
-
def setup
|
25
|
-
Byebug.handler = Byebug::CommandProcessor.new(Byebug::TestInterface.new)
|
26
|
-
Byebug.breakpoints.clear if Byebug.breakpoints
|
27
|
-
Byebug.catchpoints.clear if Byebug.catchpoints
|
28
|
-
|
29
|
-
set_defaults
|
30
|
-
|
31
|
-
# Include test files as ignored files
|
32
|
-
glob_exp = File.expand_path('../../{lib,test/support}/**/*.rb', __FILE__)
|
33
|
-
ignored_files = Dir.glob(glob_exp) + ['test/test_helper.rb']
|
34
|
-
force_set_const(Byebug, 'IGNORED_FILES', ignored_files)
|
35
|
-
end
|
36
|
-
|
37
|
-
include Byebug::TestUtils
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# Load the test files from the command line.
|
42
|
-
argv = ARGV.select do |argument|
|
43
|
-
case argument
|
44
|
-
when /^-/ then
|
45
|
-
argument
|
46
|
-
when /\*/ then
|
47
|
-
Dir.glob('test/**/*_test.rb').each do |file|
|
48
|
-
require File.expand_path file
|
49
|
-
end
|
50
|
-
false
|
51
|
-
else
|
52
|
-
require File.expand_path argument
|
53
|
-
false
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# Run the tests
|
58
|
-
Minitest.run argv
|