[Groonga-commit] groonga/grntest at a4e3f7b [master] Add --timeout

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Apr 27 15:31:53 JST 2016


Kouhei Sutou	2016-04-27 15:31:53 +0900 (Wed, 27 Apr 2016)

  New Revision: a4e3f7b3f29ea840956fd961b9e96bb37fea6a50
  https://github.com/groonga/grntest/commit/a4e3f7b3f29ea840956fd961b9e96bb37fea6a50

  Message:
    Add --timeout

  Modified files:
    lib/grntest/test-runner.rb
    lib/grntest/tester.rb

  Modified: lib/grntest/test-runner.rb (+9 -1)
===================================================================
--- lib/grntest/test-runner.rb    2016-04-26 17:03:53 +0900 (7464392)
+++ lib/grntest/test-runner.rb    2016-04-27 15:31:53 +0900 (50cc099)
@@ -16,6 +16,7 @@
 require "pathname"
 require "fileutils"
 require "tempfile"
+require "timeout"
 
 require "json"
 
@@ -135,7 +136,14 @@ module Grntest
           @tester.groonga_suggest_create_dataset
         context.output_type =****@teste*****_type
         run_groonga(context) do |executor|
-          executor.execute(test_script_path)
+          begin
+            Timeout.timeout(@tester.timeout) do
+              executor.execute(test_script_path)
+            end
+          rescue Timeout::Error
+            message = "# error: timeout (#{@tester.timeout}s)"
+            context.result << [:error, message, {}]
+          end
         end
         check_memory_leak(context)
         result.omitted = context.omitted?

  Modified: lib/grntest/tester.rb (+8 -0)
===================================================================
--- lib/grntest/tester.rb    2016-04-26 17:03:53 +0900 (0172fa1)
+++ lib/grntest/tester.rb    2016-04-27 15:31:53 +0900 (99fd72d)
@@ -206,6 +206,12 @@ module Grntest
           tester.use_color = use_color
         end
 
+        parser.on("--timeout=SECOND", Float,
+                  "Timeout for each test",
+                  "(#{tester.timeout})") do |timeout|
+          tester.timeout = timeout
+        end
+
         parser.on("--version",
                   "Show version and exit") do
           puts(VERSION)
@@ -247,6 +253,7 @@ module Grntest
     attr_accessor :output
     attr_accessor :gdb, :default_gdb
     attr_accessor :valgrind, :default_valgrind
+    attr_accessor :timeout
     attr_writer :valgrind_gen_suppressions
     attr_writer :reporter, :keep_database, :use_color
     attr_writer :stop_on_failure
@@ -279,6 +286,7 @@ module Grntest
       detect_suitable_diff
       initialize_debuggers
       initialize_memory_checkers
+      @timeout = 5
     end
 
     def run(*targets)
-------------- next part --------------
HTML����������������������������...
Télécharger 



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