Skip to content

Commit

Permalink
Skip thread safety tests if there are no users/groups to test with
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Jul 25, 2024
1 parent b4d4f19 commit a4ba4e6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/etc/test_etc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_getpwuid_thread_safety
uids = []
Etc.passwd {|s| uids << s.uid}
uids.uniq!
uids = uids[-MAX_THREADS..-1]
return unless uids = uids[-MAX_THREADS..-1]

uids.map do |uid|
Thread.new do
Expand All @@ -79,7 +79,7 @@ def test_getpwnam_thread_safety
(passwd[s.name] ||= []) << s.uid unless /\A\+/ =~ s.name
end
passwd = passwd.to_a.reject{|name, uids| uids.length > 1}
passwd = passwd[-MAX_THREADS..-1]
return unless passwd = passwd[-MAX_THREADS..-1]

passwd.map do |name, uids|
uid = uids.first
Expand Down Expand Up @@ -135,7 +135,7 @@ def test_getgrgid_thread_safety
gids = []
Etc.group {|g| gids << g.gid}
gids.uniq!
gids = gids[-MAX_THREADS..-1]
return unless gids = gids[-MAX_THREADS..-1]

gids.map do |gid|
Thread.new do
Expand All @@ -162,7 +162,7 @@ def test_getgrnam_thread_safety
(groups[s.name] ||= []) << s.gid unless /\A\+/ =~ s.name
end
groups = groups.to_a.reject{|name, gids| gids.length > 1}
groups = groups[-MAX_THREADS..-1]
return unless groups = groups[-MAX_THREADS..-1]

groups.map do |name, gids|
gid = gids.first
Expand Down

0 comments on commit a4ba4e6

Please sign in to comment.