[前][次][番号順一覧][スレッド一覧]

ruby-changes:24574

From: nobu <ko1@a...>
Date: Sun, 5 Aug 2012 14:17:46 +0900 (JST)
Subject: [ruby-changes:24574] nobu:r36625 (trunk): test_etc.rb: remove implicit assumption

nobu	2012-08-05 14:14:35 +0900 (Sun, 05 Aug 2012)

  New Revision: 36625

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36625

  Log:
    test_etc.rb: remove implicit assumption
    
    * 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 #6831]

  Modified files:
    trunk/test/etc/test_etc.rb

Index: test/etc/test_etc.rb
===================================================================
--- test/etc/test_etc.rb	(revision 36624)
+++ test/etc/test_etc.rb	(revision 36625)
@@ -28,12 +28,19 @@
   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
 
   def test_getpwnam

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]