Skip to content

Commit

Permalink
Modified 'restart' Kernel.exec to always call 'ruby'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jun Kudou committed Jan 26, 2017
1 parent a7009c7 commit 205641d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

* `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
2 changes: 2 additions & 0 deletions lib/byebug/commands/restart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'byebug/helpers/path'
require 'shellwords'
require 'English'
require 'rbconfig'

module Byebug
#
Expand Down Expand Up @@ -36,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 205641d

Please sign in to comment.