зеркало из https://github.com/github/ruby.git
* common.mk (test-all): separate directory where running test cases
from source tree. * lib/test/unit/autorunner.rb (options): added --basedir, --workdir and --load-path options. * lib/test/unit/collector/dir.rb (recursive_collect, collect_file): base directory support. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
536cbbb200
Коммит
5cfcbb2aca
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
Mon Oct 2 01:24:26 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* common.mk (test-all): separate directory where running test cases
|
||||||
|
from source tree.
|
||||||
|
|
||||||
|
* lib/test/unit/autorunner.rb (options): added --basedir, --workdir
|
||||||
|
and --load-path options.
|
||||||
|
|
||||||
|
* lib/test/unit/collector/dir.rb (recursive_collect, collect_file):
|
||||||
|
base directory support.
|
||||||
|
|
||||||
Sun Oct 1 23:56:52 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sun Oct 1 23:56:52 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* Makefile.in, common.mk, ext/extmk.rb, win{32,ce}/Makefile.in: keep
|
* Makefile.in, common.mk, ext/extmk.rb, win{32,ce}/Makefile.in: keep
|
||||||
|
|
|
@ -74,6 +74,9 @@ INSTRUBY_ARGS = $(SCRIPT_ARGS) --installed-list $(INSTALLED_LIST)
|
||||||
PRE_LIBRUBY_UPDATE = $(MINIRUBY) -e 'ARGV[1] or File.unlink(ARGV[0]) rescue nil' -- \
|
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
|
||||||
|
TESTWORKDIR = testwork
|
||||||
|
|
||||||
all: $(MKFILES) $(PREP) $(RBCONFIG) $(LIBRUBY)
|
all: $(MKFILES) $(PREP) $(RBCONFIG) $(LIBRUBY)
|
||||||
@$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS)
|
@$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS)
|
||||||
prog: $(PROGRAM) $(WPROGRAM)
|
prog: $(PROGRAM) $(WPROGRAM)
|
||||||
|
@ -278,7 +281,7 @@ test: miniruby$(EXEEXT) $(RBCONFIG) $(PROGRAM) PHONY
|
||||||
@$(MINIRUBY) $(srcdir)/rubytest.rb
|
@$(MINIRUBY) $(srcdir)/rubytest.rb
|
||||||
|
|
||||||
test-all:
|
test-all:
|
||||||
$(RUNRUBY) -C "$(srcdir)/test" runner.rb --runner=$(TESTUI) $(TESTS)
|
$(RUNRUBY) "$(srcdir)/test/runner.rb" --basedir="$(TESTSDIR)" --runner=$(TESTUI) $(TESTS)
|
||||||
|
|
||||||
extconf:
|
extconf:
|
||||||
$(MINIRUBY) -I$(srcdir)/lib -run -e mkdir -- -p "$(EXTCONFDIR)"
|
$(MINIRUBY) -I$(srcdir)/lib -run -e mkdir -- -p "$(EXTCONFDIR)"
|
||||||
|
|
|
@ -7,9 +7,8 @@ module Test
|
||||||
class AutoRunner
|
class AutoRunner
|
||||||
def self.run(force_standalone=false, default_dir=nil, argv=ARGV, &block)
|
def self.run(force_standalone=false, default_dir=nil, argv=ARGV, &block)
|
||||||
r = new(force_standalone || standalone?, &block)
|
r = new(force_standalone || standalone?, &block)
|
||||||
if((!r.process_args(argv)) && default_dir)
|
r.base = default_dir
|
||||||
r.to_run << default_dir
|
r.process_args(argv)
|
||||||
end
|
|
||||||
r.run
|
r.run
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -64,12 +63,14 @@ module Test
|
||||||
c.filter = r.filters
|
c.filter = r.filters
|
||||||
c.pattern.concat(r.pattern) if(r.pattern)
|
c.pattern.concat(r.pattern) if(r.pattern)
|
||||||
c.exclude.concat(r.exclude) if(r.exclude)
|
c.exclude.concat(r.exclude) if(r.exclude)
|
||||||
|
c.base = r.base
|
||||||
|
$:.unshift(r.base) if r.base
|
||||||
c.collect(*(r.to_run.empty? ? ['.'] : r.to_run))
|
c.collect(*(r.to_run.empty? ? ['.'] : r.to_run))
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
attr_reader :suite
|
attr_reader :suite
|
||||||
attr_accessor :output_level, :filters, :to_run, :pattern, :exclude
|
attr_accessor :output_level, :filters, :to_run, :pattern, :exclude, :base, :workdir
|
||||||
attr_writer :runner, :collector
|
attr_writer :runner, :collector
|
||||||
|
|
||||||
def initialize(standalone)
|
def initialize(standalone)
|
||||||
|
@ -110,6 +111,14 @@ module Test
|
||||||
end
|
end
|
||||||
|
|
||||||
if(@standalone)
|
if(@standalone)
|
||||||
|
o.on('-b', '--basedir=DIR', "Base directory of test suits.") do |b|
|
||||||
|
@base = b
|
||||||
|
end
|
||||||
|
|
||||||
|
o.on('-w', '--workdir=DIR', "Working directory to run tests.") do |w|
|
||||||
|
@workdir = w
|
||||||
|
end
|
||||||
|
|
||||||
o.on('-a', '--add=TORUN', Array,
|
o.on('-a', '--add=TORUN', Array,
|
||||||
"Add TORUN to the list of things to run;",
|
"Add TORUN to the list of things to run;",
|
||||||
"can be a file or a directory.") do |a|
|
"can be a file or a directory.") do |a|
|
||||||
|
@ -153,6 +162,11 @@ module Test
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
o.on('-I', "--load-path=DIR[#{File::PATH_SEPARATOR}DIR...]",
|
||||||
|
"Appends directory list to $LOAD_PATH.") do |dirs|
|
||||||
|
$LOAD_PATH.concat(dirs.split(File::PATH_SEPARATOR))
|
||||||
|
end
|
||||||
|
|
||||||
o.on('-v', '--verbose=[LEVEL]', OUTPUT_LEVELS,
|
o.on('-v', '--verbose=[LEVEL]', OUTPUT_LEVELS,
|
||||||
"Set the output level (default is verbose).",
|
"Set the output level (default is verbose).",
|
||||||
"(" + keyword_display(OUTPUT_LEVELS) + ")") do |l|
|
"(" + keyword_display(OUTPUT_LEVELS) + ")") do |l|
|
||||||
|
@ -197,6 +211,7 @@ module Test
|
||||||
def run
|
def run
|
||||||
@suite = @collector[self]
|
@suite = @collector[self]
|
||||||
result = @runner[self] or return false
|
result = @runner[self] or return false
|
||||||
|
Dir.chdir(@workdir) if @workdir
|
||||||
result.run(@suite, @output_level).passed?
|
result.run(@suite, @output_level).passed?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,7 @@ module Test
|
||||||
include Collector
|
include Collector
|
||||||
|
|
||||||
attr_reader :pattern, :exclude
|
attr_reader :pattern, :exclude
|
||||||
|
attr_accessor :base
|
||||||
|
|
||||||
def initialize(dir=::Dir, file=::File, object_space=::ObjectSpace, req=nil)
|
def initialize(dir=::Dir, file=::File, object_space=::ObjectSpace, req=nil)
|
||||||
super()
|
super()
|
||||||
|
@ -47,11 +48,12 @@ module Test
|
||||||
|
|
||||||
def recursive_collect(name, already_gathered)
|
def recursive_collect(name, already_gathered)
|
||||||
sub_suites = []
|
sub_suites = []
|
||||||
if(@file.directory?(name))
|
path = realdir(name)
|
||||||
@dir.entries(name).each do |e|
|
if @file.directory?(path)
|
||||||
|
@dir.entries(path).each do |e|
|
||||||
next if(e == '.' || e == '..')
|
next if(e == '.' || e == '..')
|
||||||
e_name = @file.join(name, e)
|
e_name = @file.join(name, e)
|
||||||
if(@file.directory?(e_name))
|
if @file.directory?(realdir(e_name))
|
||||||
next if /\ACVS\z/ =~ e
|
next if /\ACVS\z/ =~ e
|
||||||
sub_suite = recursive_collect(e_name, already_gathered)
|
sub_suite = recursive_collect(e_name, already_gathered)
|
||||||
sub_suites << sub_suite unless(sub_suite.empty?)
|
sub_suites << sub_suite unless(sub_suite.empty?)
|
||||||
|
@ -75,7 +77,7 @@ module Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def collect_file(name, suites, already_gathered)
|
def collect_file(name, suites, already_gathered)
|
||||||
dir = File.dirname(File.expand_path(name))
|
dir = File.dirname(File.expand_path(name, @base))
|
||||||
$:.unshift(dir)
|
$:.unshift(dir)
|
||||||
if(@req)
|
if(@req)
|
||||||
@req.require(name)
|
@req.require(name)
|
||||||
|
@ -86,6 +88,14 @@ module Test
|
||||||
ensure
|
ensure
|
||||||
$:.delete_at($:.rindex(dir)) if(dir)
|
$:.delete_at($:.rindex(dir)) if(dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def realdir(path)
|
||||||
|
if @base
|
||||||
|
@file.join(@base, path)
|
||||||
|
else
|
||||||
|
path
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче