Rev 4861: (vila) Skip chmod bits dependent tests when running as root (Vincent Ladeuil) in file:///home/pqm/archives/thelove/bzr/2.1/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Sep 23 22:35:23 BST 2010
At file:///home/pqm/archives/thelove/bzr/2.1/
------------------------------------------------------------
revno: 4861 [merge]
revision-id: pqm at pqm.ubuntu.com-20100923213520-bsdkodeyqvuqzq1w
parent: pqm at pqm.ubuntu.com-20100917205217-twwxe319wehq5fks
parent: v.ladeuil+lp at free.fr-20100923163727-p7ewdvoin9pen0sh
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.1
timestamp: Thu 2010-09-23 22:35:20 +0100
message:
(vila) Skip chmod bits dependent tests when running as root (Vincent Ladeuil)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/features.py features.py-20090820042958-jglgza3wrn03ha9e-1
bzrlib/tests/per_lock/test_lock.py test_lock.py-20070313190612-mfpoa7t8kvrgrhj2-1
bzrlib/tests/test_lockdir.py test_lockdir.py-20060220222025-33d4221569a3d600
bzrlib/tests/test_osutils.py test_osutils.py-20051201224856-e48ee24c12182989
bzrlib/tests/test_selftest.py test_selftest.py-20051202044319-c110a115d8c0456a
=== modified file 'NEWS'
--- a/NEWS 2010-09-17 19:58:09 +0000
+++ b/NEWS 2010-09-23 16:37:27 +0000
@@ -19,6 +19,9 @@
Bug Fixes
*********
+* Skip the tests that requires respecting the chmod bits when running as root.
+ (Vincent Ladeuil, #646133)
+
Improvements
************
=== modified file 'bzrlib/tests/features.py'
--- a/bzrlib/tests/features.py 2010-02-17 17:11:16 +0000
+++ b/bzrlib/tests/features.py 2010-09-23 16:37:27 +0000
@@ -14,11 +14,27 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+import os
from bzrlib import tests
from bzrlib.symbol_versioning import deprecated_in
+class _NotRunningAsRoot(tests.Feature):
+
+ def _probe(self):
+ try:
+ uid = os.getuid()
+ except AttributeError:
+ # If there is no uid, chances are there is no root either
+ return True
+ return uid != 0
+
+ def feature_name(self):
+ return 'Not running as root'
+
+
+not_running_as_root = _NotRunningAsRoot()
apport = tests.ModuleAvailableFeature('apport')
ApportFeature = tests._CompatabilityThunkFeature('bzrlib.tests.features',
'ApportFeature', 'bzrlib.tests.features.apport', deprecated_in((2,1,0)))
=== modified file 'bzrlib/tests/per_lock/test_lock.py'
--- a/bzrlib/tests/per_lock/test_lock.py 2009-07-07 09:00:59 +0000
+++ b/bzrlib/tests/per_lock/test_lock.py 2010-09-23 16:37:27 +0000
@@ -21,7 +21,7 @@
osutils,
)
-from bzrlib.tests import UnicodeFilenameFeature
+from bzrlib.tests import (features, UnicodeFilenameFeature)
from bzrlib.tests.per_lock import TestCaseWithLock
@@ -63,6 +63,7 @@
But we shouldn't be able to take a write lock.
"""
+ self.requireFeature(features.not_running_as_root)
osutils.make_readonly('a-file')
# Make sure the file is read-only (on all platforms)
self.assertRaises(IOError, open, 'a-file', 'rb+')
=== modified file 'bzrlib/tests/test_lockdir.py'
--- a/bzrlib/tests/test_lockdir.py 2010-09-10 05:13:57 +0000
+++ b/bzrlib/tests/test_lockdir.py 2010-09-23 16:37:27 +0000
@@ -39,7 +39,7 @@
LockNotHeld,
)
from bzrlib.lockdir import LockDir
-from bzrlib.tests import TestCaseWithTransport
+from bzrlib.tests import (features, TestCaseWithTransport)
from bzrlib.trace import note
# These tests sometimes use threads to test the behaviour of lock files with
@@ -669,6 +669,7 @@
ld1.unlock()
def test_lock_permission(self):
+ self.requireFeature(features.not_running_as_root)
if not osutils.supports_posix_readonly():
raise tests.TestSkipped('Cannot induce a permission failure')
ld1 = self.get_lock()
=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py 2010-05-27 04:00:01 +0000
+++ b/bzrlib/tests/test_osutils.py 2010-09-23 16:37:27 +0000
@@ -33,6 +33,7 @@
win32utils,
)
from bzrlib.tests import (
+ features,
file_utils,
test__walkdirs_win32,
)
@@ -1067,6 +1068,7 @@
if sys.platform == 'win32':
raise tests.TestNotApplicable(
"readdir IOError not tested on win32")
+ self.requireFeature(features.not_running_as_root)
os.mkdir("test-unreadable")
os.chmod("test-unreadable", 0000)
# must chmod it back so that it can be removed
=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py 2010-02-17 17:11:16 +0000
+++ b/bzrlib/tests/test_selftest.py 2010-09-23 16:37:27 +0000
@@ -609,12 +609,13 @@
l.attempt_lock()
test = TestDanglingLock('test_function')
result = test.run()
+ total_failures = result.errors + result.failures
if self._lock_check_thorough:
- self.assertEqual(1, len(result.errors))
+ self.assertEqual(1, len(total_failures))
else:
# When _lock_check_thorough is disabled, then we don't trigger a
# failure
- self.assertEqual(0, len(result.errors))
+ self.assertEqual(0, len(total_failures))
class TestTestCaseWithTransport(tests.TestCaseWithTransport):
More information about the bazaar-commits
mailing list