Skip to content

Commit

Permalink
test_etc.rb: remove implicit assumption
Browse files Browse the repository at this point in the history
* test/etc/test_etc.rb (TestEtc#test_getpwuid): remove implicit
  assumption, that getpwuid() would return the first entry in the
  order of getpw(), for shared UID.  apparently it is not true on
  MacOS X 10.8.  [ruby-core:46975][Bug ruby#6831]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Aug 5, 2012
1 parent e57da61 commit 800d9a7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions test/etc/test_etc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,18 @@ def test_passwd
end

def test_getpwuid
passwd = {}
Etc.passwd {|s| passwd[s.uid] ||= s }
passwd.each_value do |s|
assert_equal(s, Etc.getpwuid(s.uid))
assert_equal(s, Etc.getpwuid) if Process.euid == s.uid
# password database is not unique on UID, and which entry will be
# returned by getpwuid() is not specified.
passwd = Hash.new {[]}
# on MacOSX, same entries are returned from /etc/passwd and Open
# Directory.
Etc.passwd {|s| passwd[s.uid] |= [s]}
passwd.each_pair do |uid, s|
assert_include(s, Etc.getpwuid(uid))
end
s = passwd[Process.euid]
if s
assert_include(s, Etc.getpwuid)
end
end

Expand Down

0 comments on commit 800d9a7

Please sign in to comment.