Skip to content

Commit

Permalink
Added test_files= to test tasks.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/rake/trunk@244 5af023f1-ac1a-0410-98d6-829a145c37ef
  • Loading branch information
jimweirich committed Jul 25, 2004
1 parent f2a6606 commit 0f28752
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions rake/lib/rake/testtask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,45 @@ class TestTask < TaskLib
def initialize(name=:test)
@name = name
@libs = ["lib"]
@pattern = 'test/test*.rb'
@pattern = nil
@test_files = nil
@verbose = false
yield self if block_given?
@pattern = 'test/test*.rb' if @pattern.nil? && @test_files.nil?
define
end

# Create the tasks defined by this task lib.
def define
lib_path = @libs.join(':')
testfiles = FileList[ ENV['TEST'] || @pattern ]
if ENV['TESTOPTS']
testoptions = " \\\n -- #{ENV['TESTOPTS']}"
else
testoptions = ''
end
desc "Run tests" + (@name==:test ? "" : " for #{@name}")
task @name do
testreqs = testfiles.gsub(/^(.*)\.rb$/, ' -r\1').join(" \\\n")
ruby %{-I#{lib_path} -e0 \\\n#{testreqs}#{testoptions}}
testreqs = test_file_list.gsub(/^(.*)\.rb$/, ' -r\1').join(" \\\n")
RakeFileUtils.verbose(@verbose) do
ruby %{-I#{lib_path} -e0 \\\n#{testreqs}#{testoptions}}
end
end
self
end

def running_as_gem
$LOAD_PATH.find { |fn| fn =~ %r{gems/.*/rake} } != nil
def test_files=(list)
@test_files = list
end

def test_file_list
if ENV['TEST']
FileList[ ENV['TEST'] ]
else
result = []
result += @test_files.to_a if @test_files
result += FileList[ @pattern ].to_a if @pattern
FileList[result]
end
end

end
Expand Down

0 comments on commit 0f28752

Please sign in to comment.