lib/grntest/tester.rb in grntest-1.1.1 vs lib/grntest/tester.rb in grntest-1.1.2

- old
+ new

@@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2012-2013 Kouhei Sutou <kou@clear-code.com> +# Copyright (C) 2012-2015 Kouhei Sutou <kou@clear-code.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. @@ -162,16 +162,34 @@ "Run groonga on gdb and use COMMAND as gdb", "(#{tester.default_gdb})") do |command| tester.gdb = command || tester.default_gdb end + parser.on("--valgrind[=COMMAND]", + "Run groonga on valgrind and use COMMAND as valgrind", + "(#{tester.default_valgrind})") do |command| + tester.valgrind = command || tester.default_valgrind + end + + parser.on("--[no-]valgrind-gen-suppressions", + "Generate suppressions for Valgrind", + "(#{tester.valgrind_gen_suppressions?})") do |boolean| + tester.valgrind_gen_suppressions = boolean + end + parser.on("--[no-]keep-database", "Keep used database for debug after test is finished", "(#{tester.keep_database?})") do |boolean| tester.keep_database = boolean end + parser.on("--[no-]stop-on-failure", + "Stop immediately on the first non success test", + "(#{tester.stop_on_failure?})") do |boolean| + tester.stop_on_failure = boolean + end + parser.on("--output=OUTPUT", "Output to OUTPUT", "(stdout)") do |output| tester.output = File.open(output, "w:ascii-8bit") end @@ -204,11 +222,14 @@ attr_accessor :interface, :output_type, :testee attr_accessor :base_directory, :database_path, :diff, :diff_options attr_accessor :n_workers attr_accessor :output attr_accessor :gdb, :default_gdb + attr_accessor :valgrind, :default_valgrind + attr_writer :valgrind_gen_suppressions attr_writer :reporter, :keep_database, :use_color + attr_writer :stop_on_failure attr_reader :test_patterns, :test_suite_patterns attr_reader :exclude_test_patterns, :exclude_test_suite_patterns def initialize @groonga = "groonga" @groonga_httpd = "groonga-httpd" @@ -221,16 +242,18 @@ @reporter = nil @n_workers = 1 @output = $stdout @keep_database = false @use_color = nil + @stop_on_failure = false @test_patterns = [] @test_suite_patterns = [] @exclude_test_patterns = [] @exclude_test_suite_patterns = [] detect_suitable_diff initialize_debuggers + initialize_memory_checkers end def run(*targets) succeeded = true return succeeded if targets.empty? @@ -260,10 +283,18 @@ @use_color = guess_color_availability end @use_color end + def stop_on_failure? + @stop_on_failure + end + + def valgrind_gen_suppressions? + @valgrind_gen_suppressions + end + def target_test?(test_name) selected_test?(test_name) and not excluded_test?(test_name) end def selected_test?(test_name) @@ -339,9 +370,15 @@ end def initialize_debuggers @gdb = nil @default_gdb = "gdb" + end + + def initialize_memory_checkers + @vagrind = nil + @default_valgrind = "valgrind" + @vagrind_gen_suppressions = false end def command_exist?(name) ENV["PATH"].split(File::PATH_SEPARATOR).each do |path| absolute_path = File.join(path, name)