From dc0c04764fbd65c28337c37f70cbf71c0cadffe1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 5 Aug 2019 11:55:21 +0900 Subject: [PATCH] Refined assertion messages --- test/ruby/test_process.rb | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index b96acb1373..1d20c11ecc 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -246,18 +246,16 @@ class TestProcess < Test::Unit::TestCase assert_raise(ArgumentError) do system(RUBY, '-e', 'exit', 'rlimit_bogus'.to_sym => 123) end - assert_separately([],"#{<<-"begin;"}\n#{<<~'end;'}") + assert_separately([],"#{<<~"begin;"}\n#{<<~'end;'}", 'rlimit_cpu'.to_sym => 3600) BUG = "[ruby-core:82033] [Bug #13744]" - RUBY = "#{RUBY}" begin; - assert(system("#{RUBY}", "-e", - "exit([3600,3600] == Process.getrlimit(:CPU))", - 'rlimit_cpu'.to_sym => 3600), BUG) - assert_raise(ArgumentError, BUG) do - system("#{RUBY}", '-e', 'exit', :rlimit_bogus => 123) - end + assert_equal([3600,3600], Process.getrlimit(:CPU), BUG) end; + assert_raise_with_message(ArgumentError, /bogus/) do + system(RUBY, '-e', 'exit', :rlimit_bogus => 123) + end + assert_raise_with_message(ArgumentError, /rlimit_cpu/) { system(RUBY, '-e', 'exit', "rlimit_cpu\0".to_sym => 3600) } @@ -636,7 +634,7 @@ class TestProcess < Test::Unit::TestCase rescue NotImplementedError return end - assert(FileTest.pipe?("fifo"), "should be pipe") + assert_file.pipe?("fifo") t1 = Thread.new { system(*ECHO["output to fifo"], :out=>"fifo") } @@ -1635,7 +1633,7 @@ class TestProcess < Test::Unit::TestCase w.puts end Process.wait pid - assert sig_r.wait_readable(5), 'self-pipe not readable' + assert_send [sig_r, :wait_readable, 5], 'self-pipe not readable' end if RubyVM::MJIT.enabled? # checking -DMJIT_FORCE_ENABLE. It may trigger extra SIGCHLD. assert_equal [true], signal_received.uniq, "[ruby-core:19744]" @@ -2260,7 +2258,7 @@ EOS th = Process.detach(pid) assert_equal pid, th.pid status = th.value - assert status.success?, status.inspect + assert_predicate status, :success? end if defined?(fork) def test_kill_at_spawn_failure