ruby-changes:31745
From: tmm1 <ko1@a...>
Date: Sun, 24 Nov 2013 09:22:26 +0900 (JST)
Subject: [ruby-changes:31745] tmm1:r43824 (trunk): * ext/objspace/objspace_dump.c: test fixes and win32 compatibility
tmm1 2013-11-24 09:22:19 +0900 (Sun, 24 Nov 2013) New Revision: 43824 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43824 Log: * ext/objspace/objspace_dump.c: test fixes and win32 compatibility Modified files: trunk/ChangeLog trunk/ext/objspace/objspace_dump.c trunk/test/objspace/test_objspace.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 43823) +++ ChangeLog (revision 43824) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Nov 24 09:18:06 2013 Aman Gupta <ruby@t...> + + * ext/objspace/objspace_dump.c (dump_object): Use PRIuSIZE to print + size_t for better win32 compatibility. + * test/objspace/test_objspace.rb (test_dump_all): Hold reference to + test string to avoid failure due to GC. Reduce size of failure message + using grep(/TEST STRING/). + Sat Nov 23 13:38:00 2013 Kyle Stevens <kstevens715@g...> * lib/csv.rb: If skip_lines is set to a String, convert it to a Regexp Index: ext/objspace/objspace_dump.c =================================================================== --- ext/objspace/objspace_dump.c (revision 43823) +++ ext/objspace/objspace_dump.c (revision 43824) @@ -240,11 +240,11 @@ dump_object(VALUE obj, struct dump_confi https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace_dump.c#L240 dump_append(dc, ", \"file\":\"%s\", \"line\":%lu", ainfo->path, ainfo->line); if (RTEST(ainfo->mid)) dump_append(dc, ", \"method\":\"%s\"", rb_id2name(SYM2ID(ainfo->mid))); - dump_append(dc, ", \"generation\":%zu", ainfo->generation); + dump_append(dc, ", \"generation\":%"PRIuSIZE, ainfo->generation); } if ((memsize = rb_obj_memsize_of(obj)) > 0) - dump_append(dc, ", \"memsize\":%zu", memsize); + dump_append(dc, ", \"memsize\":%"PRIuSIZE, memsize); dump_append(dc, "}\n"); } Index: test/objspace/test_objspace.rb =================================================================== --- test/objspace/test_objspace.rb (revision 43823) +++ test/objspace/test_objspace.rb (revision 43824) @@ -239,30 +239,33 @@ class TestObjSpace < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/objspace/test_objspace.rb#L239 end def test_dump_all - entry = /"value":"TEST STRING", "encoding":"UTF-8", "file":"-", "line":4, "method":"dump_my_heap_please"/ - assert_in_out_err(%w[-robjspace], <<-'end;', entry) + entry = /"bytesize":11, "value":"TEST STRING", "encoding":"UTF-8", "file":"-", "line":4, "method":"dump_my_heap_please", "generation":/ + + assert_in_out_err(%w[-robjspace], <<-'end;') do |output, error| def dump_my_heap_please ObjectSpace.trace_object_allocations_start GC.start - "TEST STRING".force_encoding("UTF-8") + str = "TEST STRING".force_encoding("UTF-8") ObjectSpace.dump_all(output: :stdout) end dump_my_heap_please end; + assert_match(entry, output.grep(/TEST STRING/).join("\n")) + end assert_in_out_err(%w[-robjspace], <<-'end;') do |(output), (error)| def dump_my_heap_please ObjectSpace.trace_object_allocations_start GC.start - "TEST STRING".force_encoding("UTF-8") + str = "TEST STRING".force_encoding("UTF-8") ObjectSpace.dump_all().path end puts dump_my_heap_please end; skip if /is not supported/ =~ error - assert_match(entry, File.read(output)) + assert_match(entry, File.readlines(output).grep(/TEST STRING/).join("\n")) File.unlink(output) end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/