ruby-changes:42012
From: nobu <ko1@a...>
Date: Fri, 11 Mar 2016 17:03:18 +0900 (JST)
Subject: [ruby-changes:42012] nobu:r54086 (trunk): testunit: negative filter
nobu 2016-03-11 17:03:11 +0900 (Fri, 11 Mar 2016) New Revision: 54086 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54086 Log: 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. Modified files: trunk/ChangeLog trunk/common.mk trunk/test/lib/test/unit.rb Index: test/lib/test/unit.rb =================================================================== --- test/lib/test/unit.rb (revision 54085) +++ test/lib/test/unit.rb (revision 54086) @@ -87,7 +87,7 @@ module Test https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit.rb#L87 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 https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit.rb#L96 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 https://github.com/ruby/ruby/blob/trunk/test/lib/test/unit.rb#L618 @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} Index: ChangeLog =================================================================== --- ChangeLog (revision 54085) +++ ChangeLog (revision 54086) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Mar 11 17:03:09 2016 Nobuyoshi Nakada <nobu@r...> + + * 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@i...> * enc/unicode/case-folding.rb, casefold.h: Streamlining approach to Index: common.mk =================================================================== --- common.mk (revision 54085) +++ common.mk (revision 54086) @@ -154,7 +154,7 @@ PRE_LIBRUBY_UPDATE = $(MINIRUBY) -e 'ARG https://github.com/ruby/ruby/blob/trunk/common.mk#L154 $(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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/