* 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:
nobu 2016-03-11 08:03:11 +00:00
Родитель 59766643db
Коммит 83e36bb5a6
3 изменённых файлов: 35 добавлений и 5 удалений

Просмотреть файл

@ -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)

Просмотреть файл

@ -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}