summaryrefslogtreecommitdiff
path: root/lib/rake/testtask.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rake/testtask.rb')
-rw-r--r--lib/rake/testtask.rb29
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb
index c693dd2626..2daa589634 100644
--- a/lib/rake/testtask.rb
+++ b/lib/rake/testtask.rb
@@ -1,5 +1,3 @@
-# Define a task library for running unit tests.
-
require 'rake'
require 'rake/tasklib'
@@ -67,6 +65,9 @@ module Rake
# Array of commandline options to pass to ruby when running test loader.
attr_accessor :ruby_opts
+ # Description of the test task. (default is 'Run tests')
+ attr_accessor :description
+
# Explicitly define the list of test files to be included in a
# test. +list+ is expected to be an array of file names (a
# FileList is acceptable). If both +pattern+ and +test_files+ are
@@ -86,6 +87,7 @@ module Rake
@warning = false
@loader = :rake
@ruby_opts = []
+ @description = "Run tests" + (@name == :test ? "" : " for #{@name}")
yield self if block_given?
@pattern = 'test/test*.rb' if @pattern.nil? && @test_files.nil?
define
@@ -93,7 +95,7 @@ module Rake
# Create the tasks defined by this task lib.
def define
- desc "Run tests" + (@name == :test ? "" : " for #{@name}")
+ desc @description
task @name do
FileUtilsExt.verbose(@verbose) do
args =
@@ -121,18 +123,18 @@ module Rake
"")
end
- def ruby_opts_string
+ def ruby_opts_string # :nodoc:
opts = @ruby_opts.dup
opts.unshift("-I\"#{lib_path}\"") unless @libs.empty?
opts.unshift("-w") if @warning
opts.join(" ")
end
- def lib_path
+ def lib_path # :nodoc:
@libs.join(File::PATH_SEPARATOR)
end
- def file_list_string
+ def file_list_string # :nodoc:
file_list.map { |fn| "\"#{fn}\"" }.join(' ')
end
@@ -156,18 +158,18 @@ module Rake
end || ''
end
- def ruby_version
+ def ruby_version # :nodoc:
RUBY_VERSION
end
- def run_code
+ def run_code # :nodoc:
case @loader
when :direct
"-e \"ARGV.each{|f| require f}\""
when :testrb
"-S testrb #{fix}"
when :rake
- "-I\"#{rake_lib_dir}\" \"#{rake_loader}\""
+ "#{rake_include_arg} \"#{rake_loader}\""
end
end
@@ -184,6 +186,15 @@ module Rake
nil
end
+ def rake_include_arg # :nodoc:
+ spec = Gem.loaded_specs['rake']
+ if spec.respond_to?(:default_gem?) && spec.default_gem?
+ ""
+ else
+ "-I\"#{rake_lib_dir}\""
+ end
+ end
+
def rake_lib_dir # :nodoc:
find_dir('rake') or
fail "unable to find rake lib"