ruby-changes:61422
From: Yusuke <ko1@a...>
Date: Sat, 30 May 2020 00:24:25 +0900 (JST)
Subject: [ruby-changes:61422] 58bc97628c (master): test/ruby/test_process.rb: GID.from_name may raise Errno:ESRCH
https://git.ruby-lang.org/ruby.git/commit/?id=58bc97628c From 58bc97628c14933b73f13e0856d1a56e70e8b0e4 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Sat, 30 May 2020 00:13:56 +0900 Subject: test/ruby/test_process.rb: GID.from_name may raise Errno:ESRCH getgrnam(3) says: ``` ERRORS 0 or ENOENT or ESRCH or EBADF or EPERM or ... The given name or gid was not found. ``` Process::GID.from_name raises an ArgumentError for 0, but Errno::ESRCH for ESRCH. Actually, WSL 2 raises Errno::ESRCH. This change accepts all exceptions above. diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 9d0ee67..f88324f 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1621,9 +1621,15 @@ class TestProcess < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L1621 if g = Etc.getgrgid(Process.gid) assert_equal(Process.gid, Process::GID.from_name(g.name), g.name) end - assert_raise_with_message(ArgumentError, /\u{4e0d 5b58 5728}/) { - Process::GID.from_name("\u{4e0d 5b58 5728}") - } + expected_excs = [ArgumentError] + expected_excs << Errno::ENOENT if defined?(Errno::ENOENT) + expected_excs << Errno::ESRCH if defined?(Errno::ESRCH) # WSL 2 actually raises Errno::ESRCH + expected_excs << Errno::EBADF if defined?(Errno::EBADF) + expected_excs << Errno::EPERM if defined?(Errno::EPERM) + exc = assert_raise(*expected_excs) do + Process::GID.from_name("\u{4e0d 5b58 5728}") # fu son zai ("absent" in Kanji) + end + assert_match(/\u{4e0d 5b58 5728}/, exc.message) if exc.is_a?(ArgumentError) end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/