aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--common.mk2
-rw-r--r--test/lib/test/unit.rb30
3 files changed, 35 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index e9bdac4db3..eedd9ff8b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Mar 11 17:03:09 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * test/lib/test/unit.rb (Options#non_options): make regexp name
+ options prefixed with "!" negative filters.
+
+ * common.mk (TEST_EXCLUDES): use negative filter to exclude memory
+ leak tests. -x option excludes test files, not test methods.
+
Fri Mar 11 16:11:27 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
* enc/unicode/case-folding.rb, casefold.h: Streamlining approach to
diff --git a/common.mk b/common.mk
index 2041ce760f..dd190a1d91 100644
--- a/common.mk
+++ b/common.mk
@@ -154,7 +154,7 @@ PRE_LIBRUBY_UPDATE = $(MINIRUBY) -e 'ARGV[1] or File.unlink(ARGV[0]) rescue nil'
$(LIBRUBY_EXTS) $(LIBRUBY_SO_UPDATE)
TESTSDIR = $(srcdir)/test
-TEST_EXCLUDES = --excludes=$(TESTSDIR)/excludes -x /memory_leak/
+TEST_EXCLUDES = --excludes=$(TESTSDIR)/excludes --name=!/memory_leak/
EXCLUDE_TESTFRAMEWORK = -x /testunit/ -x /minitest/
TESTWORKDIR = testwork
TESTOPTS = $(RUBY_TESTOPTS)
diff --git a/test/lib/test/unit.rb b/test/lib/test/unit.rb
index 2825c2eb4a..3ab0527e6b 100644
--- a/test/lib/test/unit.rb
+++ b/test/lib/test/unit.rb
@@ -87,7 +87,7 @@ module Test
end
opts.on '-n', '--name PATTERN', "Filter test method names on pattern: /REGEXP/ or STRING" do |a|
- options[:filter] = a
+ (options[:filter] ||= []) << a
end
opts.on '--test-order=random|alpha|sorted', [:random, :alpha, :sorted] do |a|
@@ -96,6 +96,30 @@ module Test
end
def non_options(files, options)
+ filter = options[:filter]
+ if filter
+ pos_pat = /\A\/(.*)\/\z/
+ neg_pat = /\A!\/(.*)\/\z/
+ negative, positive = filter.partition {|s| neg_pat =~ s}
+ if positive.empty?
+ filter = nil
+ elsif negative.empty? and positive.size == 1 and pos_pat !~ positive[0]
+ filter = positive[0]
+ else
+ filter = Regexp.union(*positive.map! {|s| s[pos_pat, 1] || "\\A#{Regexp.quote(s)}\\z"})
+ end
+ unless negative.empty?
+ negative = Regexp.union(*negative.map! {|s| s[neg_pat, 1]})
+ filter = /\A(?!.*#{negative})#{filter}/
+ end
+ if Regexp === filter
+ # bypass conversion in minitest
+ def filter.=~(other) # :nodoc:
+ super unless Regexp === other
+ end
+ end
+ options[:filter] = filter
+ end
true
end
end
@@ -594,9 +618,7 @@ module Test
@verbose = !options[:parallel]
end
@output = Output.new(self) unless @options[:testing]
- if /\A\/(.*)\/\z/ =~ (filter = options[:filter])
- filter = Regexp.new($1)
- end
+ filter = options[:filter]
type = "#{type}_methods"
total = if filter
suites.inject(0) {|n, suite| n + suite.send(type).grep(filter).size}