diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-19 02:01:59 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-19 02:01:59 +0000 |
commit | 97e966d04bd758d66b7264801ba197a61e3616e4 (patch) | |
tree | 5b43a46cc2bfea4db1a16175debdba14a35faeaf /lib/test | |
parent | fda1e2a0abce1d52fd42bb1eacce13a56f2a7fd7 (diff) | |
download | ruby-97e966d04bd758d66b7264801ba197a61e3616e4.tar.gz ruby-97e966d04bd758d66b7264801ba197a61e3616e4.tar.xz ruby-97e966d04bd758d66b7264801ba197a61e3616e4.zip |
* lib/test/unit.rb: use standalone runner for -e.
* lib/test/unit/autorunner.rb (Test::Unit::AutoRunner#options): accept
multiple -p and -x options.
* lib/test/unit/collector/dir.rb (Test::Unit::Collector::Dir#recursive_collect):
ditto.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/test')
-rw-r--r-- | lib/test/unit.rb | 6 | ||||
-rw-r--r-- | lib/test/unit/autorunner.rb | 11 | ||||
-rw-r--r-- | lib/test/unit/collector/dir.rb | 18 |
3 files changed, 23 insertions, 12 deletions
diff --git a/lib/test/unit.rb b/lib/test/unit.rb index 763cd27ba..84f221fe9 100644 --- a/lib/test/unit.rb +++ b/lib/test/unit.rb @@ -271,4 +271,8 @@ module Test # :nodoc: end end -at_exit{exit(Test::Unit::AutoRunner.run($0)) unless($! || Test::Unit.run?)} +at_exit do + unless $! || Test::Unit.run? + exit Test::Unit::AutoRunner.run($0 != "-e" && $0) + end +end diff --git a/lib/test/unit/autorunner.rb b/lib/test/unit/autorunner.rb index 8dc2b2565..38b0b76ef 100644 --- a/lib/test/unit/autorunner.rb +++ b/lib/test/unit/autorunner.rb @@ -1,3 +1,4 @@ +require 'test/unit' require 'test/unit/ui/testrunnerutilities' require 'optparse' @@ -55,8 +56,8 @@ module Test require 'test/unit/collector/dir' c = Collector::Dir.new c.filter = r.filters - c.pattern = r.pattern if(r.pattern) - c.exclude = r.exclude if(r.exclude) + c.pattern.concat(r.pattern) if(r.pattern) + c.exclude.concat(r.exclude) if(r.exclude) c.collect(*(r.to_run.empty? ? ['.'] : r.to_run)) end, } @@ -109,14 +110,16 @@ module Test @to_run.concat(a) end + @pattern = [] o.on('-p', '--pattern=PATTERN', Regexp, "Match files to collect against PATTERN.") do |e| - @pattern = e + @pattern << e end + @exclude = [] o.on('-x', '--exclude=PATTERN', Regexp, "Ignore files to collect against PATTERN.") do |e| - @exclude = e + @exclude << e end end diff --git a/lib/test/unit/collector/dir.rb b/lib/test/unit/collector/dir.rb index bf78f3a50..9342fdecb 100644 --- a/lib/test/unit/collector/dir.rb +++ b/lib/test/unit/collector/dir.rb @@ -7,7 +7,7 @@ module Test class Dir include Collector - attr_writer :pattern, :exclude + attr_reader :pattern, :exclude def initialize(dir=::Dir, file=::File, object_space=::ObjectSpace, req=nil) super() @@ -15,8 +15,8 @@ module Test @file = file @object_space = object_space @req = req - @pattern = /\btest_.*\.rb\Z/m - @exclude = nil + @pattern = [/\btest_.*\.rb\Z/m] + @exclude = [] end def collect(*from) @@ -52,13 +52,17 @@ module Test next if(e == '.' || e == '..') e_name = @file.join(name, e) if(@file.directory?(e_name)) + next if /\ACVS\z/ =~ e sub_suite = recursive_collect(e_name, already_gathered) sub_suites << sub_suite unless(sub_suite.empty?) else - next if %r(/CVS|~\Z|\.\#) =~ e_name - next unless /test_/ =~ e_name - (next unless(@pattern =~ e_name)) if(@pattern) - (next if(@exclude =~ e_name)) if(@exclude) + next if /~\z/ =~ e_name or /\A\.\#/ =~ e + if @pattern and !@pattern.empty? + next unless @pattern.any? {|pat| pat =~ e_name} + end + if @exclude and !@exclude.empty? + next if @exclude.any? {|pat| pat =~ e_name} + end collect_file(e_name, sub_suites, already_gathered) end end |