[Groonga-commit] droonga/drntest at 6d2f082 [master] Remove needless TestResult class

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Nov 25 15:52:21 JST 2013


YUKI Hiroshi	2013-11-25 15:52:21 +0900 (Mon, 25 Nov 2013)

  New Revision: 6d2f08280940afa46f368789227f47f04d4c467e
  https://github.com/droonga/drntest/commit/6d2f08280940afa46f368789227f47f04d4c467e

  Message:
    Remove needless TestResult class

  Removed files:
    lib/drntest/test-result.rb
  Modified files:
    lib/drntest/test-results.rb
    lib/drntest/test-runner.rb

  Deleted: lib/drntest/test-result.rb (+0 -41) 100644
===================================================================
--- lib/drntest/test-result.rb    2013-11-25 15:07:16 +0900 (2d59be7)
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright (C) 2013  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
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-module Drntest
-  class TestResult
-    attr_accessor :expected, :actual
-
-    def initialize
-      @expected = nil
-      @actual = nil
-    end
-
-    def status
-      if @actual
-        if @expected
-          if @actual == @expected
-            :success
-          else
-            :failure
-          end
-        else
-          :not_checked
-        end
-      else
-        :no_response
-      end
-    end
-  end
-end

  Modified: lib/drntest/test-results.rb (+14 -27)
===================================================================
--- lib/drntest/test-results.rb    2013-11-25 15:07:16 +0900 (ffed13e)
+++ lib/drntest/test-results.rb    2013-11-25 15:52:21 +0900 (0222d65)
@@ -13,42 +13,29 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-require "drntest/test-result"
-
 module Drntest
   class TestResults
-    attr_accessor :name
+    attr_accessor :name, :actuals, :expecteds
 
     def initialize(name)
       @name = name
-      @results = []
-    end
-
-    def add(expected, actual)
-      result = TestResult.new
-      result.actual = actual
-      result.expected = expected
-      @results << result
+      @actuals = []
+      @expecteds = []
     end
 
     def status
-      @results.each do |result|
-        unless result.status == :success
-          return result.status
+      unless actuals.empty?
+        unless expecteds.empty?
+          if actuals == expecteds
+            :success
+          else
+            :failure
+          end
+        else
+          :not_checked
         end
-      end
-      :success
-    end
-
-    def expecteds
-      @results.collect do |result|
-        result.expected
-      end
-    end
-
-    def actuals
-      @results.collect do |result|
-        result.actual
+      else
+        :no_response
       end
     end
   end

  Modified: lib/drntest/test-runner.rb (+5 -12)
===================================================================
--- lib/drntest/test-runner.rb    2013-11-25 15:07:16 +0900 (880eb9d)
+++ lib/drntest/test-runner.rb    2013-11-25 15:52:21 +0900 (a9df2c8)
@@ -33,10 +33,12 @@ module Drntest
     def run
       print "#{target_path}: "
       results = TestResults.new(target_path.to_s)
-      each_request do |request, expected|
+      load_request_envelopes.each do |request|
         executor = Executor.new(tester, request)
-        actual = executor.execute
-        results.add(actual, expected)
+        results.actuals << executor.execute
+      end
+      if expected_exist?
+        results.expecteds = load_expected_responses
       end
 
       case results.status
@@ -58,15 +60,6 @@ module Drntest
     end
 
     private
-    def each_request(&block)
-      requests = load_request_envelopes
-      expecteds = load_expected_responses
-      requests.each_with_index do |request, index|
-        expected = expecteds[index]
-        yield request, expected
-      end
-    end
-
     def load_request_envelopes
       load_jsons(target_path)
     end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index