Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix restart #321

Merged
merged 2 commits into from
Jan 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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