1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
# frozen_string_literal: true
require "test_helper"
require "rbconfig"
require "minitest/mock"
module Byebug
#
# Tests restarting functionality.
#
class RestartTest < TestCase
def test_restart_with_no_args_original_script_with_no_args_standalone_mode
with_mode(:standalone) do
with_command_line(example_path) do
assert_restarts(nil, "#{ruby_bin} #{byebug_bin} #{example_path}")
end
end
end
def test_restart_with_no_args_original_script_with_no_args_attached_mode
with_mode(:attached) do
with_command_line(example_path) do
assert_restarts(nil, "#{ruby_bin} #{example_path}")
end
end
end
def test_restart_with_no_args_original_script_through_ruby_attached_mode
with_mode(:attached) do
with_command_line("ruby", example_path) do
assert_restarts(nil, "ruby #{example_path}")
end
end
end
def test_restart_with_no_args_in_standalone_mode
with_mode(:standalone) do
with_command_line(example_path, "1") do
assert_restarts(nil, "#{ruby_bin} #{byebug_bin} #{example_path} 1")
end
end
end
def test_restart_with_args_in_standalone_mode
with_mode(:standalone) do
with_command_line(example_path, "1") do
assert_restarts("2", "#{ruby_bin} #{byebug_bin} #{example_path} 2")
end
end
end
def test_restart_with_no_args_in_attached_mode
with_mode(:attached) do
with_command_line(example_path, "1") do
assert_restarts(nil, "#{ruby_bin} #{example_path} 1")
end
end
end
def test_restart_with_args_in_attached_mode
with_mode(:attached) do
with_command_line(example_path, "1") do
assert_restarts(2, "#{ruby_bin} #{example_path} 2")
end
end
end
private
def assert_restarts(arg, expected_cmd_line)
assert_calls(Kernel, :exec, expected_cmd_line) do
enter ["restart", arg].compact.join(" ")
debug_code(minimal_program)
check_output_includes "Re exec'ing:"
end
end
def ruby_bin
RbConfig.ruby
end
def byebug_bin
Context.bin_file
end
end
end
|