Navigation Menu

Skip to content

Commit

Permalink
Add --exclude-test
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 11, 2012
1 parent 27ab022 commit 014486e
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions lib/groonga/tester.rb
Expand Up @@ -116,6 +116,17 @@ def create_option_parser(tester, tag)
tester.reporter = reporter
end

parser.on("--exclude-test=NAME",
"Exclude test that name is NAME",
"If NAME is /.../, NAME is treated as regular expression",
"This option can be used multiple times") do |name|
if /\A\/(.+)\/\z/ =~ name
tester.exclude_test_patterns << Regexp.new($1, Regexp::IGNORECASE)
else
tester.exclude_test_patterns << name
end
end

parser.on("--n-workers=N", Integer,
"Use N workers to run tests") do |n|
tester.n_workers = n
Expand Down Expand Up @@ -162,6 +173,7 @@ def create_option_parser(tester, tag)
attr_accessor :output
attr_accessor :gdb, :default_gdb
attr_writer :reporter, :keep_database, :use_color
attr_reader :exclude_test_patterns
def initialize
@groonga = "groonga"
@groonga_httpd = "groonga-httpd"
Expand All @@ -174,6 +186,7 @@ def initialize
@output = $stdout
@keep_database = false
@use_color = nil
@exclude_test_patterns = []
detect_suitable_diff
initialize_debuggers
end
Expand Down Expand Up @@ -209,6 +222,12 @@ def use_color?
@use_color
end

def exclude_test?(test_name)
@exclude_test_patterns.any? do |pattern|
pattern === test_name
end
end

private
def load_tests(*targets)
default_group_name = "."
Expand Down Expand Up @@ -322,14 +341,15 @@ def test_not_checked

class Worker
attr_reader :id, :tester, :test_suites_rusult, :reporter
attr_reader :suite_name, :test_script_path, :status, :result
attr_reader :suite_name, :test_script_path, :test_name, :status, :result
def initialize(id, tester, test_suites_result, reporter)
@id = id
@tester = tester
@test_suites_result = test_suites_result
@reporter = reporter
@suite_name = nil
@test_script_path = nil
@test_name = nil
@interruptted = false
@status = "not running"
@result = WorkerResult.new
Expand All @@ -343,19 +363,14 @@ def interruptted?
@interruptted
end

def test_name
return nil if @test_script_path.nil?
@test_script_path.basename(".*").to_s
end

def run(queue)
succeeded = true

@result.measure do
@reporter.start_worker(self)
catch do |tag|
loop do
suite_name, test_script_path = queue.pop
suite_name, test_script_path, test_name = queue.pop
break if test_script_path.nil?

unless @suite_name == suite_name
Expand All @@ -364,6 +379,7 @@ def run(queue)
@reporter.start_suite(self)
end
@test_script_path = test_script_path
@test_name = test_name
runner = TestRunner.new(@tester, self)
succeeded = false unless runner.run

Expand Down Expand Up @@ -407,6 +423,7 @@ def finish_test(result)
@result.test_finished
@reporter.finish_test(self, result)
@test_script_path = nil
@test_name = nil
end
end

Expand Down Expand Up @@ -475,7 +492,9 @@ def run_test_suites(test_suites)
queue = Queue.new
test_suites.each do |suite_name, test_script_paths|
test_script_paths.each do |test_script_path|
queue << [suite_name, test_script_path]
test_name = test_script_path.basename(".*").to_s
next if @tester.exclude_test?(test_name)
queue << [suite_name, test_script_path, test_name]
@result.n_total_tests += 1
end
end
Expand Down

0 comments on commit 014486e

Please sign in to comment.