1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/test/unit.rb (Test::Unit::Options#process_args): always

return options.
* lib/test/unit.rb (Test::Unit::RequireFiles#non_options): return
  if any test case get loaded.
* lib/test/unit.rb (Test::Unit::AutoRunner#initialize): do not add
  default directory if it is nil.
* lib/test/unit.rb (Test::Unit::AutoRunner#process_args): return
  true if any test cases to run.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-02-12 15:29:24 +00:00
parent 7f46fadd9d
commit 420d98e4a8
3 changed files with 22 additions and 4 deletions

View file

@ -1,3 +1,17 @@
Sun Feb 13 00:29:18 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/test/unit.rb (Test::Unit::Options#process_args): always
return options.
* lib/test/unit.rb (Test::Unit::RequireFiles#non_options): return
if any test case get loaded.
* lib/test/unit.rb (Test::Unit::AutoRunner#initialize): do not add
default directory if it is nil.
* lib/test/unit.rb (Test::Unit::AutoRunner#process_args): return
true if any test cases to run.
Sat Feb 12 23:17:43 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> Sat Feb 12 23:17:43 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/test/unit.rb (assert_include): add alias. * lib/test/unit.rb (assert_include): add alias.

View file

@ -5,6 +5,6 @@ tests.options.banner.sub!(/\[options\]/, '\& tests...')
unless tests.process_args(ARGV) unless tests.process_args(ARGV)
abort tests.options.banner abort tests.options.banner
end end
p files = tests.to_run files = tests.to_run
$0 = files.size == 1 ? File.basename(files[0]) : files.to_s $0 = files.size == 1 ? File.basename(files[0]) : files.to_s
exit tests.run exit tests.run

View file

@ -48,7 +48,7 @@ module Test
opts.parse!(args) opts.parse!(args)
orig_args -= args orig_args -= args
args = @init_hook.call(args, options) if @init_hook args = @init_hook.call(args, options) if @init_hook
non_options(args, options) or return nil non_options(args, options)
@help = orig_args.map { |s| s =~ /[\s|&<>$()]/ ? s.inspect : s }.join " " @help = orig_args.map { |s| s =~ /[\s|&<>$()]/ ? s.inspect : s }.join " "
@options = options @options = options
end end
@ -167,7 +167,8 @@ module Test
module RequireFiles module RequireFiles
def non_options(files, options) def non_options(files, options)
return false if !super or files.empty? return false if !super
result = false
files.each {|f| files.each {|f|
d = File.dirname(path = File.expand_path(f)) d = File.dirname(path = File.expand_path(f))
unless $:.include? d unless $:.include? d
@ -175,10 +176,12 @@ module Test
end end
begin begin
require path require path
result = true
rescue LoadError rescue LoadError
puts "#{f}: #{$!}" puts "#{f}: #{$!}"
end end
} }
result
end end
end end
@ -227,7 +230,7 @@ module Test
def initialize(force_standalone = false, default_dir = nil, argv = ARGV) def initialize(force_standalone = false, default_dir = nil, argv = ARGV)
@runner = Runner.new do |files, options| @runner = Runner.new do |files, options|
options[:base_directory] ||= default_dir options[:base_directory] ||= default_dir
files << default_dir if files.empty? files << default_dir if files.empty? and default_dir
@to_run = files @to_run = files
yield self if block_given? yield self if block_given?
files files
@ -238,6 +241,7 @@ module Test
def process_args(*args) def process_args(*args)
@runner.process_args(*args) @runner.process_args(*args)
!@to_run.empty?
end end
def run def run