1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

test_etc.rb: relax comparisons

* test/etc/test_etc.rb (test_getgrgid, test_getgrnam): relax
  comparisons.  getgrent() does not return mem properly in some
  circumstances (possibly, involved in Open Directory on OSX).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-01-10 07:15:12 +00:00
parent 54f1d71ab2
commit 8ed8e0ba41

View file

@ -83,23 +83,25 @@ class TestEtc < Test::Unit::TestCase
groups = Hash.new {[]}
# on MacOSX, same entries are returned from /etc/group and Open
# Directory.
Etc.group {|s| groups[s.gid] |= [s]}
Etc.group {|s| groups[s.gid] |= [[s.name, s.gid]]}
groups.each_pair do |gid, s|
assert_include(s, Etc.getgrgid(gid))
g = Etc.getgrgid(gid)
assert_include(s, [g.name, g.gid])
end
s = groups[Process.egid]
unless s.empty?
assert_include(s, Etc.getgrgid)
g = Etc.getgrgid
assert_include(s, [g.name, g.gid])
end
end
def test_getgrnam
groups = {}
Etc.group do |s|
groups[s.name] ||= s unless /\A\+/ =~ s.name
groups[s.name] ||= s.gid unless /\A\+/ =~ s.name
end
groups.each_value do |s|
assert_equal(s, Etc.getgrnam(s.name))
groups.each_pair do |n, s|
assert_equal(s, Etc.getgrnam(n).gid)
end
end