Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/swig/ruby/test/test-unit-ext/priority.rb view on Meta::CPAN
def priority_check_method_name(priority_name)
"run_priority_#{priority_name}?"
end
def normalize_test_name(test_name)
"test_#{test_name.to_s.sub(/^test_/, '')}"
end
def set_priority(name, priority=@current_priority)
@priority_table[normalize_test_name(name)] = priority
end
def run_priority_must?(test_name)
true
end
def run_priority_important?(test_name)
rand > 0.1
end
def run_priority_high?(test_name)
rand > 0.3
end
def run_priority_normal?(test_name)
rand > 0.5
end
def run_priority_low?(test_name)
rand > 0.75
end
def run_priority_never?(test_name)
false
end
end
def need_to_run?
!previous_test_success? or self.class.need_to_run?(@method_name)
end
alias_method :original_run, :run
def run(result, &block)
original_run(result, &block)
ensure
if passed?
FileUtils.touch(passed_file)
else
FileUtils.rm_f(passed_file)
end
end
private
def previous_test_success?
File.exist?(passed_file)
end
def result_dir
dir = File.join(File.dirname($0), ".test-result",
self.class.name, escaped_method_name)
dir = File.expand_path(dir)
FileUtils.mkdir_p(dir)
dir
end
def passed_file
File.join(result_dir, "passed")
end
def escaped_method_name
@method_name.to_s.gsub(/[!?]$/) do |matched|
case matched
when "!"
".destructive"
when "?"
".predicate"
end
end
end
end
class TestSuite
@@priority_mode = false
class << self
def priority_mode=(bool)
@@priority_mode = bool
end
end
alias_method :original_run, :run
def run(*args, &block)
priority_mode = @@priority_mode
if priority_mode
@original_tests = @tests
apply_priority
end
original_run(*args, &block)
ensure
@tests = @original_tests if priority_mode
end
def apply_priority
@tests = @tests.reject {|test| !test.need_to_run?}
end
def need_to_run?
apply_priority
!@tests.empty?
end
end if RUBY_VERSION < '1.9.3'
class AutoRunner
alias_method :original_options, :options
def options
opts = original_options
opts.on("--[no-]priority", "use priority mode") do |bool|
TestSuite.priority_mode = bool
end
opts
end
( run in 0.739 second using v1.01-cache-2.11-cpan-5b529ec07f3 )