[Groonga-commit] groonga/groonga-test [master] Show summary at the end

Back to archive index

null+****@clear***** null+****@clear*****
2012年 3月 2日 (金) 17:29:47 JST


Kouhei Sutou	2012-03-02 17:29:47 +0900 (Fri, 02 Mar 2012)

  New Revision: 4389443273bb711886f543d9ef57fa5ca1095fb7

  Log:
    Show summary at the end

  Modified files:
    bin/groonga-test

  Modified: bin/groonga-test (+16 -2)
===================================================================
--- bin/groonga-test    2012-03-02 17:25:58 +0900 (a924054)
+++ bin/groonga-test    2012-03-02 17:29:47 +0900 (3edae4a)
@@ -120,6 +120,8 @@ class GroongaTester
       @term_width = guess_term_width
       @current_column = 0
       @output = STDOUT
+      @n_tests = 0
+      @n_passed_tests = 0
       @failed_tests = []
     end
 
@@ -134,6 +136,7 @@ class GroongaTester
 
     def pass_test
       report_test_result("pass")
+      @n_passed_tests += 1
     end
 
     def fail_test(expected, actual)
@@ -150,9 +153,20 @@ class GroongaTester
     end
 
     def finish_test
+      @n_tests += 1
     end
 
     def finish
+      puts
+      puts("#{@n_tests} tests, " +
+           "#{@n_passed_tests} passes, " +
+           "#{@failed_tests.size} failures.")
+      if @n_tests.zero?
+        pass_ratio = 0
+      else
+        pass_ratio = @n_passed_tests / @n_tests.to_f
+      end
+      puts("%.2g%% passed." % pass_ratio)
     end
 
     private
@@ -161,9 +175,9 @@ class GroongaTester
       @output.print(message)
     end
 
-    def puts(message)
+    def puts(*messages)
       @current_column = 0
-      @output.puts(message)
+      @output.puts(*messages)
     end
 
     def report_test_result(label)




Groonga-commit メーリングリストの案内
Back to archive index