ruby-changes:20052
From: akr <ko1@a...>
Date: Wed, 15 Jun 2011 12:37:40 +0900 (JST)
Subject: [ruby-changes:20052] akr:r32099 (trunk): * test/ruby/test_io.rb (test_copy_stream_socket): wait a child process
akr 2011-06-15 12:36:57 +0900 (Wed, 15 Jun 2011) New Revision: 32099 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32099 Log: * test/ruby/test_io.rb (test_copy_stream_socket): wait a child process before SIGUSR1 handler is removed. * test/pathname/test_pathname.rb (define_assertion): use line number for test method names. Modified files: trunk/ChangeLog trunk/test/pathname/test_pathname.rb trunk/test/ruby/test_io.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 32098) +++ ChangeLog (revision 32099) @@ -1,3 +1,11 @@ +Wed Jun 15 12:35:11 2011 Tanaka Akira <akr@f...> + + * test/ruby/test_io.rb (test_copy_stream_socket): wait a child process + before SIGUSR1 handler is removed. + + * test/pathname/test_pathname.rb (define_assertion): use line number + for test method names. + Wed Jun 15 10:37:43 2011 NARUSE, Yui <naruse@r...> * file.c (rb_stat_rdev): use DEVT2NUM. Index: test/ruby/test_io.rb =================================================================== --- test/ruby/test_io.rb (revision 32098) +++ test/ruby/test_io.rb (revision 32099) @@ -82,8 +82,8 @@ @usr1_rcvd = 0 trap(:USR1) { @usr1_rcvd += 1 } yield - ensure - trap(:USR1, "DEFAULT") + ensure + trap(:USR1, "DEFAULT") end def test_pipe @@ -610,19 +610,22 @@ end trapping_usr1 do nr = 10 - pid = fork do + begin + pid = fork do + s1.close + IO.select([s2]) + Process.kill(:USR1, Process.ppid) + s2.read + end + s2.close + nr.times do + assert_equal megacontent.bytesize, IO.copy_stream("megasrc", s1) + end + assert_equal(1, @usr1_rcvd) s1.close - IO.select([s2]) - Process.kill(:USR1, Process.ppid) - s2.read + ensure + _, status = Process.waitpid2(pid) if pid end - s2.close - nr.times do - assert_equal megacontent.bytesize, IO.copy_stream("megasrc", s1) - end - assert_equal(1, @usr1_rcvd) - s1.close - _, status = Process.waitpid2(pid) assert status.success?, status.inspect end } Index: test/pathname/test_pathname.rb =================================================================== --- test/pathname/test_pathname.rb (revision 32098) +++ test/pathname/test_pathname.rb (revision 32099) @@ -10,15 +10,21 @@ require_relative '../ruby/envutil' class TestPathname < Test::Unit::TestCase - def self.define_assertion(name, &block) - @defassert_num ||= {} - @defassert_num[name] ||= 0 - @defassert_num[name] += 1 - define_method("test_#{name}_#{@defassert_num[name]}", &block) + def self.define_assertion(name, linenum, &block) + name = "test_#{name}_#{linenum}" + define_method(name, &block) end + def self.get_linenum + if /:(\d+):/ =~ caller[1] + $1.to_i + else + nil + end + end + def self.defassert(name, result, *args) - define_assertion(name) { + define_assertion(name, get_linenum) { mesg = "#{name}(#{args.map {|a| a.inspect }.join(', ')})" assert_nothing_raised(mesg) { assert_equal(result, self.send(name, *args), mesg) @@ -26,6 +32,13 @@ } end + def self.defassert_raise(name, exc, *args) + define_assertion(name, get_linenum) { + message = "#{name}(#{args.map {|a| a.inspect }.join(', ')})" + assert_raise(exc, message) { self.send(name, *args) } + } + end + DOSISH = File::ALT_SEPARATOR != nil DOSISH_DRIVE_LETTER = File.dirname("A:") == "A:." DOSISH_UNC = File.dirname("//") == "//" @@ -294,13 +307,6 @@ defassert(:relative_path_from, "a", "a", "b/..") defassert(:relative_path_from, "b/c", "b/c", "b/..") - def self.defassert_raise(name, exc, *args) - define_assertion(name) { - message = "#{name}(#{args.map {|a| a.inspect }.join(', ')})" - assert_raise(exc, message) { self.send(name, *args) } - } - end - defassert_raise(:relative_path_from, ArgumentError, "/", ".") defassert_raise(:relative_path_from, ArgumentError, ".", "/") defassert_raise(:relative_path_from, ArgumentError, "a", "..") -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/