summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--lib/test/unit.rb6
-rw-r--r--lib/test/unit/autorunner.rb15
-rw-r--r--lib/test/unit/collector/dir.rb15
-rw-r--r--test/testunit/collector/test_dir.rb8
5 files changed, 42 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 5e5fc3554..8b287d1a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Sun Dec 19 11:01:25 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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.
+
Sat Dec 18 16:36:23 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/zlib/zlib.c (rb_deflate_s_deflate, rb_inflate_s_inflate):
diff --git a/lib/test/unit.rb b/lib/test/unit.rb
index 3c0d265b2..f6f250a5c 100644
--- a/lib/test/unit.rb
+++ b/lib/test/unit.rb
@@ -280,4 +280,8 @@ module Test
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 b120adec0..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,13 +56,14 @@ module Test
require 'test/unit/collector/dir'
c = Collector::Dir.new
c.filter = r.filters
- c.pattern = r.pattern if(r.pattern)
+ 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,
}
attr_reader :suite
- attr_accessor :output_level, :filters, :to_run, :pattern
+ attr_accessor :output_level, :filters, :to_run, :pattern, :exclude
attr_writer :runner, :collector
def initialize(standalone)
@@ -108,9 +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
end
end
diff --git a/lib/test/unit/collector/dir.rb b/lib/test/unit/collector/dir.rb
index 43fd1be71..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
+ attr_reader :pattern, :exclude
def initialize(dir=::Dir, file=::File, object_space=::ObjectSpace, req=nil)
super()
@@ -15,7 +15,8 @@ module Test
@file = file
@object_space = object_space
@req = req
- @pattern = /\Atest_.*\.rb\Z/m
+ @pattern = [/\btest_.*\.rb\Z/m]
+ @exclude = []
end
def collect(*from)
@@ -51,10 +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 unless(@pattern =~ e)) if(@pattern)
+ 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
@@ -76,7 +84,6 @@ module Test
require(name)
end
find_test_cases(already_gathered).each{|t| add_suite(suites, t.suite)}
- rescue LoadError, SystemExit
ensure
$:.replace(loadpath)
end
diff --git a/test/testunit/collector/test_dir.rb b/test/testunit/collector/test_dir.rb
index e9b42d796..e7ae41426 100644
--- a/test/testunit/collector/test_dir.rb
+++ b/test/testunit/collector/test_dir.rb
@@ -164,11 +164,11 @@ module Test
def test_dir
inner_dir = nil
- dir = FileSystem::Directory.new('/', nil) do
+ dirs = FileSystem::Directory.new('/', nil) do
file 'a', nil
inner_dir = dir 'b'
end
- assert_equal(inner_dir, dir['b'])
+ assert_equal(inner_dir, dirs['b'])
end
def test_fs
@@ -365,7 +365,7 @@ module Test
def test_nil_pattern
expected = TestSuite.new('d2')
expected << @t5.suite
- @c.pattern = nil
+ @c.pattern.clear
assert_equal(expected, @c.collect('d2'))
end
@@ -380,7 +380,7 @@ module Test
expected = TestSuite.new('[d1, d2]')
expected << (TestSuite.new('d1') << @t3.suite)
expected << (TestSuite.new('d2') << @t5.suite)
- @c.pattern = /^test_/
+ @c.pattern.replace([/\btest_/])
assert_equal(expected, @c.collect('d1', 'd2'))
end
end