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
This commit is contained in:
parent
59766643db
commit
83e36bb5a6
@ -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>
|
Fri Mar 11 16:11:27 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||||
|
|
||||||
* enc/unicode/case-folding.rb, casefold.h: Streamlining approach to
|
* 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)
|
$(LIBRUBY_EXTS) $(LIBRUBY_SO_UPDATE)
|
||||||
|
|
||||||
TESTSDIR = $(srcdir)/test
|
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/
|
EXCLUDE_TESTFRAMEWORK = -x /testunit/ -x /minitest/
|
||||||
TESTWORKDIR = testwork
|
TESTWORKDIR = testwork
|
||||||
TESTOPTS = $(RUBY_TESTOPTS)
|
TESTOPTS = $(RUBY_TESTOPTS)
|
||||||
|
@ -87,7 +87,7 @@ module Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
opts.on '-n', '--name PATTERN', "Filter test method names on pattern: /REGEXP/ or STRING" do |a|
|
opts.on '-n', '--name PATTERN', "Filter test method names on pattern: /REGEXP/ or STRING" do |a|
|
||||||
options[:filter] = a
|
(options[:filter] ||= []) << a
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on '--test-order=random|alpha|sorted', [:random, :alpha, :sorted] do |a|
|
opts.on '--test-order=random|alpha|sorted', [:random, :alpha, :sorted] do |a|
|
||||||
@ -96,6 +96,30 @@ module Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def non_options(files, options)
|
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
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -594,9 +618,7 @@ module Test
|
|||||||
@verbose = !options[:parallel]
|
@verbose = !options[:parallel]
|
||||||
end
|
end
|
||||||
@output = Output.new(self) unless @options[:testing]
|
@output = Output.new(self) unless @options[:testing]
|
||||||
if /\A\/(.*)\/\z/ =~ (filter = options[:filter])
|
filter = options[:filter]
|
||||||
filter = Regexp.new($1)
|
|
||||||
end
|
|
||||||
type = "#{type}_methods"
|
type = "#{type}_methods"
|
||||||
total = if filter
|
total = if filter
|
||||||
suites.inject(0) {|n, suite| n + suite.send(type).grep(filter).size}
|
suites.inject(0) {|n, suite| n + suite.send(type).grep(filter).size}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user