summaryrefslogtreecommitdiff
path: root/lib/test/unit/autorunner.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/test/unit/autorunner.rb')
-rw-r--r--lib/test/unit/autorunner.rb23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/test/unit/autorunner.rb b/lib/test/unit/autorunner.rb
index d9720daa498..71dbccbced2 100644
--- a/lib/test/unit/autorunner.rb
+++ b/lib/test/unit/autorunner.rb
@@ -7,9 +7,8 @@ module Test
class AutoRunner
def self.run(force_standalone=false, default_dir=nil, argv=ARGV, &block)
r = new(force_standalone || standalone?, &block)
- if((!r.process_args(argv)) && default_dir)
- r.to_run << default_dir
- end
+ r.base = default_dir
+ r.process_args(argv)
r.run
end
@@ -64,12 +63,14 @@ module Test
c.filter = r.filters
c.pattern.concat(r.pattern) if(r.pattern)
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))
end,
}
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
def initialize(standalone)
@@ -110,6 +111,14 @@ module Test
end
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,
"Add TORUN to the list of things to run;",
"can be a file or a directory.") do |a|
@@ -153,6 +162,11 @@ module Test
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,
"Set the output level (default is verbose).",
"(" + keyword_display(OUTPUT_LEVELS) + ")") do |l|
@@ -197,6 +211,7 @@ module Test
def run
@suite = @collector[self]
result = @runner[self] or return false
+ Dir.chdir(@workdir) if @workdir
result.run(@suite, @output_level).passed?
end
end