[Groonga-commit] groonga/grntest at 76b2625 [master] Add --n-retries option

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Feb 19 09:30:31 JST 2018


Kouhei Sutou	2018-02-19 09:30:31 +0900 (Mon, 19 Feb 2018)

  New Revision: 76b2625b6fe13201fe0c6db093b0e119f7ef406a
  https://github.com/groonga/grntest/commit/76b2625b6fe13201fe0c6db093b0e119f7ef406a

  Message:
    Add --n-retries option

  Modified files:
    lib/grntest/tester.rb
    lib/grntest/worker.rb

  Modified: lib/grntest/tester.rb (+9 -1)
===================================================================
--- lib/grntest/tester.rb    2018-01-18 13:02:07 +0900 (0088c9f)
+++ lib/grntest/tester.rb    2018-02-19 09:30:31 +0900 (5070567)
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2016  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2012-2018  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
@@ -230,6 +230,12 @@ module Grntest
           tester.debug = debug
         end
 
+        parser.on("--n-retries=N", Integer,
+                  "Retry N times on failure",
+                  "(#{tester.n_retries}") do |n|
+          tester.n_retries = n
+        end
+
         parser.on("--version",
                   "Show version and exit") do
           puts(VERSION)
@@ -281,6 +287,7 @@ module Grntest
     attr_writer :debug
     attr_reader :test_patterns, :test_suite_patterns
     attr_reader :exclude_test_patterns, :exclude_test_suite_patterns
+    attr_accessor :n_retries
     def initialize
       @groonga = "groonga"
       @groonga_httpd = "groonga-httpd"
@@ -311,6 +318,7 @@ module Grntest
       initialize_memory_checkers
       @timeout = 5
       @read_timeout = 3
+      @n_retries = 0
     end
 
     def run(*targets)

  Modified: lib/grntest/worker.rb (+32 -7)
===================================================================
--- lib/grntest/worker.rb    2018-01-18 13:02:07 +0900 (27a1e71)
+++ lib/grntest/worker.rb    2018-02-19 09:30:31 +0900 (8a14dfd)
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2016  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2012-2018  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
@@ -99,12 +99,13 @@ module Grntest
               @suite_name = suite_name
               @reporter.on_suite_start(self)
             end
-            @test_script_path = test_script_path
-            @test_name = test_name
-            runner = TestRunner.new(@tester, self)
-            succeeded = false unless runner.run
+
+            unless run_test(test_script_path, test_name)
+              succeeded = false
+            end
 
             break if interruptted?
+
             if****@teste*****_on_failure? and @test_suites_result.have_failure?
               break
             end
@@ -162,8 +163,32 @@ module Grntest
     def on_test_finish(result)
       @result.on_test_finish
       @reporter.on_test_finish(self, result)
-      @test_script_path = nil
-      @test_name = nil
+    end
+
+    private
+    def run_test(test_script_path, test_name)
+      begin
+        @test_script_path = test_script_path
+        @test_name = test_name
+
+        n = -1
+        loop do
+          n += 1
+
+          runner = TestRunner.new(@tester, self)
+          return true if runner.run
+
+          if n < @tester.n_retries and not interruptted?
+            @test_suites_result.n_total_tests += 1
+            next
+          end
+
+          return false
+        end
+      ensure
+        @test_script_path = nil
+        @test_name = nil
+      end
     end
   end
 end
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180219/bda31003/attachment-0001.htm 



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