Skip to content

Commit

Permalink
Add --test-suite
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 11, 2012
1 parent ca4e97e commit 2c5e972
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions lib/groonga/tester.rb
Expand Up @@ -123,6 +123,13 @@ def create_option_parser(tester, tag)
tester.test_patterns << parse_name_or_pattern(name)
end

parser.on("--test-suite=NAME",
"Run only test suite that name is NAME",
"If NAME is /.../, NAME is treated as regular expression",
"This option can be used multiple times") do |name|
tester.test_suite_patterns << parse_name_or_pattern(name)
end

parser.on("--exclude-test=NAME",
"Exclude test that name is NAME",
"If NAME is /.../, NAME is treated as regular expression",
Expand Down Expand Up @@ -191,7 +198,7 @@ def parse_name_or_pattern(name)
attr_accessor :output
attr_accessor :gdb, :default_gdb
attr_writer :reporter, :keep_database, :use_color
attr_reader :test_patterns
attr_reader :test_patterns, :test_suite_patterns
attr_reader :exclude_test_patterns, :exclude_test_suite_patterns
def initialize
@groonga = "groonga"
Expand All @@ -206,6 +213,7 @@ def initialize
@keep_database = false
@use_color = nil
@test_patterns = []
@test_suite_patterns = []
@exclude_test_patterns = []
@exclude_test_suite_patterns = []
detect_suitable_diff
Expand Down Expand Up @@ -259,6 +267,17 @@ def exclude_test?(test_name)
end
end

def target_test_suite?(test_suite_name)
selected_test_suite?(test_suite_name) and
not exclude_test_suite?(test_suite_name)
end

def selected_test_suite?(test_suite_name)
@test_suite_patterns.all? do |pattern|
pattern === test_suite_name
end
end

def exclude_test_suite?(test_suite_name)
@exclude_test_suite_patterns.any? do |pattern|
pattern === test_suite_name
Expand Down Expand Up @@ -528,7 +547,7 @@ def run(test_suites)
def run_test_suites(test_suites)
queue = Queue.new
test_suites.each do |suite_name, test_script_paths|
next if @tester.exclude_test_suite?(suite_name)
next unless @tester.target_test_suite?(suite_name)
test_script_paths.each do |test_script_path|
test_name = test_script_path.basename(".*").to_s
next unless @tester.target_test?(test_name)
Expand Down

0 comments on commit 2c5e972

Please sign in to comment.