Skip to content

Commit

Permalink
The rake test loaded needs to remove items from ARGV that it has hand…
Browse files Browse the repository at this point in the history
…led. Issue ruby#51
  • Loading branch information
drbrain committed Jun 23, 2011
1 parent 3fbd677 commit 962ee5b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/rake/rake_test_loader.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
require 'rake'

# Load the test files from the command line.
argv = ARGV.select do |argument|
case argument
when /^-/ then
argument
when /\*/ then
FileList[argument].to_a.each do |file|
require File.expand_path file
end

ARGV.each do |f|
next if f =~ /^-/

if f =~ /\*/
FileList[f].to_a.each { |fn| require File.expand_path(fn) }
false
else
require File.expand_path(f)
require File.expand_path argument

false
end
end

ARGV.replace argv

21 changes: 21 additions & 0 deletions test/test_rake_rake_test_loader.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require File.expand_path('../helper', __FILE__)

class TestRakeRakeTestLoader < Rake::TestCase

def test_pattern
orig_LOADED_FEATURES = $:.dup
FileUtils.touch 'foo.rb'
FileUtils.touch 'test_a.rb'
FileUtils.touch 'test_b.rb'

ARGV.replace %w[foo.rb test_*.rb -v]

load 'rake/rake_test_loader.rb'

assert_equal %w[-v], ARGV
ensure
$:.replace orig_LOADED_FEATURES
end

end

0 comments on commit 962ee5b

Please sign in to comment.