diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-11 08:03:11 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-11 08:03:11 +0000 |
commit | 83e36bb5a6e02b747d10c1baf5e1b7ff2b4c49fe (patch) | |
tree | cb0be93b838fa7e4f104a4be727cf2b594509e81 | |
parent | 59766643db17f8dbfe518cafa20f6ba36a9b8d9b (diff) | |
download | ruby-83e36bb5a6e02b747d10c1baf5e1b7ff2b4c49fe.tar.gz |
testunit: negative filter
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | common.mk | 2 | ||||
-rw-r--r-- | test/lib/test/unit.rb | 30 |
3 files changed, 35 insertions, 5 deletions
@@ -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 @@ -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} |