Skip to content

Commit

Permalink
Fixes #67
Browse files Browse the repository at this point in the history
When the script to be debugged is ruby's binary, we ignore it and pass
to byebug the script to be run by ruby instead.
  • Loading branch information
David Rodríguez de Dios committed Sep 26, 2014
1 parent 2e6312e commit 72f327c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
9 changes: 6 additions & 3 deletions lib/byebug/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ def debugged_program_from_argv
abort
end

prog_script = ARGV.first
prog_script = which(prog_script)
prog_script_try = which(ARGV.first)
if prog_script_try == which('ruby')
ARGV.shift
return which(ARGV.first)
end

prog_script
prog_script_try
end

#
Expand Down
16 changes: 13 additions & 3 deletions test/runner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,20 @@ def test_run_with_a_script_to_debug
@runner.run
end

def test_debugged_program_from_argv
ARGV.replace(%w(my_script -opt value))
def test_run_with_a_script_and_params_does_not_consume_script_params
ARGV.replace(%w(-- my_script -opt value))
expect_it_debugs_script

@runner.run
assert_equal %w(my_script -opt value), ARGV
end

assert_match 'my_script', @runner.debugged_program_from_argv
def test_run_with_ruby_script_ruby_is_ignored_and_script_passed_instead
ARGV.replace(%w(-- ruby ruby_script))
expect_it_debugs_script

@runner.run
assert_equal %w(ruby_script), ARGV
end

def test_run_with_no_rc_option
Expand Down

0 comments on commit 72f327c

Please sign in to comment.