Skip to content

Commit

Permalink
Fix continue! to ignore also byebug calls
Browse files Browse the repository at this point in the history
Not only breakpoints.
  • Loading branch information
deivid-rodriguez committed Mar 11, 2019
1 parent af25ece commit 374d30f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Fixed

* [#546](https://github.com/deivid-rodriguez/byebug/pull/546): `continue!` to ignore further `byebug` calls.

## [11.0.0] - 2019-02-15

### Added
Expand Down
2 changes: 1 addition & 1 deletion lib/byebug/attacher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def self.spawn(host = "localhost", port = nil)
#
module Kernel
def byebug
Byebug.attach
Byebug.attach unless Byebug.mode == :off
end

def remote_byebug(host = "localhost", port = nil)
Expand Down
1 change: 1 addition & 0 deletions lib/byebug/commands/continue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def execute

processor.proceed!

Byebug.mode = :off if unconditionally?
Byebug.stop if unconditionally? || Byebug.stoppable?
end

Expand Down
1 change: 1 addition & 0 deletions lib/byebug/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module Byebug
#
# * :attached => Attached to a running program through the `byebug` method.
# * :standalone => Started through `byebug` script.
# * :off => Ignoring any `byebug` method calls.
#
attr_accessor :mode

Expand Down
46 changes: 42 additions & 4 deletions test/commands/continue_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,19 @@ def test_continues_until_the_end_if_no_line_specified_and_no_breakpoints
end

def test_continues_until_the_end_if_used_with_bang
enter "break 14", "continue!"
with_mode(:attached) do
enter "break 14", "continue!"

debug_code(program) { assert_program_finished }
debug_code(program) { assert_program_finished }
end
end

def test_continues_until_the_end_if_used_with_unconditionally
enter "break 14", "continue unconditionally"
with_mode(:attached) do
enter "break 14", "continue unconditionally"

debug_code(program) { assert_program_finished }
debug_code(program) { assert_program_finished }
end
end

def test_stops_byebug_after_continue
Expand Down Expand Up @@ -102,4 +106,38 @@ def test_linetrace_does_not_show_a_line_in_eval_context
end
end
end

class ContinueUnconditionallyWithByebugCallsTest < TestCase
def program
strip_line_numbers <<-RUBY
1: module Byebug
2: byebug
3:
4: b = 5
5:
6: byebug
7:
8: c = b + 5
9:
10: d = c + 5
11: end
RUBY
end

def test_continues_until_the_end_ignoring_byebug_calls_if_used_with_bang
with_mode(:attached) do
enter "continue!"

debug_code(program) { assert_program_finished }
end
end

def test_continues_until_the_end_ignoring_byebug_calls_if_used_with_unconditionally
with_mode(:attached) do
enter "continue unconditionally"

debug_code(program) { assert_program_finished }
end
end
end
end

0 comments on commit 374d30f

Please sign in to comment.