Skip to content
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: 1 addition & 1 deletion lib/rake/testtask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def ruby_version # :nodoc:
def run_code # :nodoc:
case @loader
when :direct
"-e \"ARGV.each{|f| require f}\""
"-e \"ARGV.each{|f| require f unless f.start_with?('-')}\""
when :"test-unit"
"-S test-unit"
when :rake
Expand Down
26 changes: 25 additions & 1 deletion test/test_rake_test_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,34 @@ def test_run_code_direct
# t.pettern is "test/test*.rb"
end

assert_equal '-e "ARGV.each{|f| require f}"', test_task.run_code
assert_equal %q{-e "ARGV.each{|f| require f unless f.start_with?('-')}"}, test_task.run_code
assert_equal globbed, test_task.file_list.to_a
end

def test_run_code_direct_skips_option_arguments
test_task = Rake::TestTask.new do |t|
t.loader = :direct
t.verbose = true
end

code = test_task.run_code[/\A-e "(.*)"\z/, 1]
refute_nil code

required = []
receiver = Object.new
receiver.define_singleton_method(:require) { |file| required << file }

saved_argv = ARGV.dup
begin
ARGV.replace(["test/foo_test.rb", "-v"])
receiver.instance_eval(code)
ensure
ARGV.replace(saved_argv)
end

assert_equal ["test/foo_test.rb"], required
end

test "run code test-unit" do
test_task = Rake::TestTask.new do |t|
t.loader = :"test-unit"
Expand Down