Relax expectations of errors from getgrnam

The list of errors cited in 58bc97628c14933b73f13e0856d1a56e70e8b0e4
is not exhaustive and other errors may be raised by `getgrnam`.
Additionally, these errors are system dependent and may not be listed
on all platforms.
This commit is contained in:
Nobuyoshi Nakada 2025-01-22 18:19:54 +09:00
parent 9f78c727ea
commit 7070b1b196
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2025-01-22 10:58:34 +00:00

View File

@ -1693,12 +1693,7 @@ class TestProcess < Test::Unit::TestCase
if g = Etc.getgrgid(Process.gid)
assert_equal(Process.gid, Process::GID.from_name(g.name), g.name)
end
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
exc = assert_raise(ArgumentError, SystemCallError) 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)