Kouhei Sutou
null+****@clear*****
Mon Jan 20 18:37:05 JST 2014
Kouhei Sutou 2014-01-20 18:37:05 +0900 (Mon, 20 Jan 2014) New Revision: 6cdc02f85d9fce2398567854e002479db6253511 https://github.com/droonga/drntest/commit/6cdc02f85d9fce2398567854e002479db6253511 Message: Add generic error handler Modified files: lib/drntest/response-normalizer.rb lib/drntest/test-results.rb lib/drntest/test-runner.rb Modified: lib/drntest/response-normalizer.rb (+2 -6) =================================================================== --- lib/drntest/response-normalizer.rb 2014-01-17 18:16:19 +0900 (494c30b) +++ lib/drntest/response-normalizer.rb 2014-01-20 18:37:05 +0900 (696c335) @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Droonga Project +# Copyright (C) 2013-2014 Droonga Project # # 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 @@ -37,11 +37,7 @@ module Drntest def normalize_body!(normalized_response) return unless groonga_command? - begin - normalize_groonga_command_response!(normalized_response[2]) - rescue StandardError => error - p error - end + normalize_groonga_command_response!(normalized_response[2]) end GROONGA_COMMANDS = [ Modified: lib/drntest/test-results.rb (+5 -2) =================================================================== --- lib/drntest/test-results.rb 2014-01-17 18:16:19 +0900 (e73b437) +++ lib/drntest/test-results.rb 2014-01-20 18:37:05 +0900 (5aaffc9) @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Droonga Project +# Copyright (C) 2013-2014 Droonga Project # # 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 @@ -15,15 +15,18 @@ module Drntest class TestResults - attr_accessor :name, :actuals, :expecteds + attr_accessor :name, :actuals, :expecteds, :errors def initialize(name) @name = name @actuals = [] @expecteds = [] + @errors = [] end def status + return :error unles****@error*****? + unles****@actua*****? unles****@expec*****? if @actuals == @expecteds Modified: lib/drntest/test-runner.rb (+21 -1) =================================================================== --- lib/drntest/test-runner.rb 2014-01-17 18:16:19 +0900 (5281523) +++ lib/drntest/test-runner.rb 2014-01-20 18:37:05 +0900 (7cba2b4) @@ -48,7 +48,11 @@ module Drntest results = TestResults.new(@target_path) executor = TestExecutor.new(@config, @target_path) - results.actuals = executor.execute + begin + results.actuals = executor.execute + rescue + results.errors << $! + end if expected_exist? results.expecteds = load_expected_responses end @@ -66,6 +70,9 @@ module Drntest when :not_checked puts "NOT CHECKED" output_actual_file(results.actuals) + when :error + puts "ERROR" + output_errors(results.errors) end results @@ -157,5 +164,18 @@ module Drntest file.close yield(file) end + + def output_errors(errors) + return if errors.empty? + n_digits = (Math.log10(errors.size) + 1).ceil + mark = "=" * 78 + errors.each_with_index do |error, i| + puts(mark) + formatted_nth = "%*d)" % [n_digits, i + 1] + puts("#{formatted_nth} #{error.message} (#{error.class})") + puts(error.backtrace) + puts(mark) + end + end end end -------------- next part -------------- HTML����������������������������...Download