Rev 3644: Isolate group sticky bit related tests. in http://bazaar.launchpad.net/%7Ebzr/bzr/osx_tests_fix

Vincent Ladeuil v.ladeuil+lp at free.fr
Sun Aug 31 20:20:17 BST 2008


At http://bazaar.launchpad.net/%7Ebzr/bzr/osx_tests_fix

------------------------------------------------------------
revno: 3644
revision-id: v.ladeuil+lp at free.fr-20080831191908-l4ke1ttjj61sit76
parent: v.ladeuil+lp at free.fr-20080831190607-m5kmikqnn4ssyt0f
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: osx_tests_fix
timestamp: Sun 2008-08-31 21:19:08 +0200
message:
  Isolate group sticky bit related tests.
  
  * bzrlib/tests/test_permissions.py:
  (TestPermissions.test_new_files_group_sticky_bit): Spliited out
  from test_new_files for better defect localization.
  
  * bzrlib/tests/branch_implementations/test_permissions.py:
  (TestPermissions.test_new_branch_group_sticky_bit): Splitted out
  from test_new_branch for better defect localization.
modified:
  bzrlib/tests/branch_implementations/test_permissions.py test_permissions.py-20060210110243-245c01403bf0fde6
  bzrlib/tests/test_permissions.py test_permissions.py-20051215004520-ccf475789c80e80c
-------------- next part --------------
=== modified file 'bzrlib/tests/branch_implementations/test_permissions.py'
--- a/bzrlib/tests/branch_implementations/test_permissions.py	2008-08-31 19:06:07 +0000
+++ b/bzrlib/tests/branch_implementations/test_permissions.py	2008-08-31 19:19:08 +0000
@@ -64,11 +64,6 @@
                                           ' permission logic')
         if sys.platform == 'win32':
             raise tests.TestNotApplicable('chmod has no effect on win32')
-        elif sys.platform == 'darwin':
-            # OS X creates temp dirs with the 'wheel' group, which users are
-            # not likely to be in, and this prevents us from setting the sgid
-            # bit
-            os.chown(self.test_dir, os.getuid(), os.getgid())
         # also, these are BzrBranch format specific things..
         os.mkdir('a')
         mode = stat.S_IMODE(os.stat('a').st_mode)
@@ -79,6 +74,31 @@
         self.assertEqualMode(mode, b.control_files._dir_mode)
         self.assertEqualMode(mode & ~07111, b.control_files._file_mode)
 
+        os.mkdir('d')
+        os.chmod('d', 0700)
+        b = self.make_branch('d')
+        self.assertEqualMode(0700, b.bzrdir._get_dir_mode())
+        self.assertEqualMode(0600, b.bzrdir._get_file_mode())
+        self.assertEqualMode(0700, b.control_files._dir_mode)
+        self.assertEqualMode(0600, b.control_files._file_mode)
+        check_mode_r(self, 'd/.bzr', 00600, 00700)
+
+    def test_new_branch_group_sticky_bit(self):
+        if isinstance(self.branch_format, RemoteBranchFormat):
+            # Remote branch format have no permission logic in them; there's
+            # nothing to test here.
+            raise tests.TestNotApplicable('Remote branches have no'
+                                          ' permission logic')
+        if sys.platform == 'win32':
+            raise tests.TestNotApplicable('chmod has no effect on win32')
+        elif sys.platform == 'darwin':
+            # OS X creates temp dirs with the 'wheel' group, which users are
+            # not likely to be in, and this prevents us from setting the sgid
+            # bit
+            os.chown(self.test_dir, os.getuid(), os.getgid())
+        # also, these are BzrBranch format specific things..
+        t = self.make_branch_and_tree('.')
+        b = t.branch
         os.mkdir('b')
         os.chmod('b', 02777)
         b = self.make_branch('b')
@@ -97,15 +117,6 @@
         self.assertEqualMode(00640, b.control_files._file_mode)
         check_mode_r(self, 'c/.bzr', 00640, 02750)
 
-        os.mkdir('d')
-        os.chmod('d', 0700)
-        b = self.make_branch('d')
-        self.assertEqualMode(0700, b.bzrdir._get_dir_mode())
-        self.assertEqualMode(0600, b.bzrdir._get_file_mode())
-        self.assertEqualMode(0700, b.control_files._dir_mode)
-        self.assertEqualMode(0600, b.control_files._file_mode)
-        check_mode_r(self, 'd/.bzr', 00600, 00700)
-
     def test_mode_0(self):
         """Test when a transport returns null permissions for .bzr"""
         if isinstance(self.branch_format, RemoteBranchFormat):

=== modified file 'bzrlib/tests/test_permissions.py'
--- a/bzrlib/tests/test_permissions.py	2008-08-31 19:06:07 +0000
+++ b/bzrlib/tests/test_permissions.py	2008-08-31 19:19:08 +0000
@@ -29,7 +29,7 @@
 # TODO: jam 20051215 Currently the default behavior for 'bzr branch' is just 
 #                    defined by the local umask. This isn't terrible, is it
 #                    the truly desired behavior?
- 
+
 import os
 import sys
 import stat
@@ -84,11 +84,6 @@
     def test_new_files(self):
         if sys.platform == 'win32':
             raise TestSkipped('chmod has no effect on win32')
-        elif sys.platform == 'darwin':
-            # OS X creates temp dirs with the 'wheel' group, which users are
-            # not likely to be in, and this prevents us from setting the sgid
-            # bit
-            os.chown(self.test_dir, os.getuid(), os.getgid())
 
         t = self.make_branch_and_tree('.')
         b = t.branch
@@ -143,6 +138,19 @@
         t.commit('new c')
         check_mode_r(self, '.bzr', 0664, 0775)
 
+
+    def test_new_files_group_sticky_bit(self):
+        if sys.platform == 'win32':
+            raise TestSkipped('chmod has no effect on win32')
+        elif sys.platform == 'darwin':
+            # OS X creates temp dirs with the 'wheel' group, which users are
+            # not likely to be in, and this prevents us from setting the sgid
+            # bit
+            os.chown(self.test_dir, os.getuid(), os.getgid())
+
+        t = self.make_branch_and_tree('.')
+        b = t.branch
+
         # Test the group sticky bit
         # Recursively update the modes of all files
         chmod_r('.bzr', 0664, 02775)



More information about the bazaar-commits mailing list