Rev 4511: Mark the known failures as such on OSX in http://bazaar.launchpad.net/%7Evila/bzr/integration
Vincent Ladeuil
v.ladeuil+lp at free.fr
Mon Jul 6 08:51:38 BST 2009
At http://bazaar.launchpad.net/%7Evila/bzr/integration
------------------------------------------------------------
revno: 4511 [merge]
revision-id: v.ladeuil+lp at free.fr-20090706075129-hoht0i4rl8w2uu7f
parent: pqm at pqm.ubuntu.com-20090706074459-trmwhot2xsag79ud
parent: v.ladeuil+lp at free.fr-20090706074905-sxrmz01tzqfvr23k
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: integration
timestamp: Mon 2009-07-06 09:51:29 +0200
message:
Mark the known failures as such on OSX
modified:
bzrlib/tests/blackbox/test_non_ascii.py test_non_ascii.py-20060105214030-68010be784a5d854
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
-------------- next part --------------
=== modified file 'bzrlib/tests/blackbox/test_non_ascii.py'
--- a/bzrlib/tests/blackbox/test_non_ascii.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_non_ascii.py 2009-07-06 07:49:05 +0000
@@ -16,30 +16,28 @@
"""Black-box tests for bzr handling non-ascii characters."""
+import os
import sys
-import os
-from bzrlib import osutils, urlutils
-from bzrlib.tests import (
- TestCaseWithTransport,
- TestSkipped,
- multiply_tests,
+from bzrlib import (
+ osutils,
+ tests,
+ urlutils,
)
-from bzrlib.tests.EncodingAdapter import encoding_scenarios
-from bzrlib.trace import mutter, note
+from bzrlib.tests import EncodingAdapter
def load_tests(standard_tests, module, loader):
- return multiply_tests(standard_tests, encoding_scenarios,
- loader.suiteClass())
-
-
-class TestNonAscii(TestCaseWithTransport):
+ return tests.multiply_tests(standard_tests,
+ EncodingAdapter.encoding_scenarios,
+ loader.suiteClass())
+
+
+class TestNonAscii(tests.TestCaseWithTransport):
"""Test that bzr handles files/committers/etc which are non-ascii."""
def setUp(self):
super(TestNonAscii, self).setUp()
- self._orig_email = os.environ.get('BZR_EMAIL', None)
self._orig_encoding = osutils._cached_user_encoding
osutils._cached_user_encoding = self.encoding
@@ -48,16 +46,11 @@
self.create_base()
def tearDown(self):
- if self._orig_email is not None:
- os.environ['BZR_EMAIL'] = self._orig_email
- else:
- if os.environ.get('BZR_EMAIL', None) is not None:
- del os.environ['BZR_EMAIL']
osutils._cached_user_encoding = self._orig_encoding
super(TestNonAscii, self).tearDown()
def run_bzr_decode(self, args, encoding=None, fail=False, retcode=None,
- working_dir=None):
+ working_dir=None):
"""Run bzr and decode the output into a particular encoding.
Returns a string containing the stdout output from bzr.
@@ -68,8 +61,9 @@
if encoding is None:
encoding = osutils.get_user_encoding()
try:
- out = self.run_bzr(args, output_encoding=encoding, encoding=encoding,
- retcode=retcode, working_dir=working_dir)[0]
+ out = self.run_bzr(args,
+ output_encoding=encoding, encoding=encoding,
+ retcode=retcode, working_dir=working_dir)[0]
return out.decode(encoding)
except UnicodeError, e:
if not fail:
@@ -82,8 +76,30 @@
if fail:
self.fail("Expected UnicodeError not raised")
+ def _check_OSX_can_roundtrip(self, path, fs_enc=None):
+ """Stop the test if it's about to fail or errors out.
+
+ Until we get proper support on OSX for accented paths (in fact, any
+ path whose NFD decomposition is different than the NFC one), this is
+ the best way to keep test active (as opposed to disabling them
+ completely). This is a stop gap. The tests should at least be rewritten
+ so that the failing ones are clearly separated from the passing ones.
+ """
+ if fs_enc is None:
+ fs_enc = osutils._fs_enc
+ if sys.platform == 'darwin':
+ encoded = path.encode(fs_enc)
+ import unicodedata
+ normal_thing = unicodedata.normalize('NFD', path)
+ mac_encoded = normal_thing.encode(fs_enc)
+ if mac_encoded != encoded:
+ raise tests.KnownFailure(
+ 'Unable to roundtrip path %r on OSX filesystem'
+ ' using encoding "%s"'
+ % (path, fs_enc))
+
def create_base(self):
- fs_enc = sys.getfilesystemencoding()
+ fs_enc = osutils._fs_enc
terminal_enc = osutils.get_terminal_encoding()
fname = self.info['filename']
dir_name = self.info['directory']
@@ -91,17 +107,16 @@
try:
thing.encode(fs_enc)
except UnicodeEncodeError:
- raise TestSkipped(('Unable to represent path %r'
- ' in filesystem encoding "%s"')
- % (thing, fs_enc))
+ raise tests.TestSkipped(
+ 'Unable to represent path %r in filesystem encoding "%s"'
+ % (thing, fs_enc))
try:
thing.encode(terminal_enc)
except UnicodeEncodeError:
- raise TestSkipped(('Unable to represent path %r'
- ' in terminal encoding "%s"'
- ' (even though it is valid in'
- ' filesystem encoding "%s")')
- % (thing, terminal_enc, fs_enc))
+ raise tests.TestSkipped(
+ 'Unable to represent path %r in terminal encoding "%s"'
+ ' (even though it is valid in filesystem encoding "%s")'
+ % (thing, terminal_enc, fs_enc))
wt = self.make_branch_and_tree('.')
self.build_tree_contents([('a', 'foo\n')])
@@ -117,11 +132,17 @@
wt.add(fname)
wt.commit(u'And a unicode file\n')
self.wt = wt
+ # FIXME: We don't check that the add went well, in fact, it doesn't on
+ # OSX (when LC_ALL is set correctly) because the added path doesn't
+ # match the one used on OSX. But checking here will require more
+ # invasive changes than adding the _check_OSX_can_roundtrip(), so I
+ # punt for now -- vila 20090702
def test_status(self):
self.build_tree_contents(
[(self.info['filename'], 'changed something\n')])
txt = self.run_bzr_decode('status')
+ self._check_OSX_can_roundtrip(self.info['filename'])
self.assertEqual(u'modified:\n %s\n' % (self.info['filename'],), txt)
txt = self.run_bzr_decode('status', encoding='ascii')
@@ -135,6 +156,7 @@
txt = self.run_bzr('cat b')[0]
self.assertEqual('non-ascii \xFF\xFF\xFC\xFB\x00 in b\n', txt)
+ self._check_OSX_can_roundtrip(self.info['filename'])
txt = self.run_bzr(['cat', self.info['filename']])[0]
self.assertEqual('unicode filename\n', txt)
@@ -168,6 +190,7 @@
def test_inventory(self):
txt = self.run_bzr_decode('inventory')
+ self._check_OSX_can_roundtrip(self.info['filename'])
self.assertEqual(['a', 'b', self.info['filename']],
txt.splitlines())
@@ -211,6 +234,7 @@
os.mkdir(dirname)
self.wt.add(dirname)
txt = self.run_bzr_decode(['mv', fname1, fname2, dirname])
+ self._check_OSX_can_roundtrip(self.info['filename'])
self.assertEqual([u'%s => %s/%s' % (fname1, dirname, fname1),
u'%s => %s/%s' % (fname2, dirname, fname2)]
, txt.splitlines())
@@ -323,6 +347,7 @@
self.wt.add('base')
self.wt.add('base/'+dirname)
path = osutils.pathjoin('base', dirname, fname)
+ self._check_OSX_can_roundtrip(self.info['filename'])
self.wt.rename_one(fname, path)
self.wt.commit('moving things around')
@@ -344,6 +369,7 @@
txt = self.run_bzr_decode('ancestry')
def test_diff(self):
+ self._check_OSX_can_roundtrip(self.info['filename'])
# TODO: jam 20060106 diff is a difficult one to test, because it
# shouldn't encode the file contents, but it needs some sort
# of encoding for the paths, etc which are displayed.
@@ -351,6 +377,7 @@
txt = self.run_bzr('diff', retcode=1)[0]
def test_deleted(self):
+ self._check_OSX_can_roundtrip(self.info['filename'])
fname = self.info['filename']
os.remove(fname)
self.wt.remove(fname)
@@ -371,6 +398,7 @@
self.build_tree_contents([(fname, 'modified\n')])
txt = self.run_bzr_decode('modified')
+ self._check_OSX_can_roundtrip(self.info['filename'])
self.assertEqual('"'+fname+'"'+'\n', txt)
self.run_bzr_decode('modified', encoding='ascii', fail=True)
@@ -406,6 +434,8 @@
self.assertNotEqual(-1, txt.find(self.info['message']))
txt = self.run_bzr_decode('log --verbose')
+ # FIXME: iso-8859-2 test shouldn't be skipped here --vila 20090702
+ self._check_OSX_can_roundtrip(self.info['filename'])
self.assertNotEqual(-1, txt.find(fname))
# Make sure log doesn't fail even if we can't write out
@@ -416,6 +446,7 @@
def test_touching_revisions(self):
fname = self.info['filename']
txt = self.run_bzr_decode(['touching-revisions', fname])
+ self._check_OSX_can_roundtrip(self.info['filename'])
self.assertEqual(u' 3 added %s\n' % (fname,), txt)
fname2 = self.info['filename'] + '2'
@@ -450,6 +481,7 @@
# quotes paths do we really want it to?
# awilkins 20080521 added and modified do it now as well
txt = self.run_bzr_decode('unknowns')
+ self._check_OSX_can_roundtrip(self.info['filename'])
self.assertEqual(u'"%s"\n' % (fname,), txt)
self.run_bzr_decode('unknowns', encoding='ascii', fail=True)
@@ -461,6 +493,7 @@
def check_unknowns(expected):
self.assertEqual(expected, list(self.wt.unknowns()))
+ self._check_OSX_can_roundtrip(self.info['filename'])
check_unknowns([fname2])
self.run_bzr_decode(['ignore', './' + fname2])
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2009-07-02 11:37:38 +0000
+++ b/bzrlib/workingtree_4.py 2009-07-06 07:51:29 +0000
@@ -687,7 +687,7 @@
from_entry = self._get_entry(path=from_rel)
if from_entry == (None, None):
raise errors.BzrMoveFailedError(from_rel,to_dir,
- errors.NotVersionedError(path=str(from_rel)))
+ errors.NotVersionedError(path=from_rel))
from_id = from_entry[0][2]
to_rel = pathjoin(to_dir, from_tail)
More information about the bazaar-commits
mailing list