Merge lp:~jameinel/tarmac/non_ascii-750930 into lp:tarmac

Proposed by John A Meinel
Status: Superseded
Proposed branch: lp:~jameinel/tarmac/non_ascii-750930
Merge into: lp:tarmac
Diff against target: 37 lines (+19/-0)
2 files modified
tarmac/plugins/command.py (+2/-0)
tarmac/plugins/tests/test_command.py (+17/-0)
To merge this branch: bzr merge lp:~jameinel/tarmac/non_ascii-750930
Reviewer Review Type Date Requested Status
dobey Needs Resubmitting
Paul Hummer Pending
Review via email: mp+73831@code.launchpad.net

This proposal has been superseded by a proposal from 2013-10-29.

Commit message

Bug #750930, handle non-ascii characters in test output.

Description of the change

This should be a reasonable fix for bug #750930.

I was trying to use Tarmac for lp:meliae, and it seems that gcc likes to put non-ascii characters into the output. (It looks like it uses fancy quotes.) I'm not 100% sure what characters are bad, but I do know that when the test suite failed, Tarmac just dies because of a UnicodeDecodeError.

The test case shows the failure, and the workaround is assuming that stdout/stderr are encoded in UTF-8. It is a slight hack, because the encoding could be something else, but it is unlikely.
At a minimum, it is better to decode w/ UTF-8 than to do u''.join(8-bit-strings).

This fix was enough for Meliae, though arguably any command that fails should cause Tarmac to say 'could not merge this branch because of FAILURE' rather than dying completely.

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

I'm not sure how I feel about this. GCC is using the fancy quotes because the locale you're compiling under is en_US.UTF-8 presumably (as you are presumably running this as a live logged-in user). If GCC runs under the C locale, it uses pure ASCII for error/warning messages. And, as you pointed out, this will still fail if under a UTF-8-incompatible locale, such as Russian KOI8-R. I wonder if a better solution might be to force the locale to be C inside tarmac.

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/07/2011 03:15 PM, Rodney Dawes wrote:
> I'm not sure how I feel about this. GCC is using the fancy quotes because the locale you're compiling under is en_US.UTF-8 presumably (as you are presumably running this as a live logged-in user). If GCC runs under the C locale, it uses pure ASCII for error/warning messages. And, as you pointed out, this will still fail if under a UTF-8-incompatible locale, such as Russian KOI8-R. I wonder if a better solution might be to force the locale to be C inside tarmac.
>

If it is a C locale, then .decode('UTF-8') will still work.

Yes, it will fail for other locales, and yes there are ways to detect it.

This still solves 90% of the cases without having to do more work.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5nv2sACgkQJdeBCYSNAAOu7QCaA9H+qhXRjrUx7YPSJhdMPgp6
3sEAoM9jNkmeKk6QR3duFbMArr5bafFR
=oLNa
-----END PGP SIGNATURE-----

Revision history for this message
dobey (dobey) wrote :

This needs to be re-submitted afresh, without Paul as the reviewer (but with ~tarmac or myself as the reviewer instead).

review: Needs Resubmitting

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tarmac/plugins/command.py'
2--- tarmac/plugins/command.py 2011-09-02 04:06:25 +0000
3+++ tarmac/plugins/command.py 2011-09-02 14:55:29 +0000
4@@ -179,6 +179,8 @@
5 exception is then raised to prevent the commit from happening.
6 '''
7 message = u'Test command "%s" failed.' % self.verify_command
8+ stdout_value = stdout_value.decode('UTF-8')
9+ stderr_value = stderr_value.decode('UTF-8')
10 comment = (u'The attempt to merge %(source)s into %(target)s failed. '
11 u'Below is the output from the failed tests.\n\n'
12 u'%(output)s') % {
13
14=== modified file 'tarmac/plugins/tests/test_command.py'
15--- tarmac/plugins/tests/test_command.py 2010-09-21 18:26:57 +0000
16+++ tarmac/plugins/tests/test_command.py 2011-09-02 14:55:29 +0000
17@@ -57,3 +57,20 @@
18 self.plugin.run,
19 command=self.command, target=target, source=None,
20 proposal=self.proposal)
21+
22+ def test_run_nonascii_failure(self):
23+ self.config.debug = False
24+ target = Thing(config=Thing(
25+ verify_command="python -c 'import sys;"
26+ " sys.stdout.write(\"f\\xc3\\xa5\\xc3\\xafl\"\n);"
27+ " sys.exit(1)'"),
28+ tree=Thing(abspath=os.path.abspath))
29+ e = self.assertRaises(command.VerifyCommandFailed,
30+ self.plugin.run,
31+ command=self.command, target=target, source=None,
32+ proposal=self.proposal)
33+ self.assertEqual(u'The attempt to merge lp:project/source'
34+ u' into lp:project failed.'
35+ u' Below is the output from the failed tests.'
36+ u'\n\nf\xe5\xefl\n',
37+ e.comment)

Subscribers

People subscribed via source and target branches