ruby-changes:59051
From: Yusuke <ko1@a...>
Date: Tue, 3 Dec 2019 17:26:28 +0900 (JST)
Subject: [ruby-changes:59051] 409e4ab740 (master): tool/lib/test/unit/parallel.rb: fail explicitly when failing to get io
https://git.ruby-lang.org/ruby.git/commit/?id=409e4ab740 From 409e4ab740de3852c3667217bcf41b55040f638f Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Tue, 3 Dec 2019 17:05:07 +0900 Subject: tool/lib/test/unit/parallel.rb: fail explicitly when failing to get io `(ulimit -n 30; make test-tool)` fails with unexplicit message: "undefined method `write' for nil:NilClass" due to lack of stdout. This change makes it explicit. [Bug #5577] diff --git a/tool/lib/test/unit/parallel.rb b/tool/lib/test/unit/parallel.rb index 3fe7629..bf69b81 100644 --- a/tool/lib/test/unit/parallel.rb +++ b/tool/lib/test/unit/parallel.rb @@ -145,9 +145,13 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/parallel.rb#L145 rescue Exception => e begin trace = e.backtrace || ['unknown method'] - err = ["#{trace.shift}: #{e.message} (#{e.class})"] + trace.map{|t| t.prepend("\t") } + err = ["#{trace.shift}: #{e.message} (#{e.class})"] + trace.map{|t| "\t" + t } - _report "bye", Marshal.dump(err.join("\n")) + if @stdout + _report "bye", Marshal.dump(err.join("\n")) + else + raise "failed to report a failure due to lack of @stdout" + end rescue Errno::EPIPE;end exit ensure diff --git a/tool/test/testunit/test_parallel.rb b/tool/test/testunit/test_parallel.rb index 24e1f89..60fc207 100644 --- a/tool/test/testunit/test_parallel.rb +++ b/tool/test/testunit/test_parallel.rb @@ -98,6 +98,7 @@ module TestParallel https://github.com/ruby/ruby/blob/trunk/tool/test/testunit/test_parallel.rb#L98 while buf = @worker_out.gets break if /^p (.+?)$/ =~ buf end + assert_not_nil($1, "'p' was not found") assert_match(/TestA#test_nothing_test = \d+\.\d+ s = \.\n/, $1.chomp.unpack("m")[0]) end end @@ -108,6 +109,7 @@ module TestParallel https://github.com/ruby/ruby/blob/trunk/tool/test/testunit/test_parallel.rb#L109 while buf = @worker_out.gets break if /^done (.+?)$/ =~ buf end + assert_not_nil($1, "'done' was not found") result = Marshal.load($1.chomp.unpack("m")[0]) assert_equal(5, result[0]) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/