Subversion fails in a non-english locale

Bug #1724674 reported by Facundo Batista
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
Fix Released
Medium
Carlo Lobrano

Bug Description

The following test fails if machine locale is not English, showing the actual bug in the code:

  snapcraft.tests.sources.test_subversion.SubversionDetailsTestCase.test_svn_details_commit

This is because it tries to find a specific string in the svn output, 'Last Changed Rev: ', which is for english locales only.

summary: - Subversion test fails in a non-english locale
+ Subversion fails in a non-english locale
description: updated
Revision history for this message
Carlo Lobrano (c-lobrano) wrote :

I'm trying to reproduce this issue. What are your locale settings?

Revision history for this message
Facundo Batista (facundo) wrote :

Hi Carlo!

$ echo $LANG
es_AR.UTF-8

For the test to pass ok in my machine, I did

LANG=C python3 -m unittest snapcraft.tests.sources.test_subversion.SubversionDetailsTestCase.test_svn_details_commit

So probably you could do the same (changing the LANG, of course) to reproduce it

Revision history for this message
Carlo Lobrano (c-lobrano) wrote :

@facundo I can not reproduce this problem. This is my locale settings (which is mixed between yours and the italian one, but there is no english configuration here)

$ locale
LANG=es_AR.UTF-8
LANGUAGE=
LC_CTYPE="es_AR.UTF-8"
LC_NUMERIC=it_IT.UTF-8
LC_TIME=it_IT.UTF-8
LC_COLLATE="es_AR.UTF-8"
LC_MONETARY=it_IT.UTF-8
LC_MESSAGES=
LC_PAPER=it_IT.UTF-8
LC_NAME=it_IT.UTF-8
LC_ADDRESS=it_IT.UTF-8
LC_TELEPHONE=it_IT.UTF-8
LC_MEASUREMENT=it_IT.UTF-8
LC_IDENTIFICATION=it_IT.UTF-8
LC_ALL=

and this is the test result

$ python3 -m unittest snapcraft.tests.sources.test_subversion.SubversionDetailsTestCase.test_svn_details_commit -v
test_svn_details_commit (snapcraft.tests.sources.test_subversion.SubversionDetailsTestCase)
snapcraft.tests.sources.test_subversion.SubversionDetailsTestCase.test_svn_details_commit ... ok

----------------------------------------------------------------------
Ran 1 test in 0.633s

OK

I suspect the problem could be slightly different.
Could you please report:

- the snapcraft version
- your full locale (run `locale` on a shell)
- the full output of the test using the verbose `-v` flag?

thanks a lot

Revision history for this message
Facundo Batista (facundo) wrote :
Download full text (3.4 KiB)

Snapcraft version: directly from project's master

Full locale:

$ locale
LANG=es_AR.UTF-8
LANGUAGE=es_AR:es
LC_CTYPE="es_AR.UTF-8"
LC_NUMERIC="es_AR.UTF-8"
LC_TIME="es_AR.UTF-8"
LC_COLLATE="es_AR.UTF-8"
LC_MONETARY="es_AR.UTF-8"
LC_MESSAGES="es_AR.UTF-8"
LC_PAPER="es_AR.UTF-8"
LC_NAME="es_AR.UTF-8"
LC_ADDRESS="es_AR.UTF-8"
LC_TELEPHONE="es_AR.UTF-8"
LC_MEASUREMENT="es_AR.UTF-8"
LC_IDENTIFICATION="es_AR.UTF-8"
LC_ALL=

Full output:

$ python3 -m unittest snapcraft.tests.sources.test_subversion.SubversionDetailsTestCase.test_svn_details_commit -v
test_svn_details_commit (snapcraft.tests.sources.test_subversion.SubversionDetailsTestCase)
snapcraft.tests.sources.test_subversion.SubversionDetailsTestCase.test_svn_details_commit ... FAIL

======================================================================
FAIL: test_svn_details_commit (snapcraft.tests.sources.test_subversion.SubversionDetailsTestCase)
snapcraft.tests.sources.test_subversion.SubversionDetailsTestCase.test_svn_details_commit
----------------------------------------------------------------------
testtools.testresult.real._StringException: Empty attachments:
  pythonlogging:''

Traceback (most recent call last):
  File "/home/facundo/canonical/snappy/snapcraft/snapcraft/tests/sources/test_subversion.py", line 179, in test_svn_details_commit
    self.source_details['source-commit'], Equals(self.expected_commit))
  File "/home/facundo/canonical/snappy/snapcraft/env/lib/python3.5/site-packages/testtools/testcase.py", line 498, in assertThat
    raise mismatch_error
testtools.matchers._impl.MismatchError: None != '1'

----------------------------------------------------------------------
Ran 1 test in 1.338s

FAILED (failures=1)

For further debugging, I applied this small patch:

--- a/snapcraft/internal/sources/_subversion.py
+++ b/snapcraft/internal/sources/_subversion.py
@@ -83,6 +83,8 @@ class Subversion(Base):
         if not commit: # retrieve the commit id
             lines = subprocess.check_output(['svn', 'info', self.source_dir]
                                             ).decode('utf-8').split('\n')
+ import logging
+ logging.getLogger().error("Lines: %s", lines)
             prefix = 'Last Changed Rev: '
             for line in lines:
                 if line.startswith(prefix):

And this is what the logging shown when running the same test than above:

Lines: ['Ruta: svn-checkout', 'Working Copy Root Path: /tmp/tmpndlng0ti/svn-checkout', 'URL: file:///tmp/tmpndlng0ti/svn-repo', 'Relative URL: ^/', 'Raíz del repositorio: file:///tmp/tmpndlng0ti/svn-repo', 'UUID del repositorio: 6262fc05-1778-4155-85ec-38d5d6d3a634', 'Revisión: 1', 'Tipo de nodo: directorio', 'Agendado: normal', 'Autor del último cambio: facundo', 'Revisión del último cambio: 1', 'Fecha de último cambio: 2017-10-25 12:50:40 -0300 (mié 25 de oct de 2017)', '', '']
Lines: ['Ruta: svn-checkout', 'Working Copy Root Path: /tmp/tmpndlng0ti/svn-checkout', 'URL: file:///tmp/tmpndlng0ti/svn-repo', 'Relative URL: ^/', 'Raíz del repositorio: file:///tmp/tmpndlng0ti/svn-repo', 'UUID del repositorio: 6262fc05-1778-4155-85ec-38d5d6d3a634', 'Revisión: 1', 'Tipo de nodo: directorio', 'Agendad...

Read more...

Revision history for this message
Carlo Lobrano (c-lobrano) wrote :

Finally, I replicated the issue, so I can confirm this bug.

I assume that the best solution would be to assure that snapcraft tests run in a (temporary) default locale, is it right?

Changed in snapcraft:
assignee: nobody → Carlo Lobrano (c-lobrano)
status: New → Confirmed
Revision history for this message
Carlo Lobrano (c-lobrano) wrote :
Revision history for this message
Carlo Lobrano (c-lobrano) wrote :

New fix proposal after code review https://github.com/snapcore/snapcraft/pull/1648

Changed in snapcraft:
milestone: none → 2.35
status: Confirmed → Fix Committed
importance: Undecided → Medium
Changed in snapcraft:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.