Navigation Menu

Skip to content

Commit

Permalink
Add --test
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 11, 2012
1 parent 6d7784c commit ca4e97e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/groonga/tester.rb
Expand Up @@ -116,6 +116,13 @@ def create_option_parser(tester, tag)
tester.reporter = reporter
end

parser.on("--test=NAME",
"Run only test that name is NAME",
"If NAME is /.../, NAME is treated as regular expression",
"This option can be used multiple times") do |name|
tester.test_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 @@ -184,6 +191,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 :exclude_test_patterns, :exclude_test_suite_patterns
def initialize
@groonga = "groonga"
Expand All @@ -197,6 +205,7 @@ def initialize
@output = $stdout
@keep_database = false
@use_color = nil
@test_patterns = []
@exclude_test_patterns = []
@exclude_test_suite_patterns = []
detect_suitable_diff
Expand Down Expand Up @@ -234,6 +243,16 @@ def use_color?
@use_color
end

def target_test?(test_name)
selected_test?(test_name) and not exclude_test?(test_name)
end

def selected_test?(test_name)
@test_patterns.all? do |pattern|
pattern === test_name
end
end

def exclude_test?(test_name)
@exclude_test_patterns.any? do |pattern|
pattern === test_name
Expand Down Expand Up @@ -512,7 +531,7 @@ def run_test_suites(test_suites)
next if @tester.exclude_test_suite?(suite_name)
test_script_paths.each do |test_script_path|
test_name = test_script_path.basename(".*").to_s
next if @tester.exclude_test?(test_name)
next unless @tester.target_test?(test_name)
queue << [suite_name, test_script_path, test_name]
@result.n_total_tests += 1
end
Expand Down

0 comments on commit ca4e97e

Please sign in to comment.