Skip to content

Commit

Permalink
Merge pull request #321 from akaneko3/fix_restart
Browse files Browse the repository at this point in the history
Fix restart
  • Loading branch information
David Rodríguez authored Jan 26, 2017
2 parents 0012194 + 205641d commit 7eab3fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
### Fixed

* `where` command failing on instance_exec block stack frames
* `restart` command crashing in certain cases because of a missing `require 'English'` (#321, @akaneko3).
* `restart` command crashing when debugged script is not executable or has no shebang (#321, @akaneko3).

## 9.0.6 - 2016-09-29

Expand Down
3 changes: 3 additions & 0 deletions lib/byebug/commands/restart.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'byebug/command'
require 'byebug/helpers/path'
require 'shellwords'
require 'English'
require 'rbconfig'

module Byebug
#
Expand Down Expand Up @@ -35,6 +37,7 @@ def execute
argv = [$PROGRAM_NAME]

argv.unshift(bin_file) if Byebug.mode == :standalone
argv.unshift(RbConfig.ruby)

argv += (@match[:args] ? @match[:args].shellsplit : $ARGV.compact)

Expand Down
15 changes: 11 additions & 4 deletions test/commands/restart_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'test_helper'
require 'rbconfig'

module Byebug
#
Expand All @@ -8,31 +9,37 @@ class RestartTest < TestCase
def test_restart_without_arguments_in_standalone_mode
with_mode(:standalone) do
with_command_line(example_path, '1') do
assert_restarts(nil, "#{Context.bin_file} #{example_path} 1")
assert_restarts(
nil,
"#{RbConfig.ruby} #{Context.bin_file} #{example_path} 1"
)
end
end
end

def test_restart_with_arguments_in_standalone_mode
with_mode(:standalone) do
with_command_line(example_path, '1') do
assert_restarts('2', "#{Context.bin_file} #{example_path} 2")
assert_restarts(
'2',
"#{RbConfig.ruby} #{Context.bin_file} #{example_path} 2"
)
end
end
end

def test_restart_without_arguments_in_attached_mode
with_mode(:attached) do
with_command_line(example_path, '1') do
assert_restarts(nil, "#{example_path} 1")
assert_restarts(nil, "#{RbConfig.ruby} #{example_path} 1")
end
end
end

def test_restart_with_arguments_in_attached_mode
with_mode(:attached) do
with_command_line(example_path, '1') do
assert_restarts(2, "#{example_path} 2")
assert_restarts(2, "#{RbConfig.ruby} #{example_path} 2")
end
end
end
Expand Down

0 comments on commit 7eab3fb

Please sign in to comment.