null+****@clear*****
null+****@clear*****
2011年 12月 27日 (火) 15:50:08 JST
Yoji SHIDARA 2011-12-27 15:50:08 +0900 (Tue, 27 Dec 2011)
New Revision: f86452bf7de3e7dbf2893646e8ebe087cc904dac
Log:
[test] show hexdump on MessagePack::UnpackError
Modified files:
test/unit/lib/ruby/groonga-http-test-utils.rb
Modified: test/unit/lib/ruby/groonga-http-test-utils.rb (+8 -1)
===================================================================
--- test/unit/lib/ruby/groonga-http-test-utils.rb 2011-12-27 13:58:04 +0900 (105586f)
+++ test/unit/lib/ruby/groonga-http-test-utils.rb 2011-12-27 15:50:08 +0900 (58b331b)
@@ -265,8 +265,15 @@ module GroongaHTTPTestUtils
begin
actual = ::MessagePack.unpack(response.body)
rescue ::MessagePack::UnpackError => e
+ hexdump = response.body.bytes.each_slice(16).map{ |bytes|
+ bytes.each_slice(8).map {|half|
+ half.map{|byte| '%02x' % byte}.join(' ')
+ }.join(' ').ljust(3*16+1) + ' ' + \
+ bytes.map{|byte| (0x20..0x7e).include?(byte) ? byte.chr : '.'}.join
+ }.join("\n")
+
raise "MessagePack UnpackError #{e.message}\nMessagePack is ...\n" \
- "---\n#{response.body}\n---"
+ "---\n#{hexdump}\n---"
end
normalize_structured_response(actual)
when "text/html"