[Groonga-commit] groonga/groonga-test [master] Don't parse non JSON output as JSON

Back to archive index

null+****@clear***** null+****@clear*****
2012年 3月 6日 (火) 15:15:30 JST


Kouhei Sutou	2012-03-06 15:15:30 +0900 (Tue, 06 Mar 2012)

  New Revision: 730cebac6c25d25c6733d9ed62cf4d99d1ecf647

  Log:
    Don't parse non JSON output as JSON

  Modified files:
    bin/groonga-test

  Modified: bin/groonga-test (+13 -8)
===================================================================
--- bin/groonga-test    2012-03-06 15:14:48 +0900 (5d329ef)
+++ bin/groonga-test    2012-03-06 15:15:30 +0900 (cfd7f11)
@@ -150,15 +150,20 @@ class GroongaTester
         when :input
           normalized_result << content
         when :output
-          status, *values = JSON.parse(content)
-          normalized_status = normalize_status(status)
-          normalized_output_content = [normalized_status, *values]
-          normalized_output = JSON.generate(normalized_output_content)
-          if normalized_output.bytesize > @max_n_columns
-            normalized_output = JSON.pretty_generate(normalized_output_content)
+          case options[:format]
+          when "json"
+            status, *values = JSON.parse(content)
+            normalized_status = normalize_status(status)
+            normalized_output_content = [normalized_status, *values]
+            normalized_output = JSON.generate(normalized_output_content)
+            if normalized_output.bytesize > @max_n_columns
+              normalized_output = JSON.pretty_generate(normalized_output_content)
+            end
+            normalized_output.force_encoding("ASCII-8BIT")
+            normalized_result << "#{normalized_output}\n"
+          else
+            normalized_result << "#{content}\n".force_encoding("ASCII-8BIT")
           end
-          normalized_output.force_encoding("ASCII-8BIT")
-          normalized_result << "#{normalized_output}\n"
         when :error
           normalized_result << "#{content}\n".force_encoding("ASCII-8BIT")
         end




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