Merge lp:~spiv/bzr/lang-c-failures-632387-2.2 into lp:bzr/2.2

Proposed by Andrew Bennetts
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: 5094
Proposed branch: lp:~spiv/bzr/lang-c-failures-632387-2.2
Merge into: lp:bzr/2.2
Diff against target: 131 lines (+23/-13)
5 files modified
NEWS (+3/-0)
bzrlib/tests/blackbox/test_alias.py (+4/-2)
bzrlib/tests/blackbox/test_commit.py (+2/-0)
bzrlib/tests/blackbox/test_export.py (+5/-8)
bzrlib/tests/test_osutils.py (+9/-3)
To merge this branch: bzr merge lp:~spiv/bzr/lang-c-failures-632387-2.2
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+36411@code.launchpad.net

Commit message

Fix test failures in a LANG=C environment caused by tests using non-ascii unicode filenames without checking if that feature is available.

Description of the change

This fixes the test failures in lp:bzr/2.2 due to running under LANG=C (and LC_CTYPE= LANG=C LC_ALL=), at least on my Ubuntu 10.10 system. In all cases the best fix seemed to be to just skip if unicode filenames weren't possible.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

Thanks, this is very nice to fix for SRUs.

istm that on modern unix, even with LANG=C, it may be reasonable to assume the filesystem names are actually still in UTF-8. Or at least it's probably more useful to treat them as UTF-8 than to fail. But that's a separate bug.

The fixes look reasonable to me.

I wonder how hard it would be to fix 2.1 for the sake of covering more SRUs?

review: Approve
Revision history for this message
Andrew Bennetts (spiv) wrote :

Probably not too hard to fix 2.1 too. I'm inclined to get 2.2's selftest working nicely in the deb build environment first then look at backporting in one batch.

Revision history for this message
Andrew Bennetts (spiv) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-09-20 09:13:57 +0000
3+++ NEWS 2010-09-23 04:05:59 +0000
4@@ -34,6 +34,9 @@
5 Testing
6 *******
7
8+* Fix tests that failed when run under ``LANG=C``.
9+ (Andrew Bennetts, #632387)
10+
11
12 bzr 2.2.1
13 #########
14
15=== modified file 'bzrlib/tests/blackbox/test_alias.py'
16--- bzrlib/tests/blackbox/test_alias.py 2010-06-23 08:19:28 +0000
17+++ bzrlib/tests/blackbox/test_alias.py 2010-09-23 04:05:59 +0000
18@@ -16,10 +16,9 @@
19 #
20
21 """Tests of the 'bzr alias' command."""
22-import os
23 import codecs
24
25-from bzrlib.tests import TestCaseWithTransport
26+from bzrlib.tests import TestCaseWithTransport, UnicodeFilenameFeature
27 from bzrlib.config import (ensure_config_dir_exists, config_filename)
28
29
30@@ -46,6 +45,9 @@
31
32 def test_unicode_alias(self):
33 """Unicode aliases should work (Bug #529930)"""
34+ # XXX: strictly speaking, lack of unicode filenames doesn't imply that
35+ # unicode command lines aren't available.
36+ self.requireFeature(UnicodeFilenameFeature)
37 config_enc = 'utf-8'
38 file_name = u'foo\xb6'
39
40
41=== modified file 'bzrlib/tests/blackbox/test_commit.py'
42--- bzrlib/tests/blackbox/test_commit.py 2010-07-14 08:53:58 +0000
43+++ bzrlib/tests/blackbox/test_commit.py 2010-09-23 04:05:59 +0000
44@@ -33,6 +33,7 @@
45 from bzrlib.tests import (
46 probe_bad_non_ascii,
47 TestSkipped,
48+ UnicodeFilenameFeature,
49 )
50 from bzrlib.tests import TestCaseWithTransport
51
52@@ -112,6 +113,7 @@
53 def test_unicode_commit_message_is_filename(self):
54 """Unicode commit message same as a filename (Bug #563646).
55 """
56+ self.requireFeature(UnicodeFilenameFeature)
57 file_name = u'\N{euro sign}'
58 self.run_bzr(['init'])
59 open(file_name, 'w').write('hello world')
60
61=== modified file 'bzrlib/tests/blackbox/test_export.py'
62--- bzrlib/tests/blackbox/test_export.py 2010-06-11 07:32:12 +0000
63+++ bzrlib/tests/blackbox/test_export.py 2010-09-23 04:05:59 +0000
64@@ -66,15 +66,13 @@
65 self.assertEqual(['test/a'], sorted(ball.getnames()))
66
67 def test_tar_export_unicode(self):
68+ self.requireFeature(tests.UnicodeFilenameFeature)
69 tree = self.make_branch_and_tree('tar')
70 # FIXME: using fname = u'\xe5.txt' below triggers a bug revealed since
71 # bzr.dev revno 4216 but more related to OSX/working trees/unicode than
72 # export itself --vila 20090406
73 fname = u'\N{Euro Sign}.txt'
74- try:
75- self.build_tree(['tar/' + fname])
76- except UnicodeError:
77- raise tests.TestSkipped('Unable to represent path %r' % (fname,))
78+ self.build_tree(['tar/' + fname])
79 tree.add([fname])
80 tree.commit('first')
81
82@@ -87,6 +85,7 @@
83
84 def test_tar_export_unicode_basedir(self):
85 """Test for bug #413406"""
86+ self.requireFeature(tests.UnicodeFilenameFeature)
87 basedir = u'\N{euro sign}'
88 os.mkdir(basedir)
89 os.chdir(basedir)
90@@ -119,12 +118,10 @@
91 self.assertEqual(['test/a'], sorted(zfile.namelist()))
92
93 def test_zip_export_unicode(self):
94+ self.requireFeature(tests.UnicodeFilenameFeature)
95 tree = self.make_branch_and_tree('zip')
96 fname = u'\N{Euro Sign}.txt'
97- try:
98- self.build_tree(['zip/' + fname])
99- except UnicodeError:
100- raise tests.TestSkipped('Unable to represent path %r' % (fname,))
101+ self.build_tree(['zip/' + fname])
102 tree.add([fname])
103 tree.commit('first')
104
105
106=== modified file 'bzrlib/tests/test_osutils.py'
107--- bzrlib/tests/test_osutils.py 2010-07-08 09:11:44 +0000
108+++ bzrlib/tests/test_osutils.py 2010-09-23 04:05:59 +0000
109@@ -21,7 +21,6 @@
110 import os
111 import re
112 import socket
113-import stat
114 import sys
115 import time
116
117@@ -2076,5 +2075,12 @@
118
119 def test_unicode_user(self):
120 ue = osutils.get_user_encoding()
121- osutils.set_or_unset_env('LOGNAME', u'jrandom\xb6'.encode(ue))
122- self.assertEqual(u'jrandom\xb6', osutils.getuser_unicode())
123+ uni_val, env_val = tests.probe_unicode_in_user_encoding()
124+ if uni_val is None:
125+ raise tests.TestSkipped(
126+ 'Cannot find a unicode character that works in encoding %s'
127+ % (osutils.get_user_encoding(),))
128+ uni_username = u'jrandom' + uni_val
129+ encoded_username = uni_username.encode(ue)
130+ osutils.set_or_unset_env('LOGNAME', encoded_username)
131+ self.assertEqual(uni_username, osutils.getuser_unicode())

Subscribers

People subscribed via source and target branches