TimeFormatterTest does not set environment properly.

Bug #1301038 reported by Antti Kaijanmäki
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
unity8 (Ubuntu)
Fix Released
Medium
Andrea Cimitan

Bug Description

Trying to compile binary package for unity8 with bzr bd fails with unit test failure:

FAIL! : TimeFormatterTest::testFormatStrF() Compared values are not the same
   Actual (formatter.timeString()) : 01-04-2014 11:57
   Expected (time.toString("dd-MM-yyyy hh:mmAP")): 01-04-2014 11:57IP.
   Loc: [/home/antti/branches/unity8/build-area/unity8-7.84+14.04.20140327.1/tests/plugins/Utils/timeformattertest.cpp(62)]

See that "IP". That comes from my locale. In Finnish PM is IltaPäivä -> IP .
Compiling again a few minutes later I got "AP" (for Finnish AamuPäivä).

The test uses QDateTime which probably picks up my system locale correctly and gives the localized postfixes.
So, the test should set up locale to en_US before executing to get reliable results on different systems.

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

Related branches

Revision history for this message
Albert Astals Cid (aacid) wrote :

This is documented in the CODING file

Michał Sawicz (saviq)
Changed in unity8:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Michał Sawicz (saviq) wrote :

This affects autopilot tests now, too, since they test for indicator titles.

Andrea Cimitan (cimi)
Changed in unity8:
assignee: nobody → Andrea Cimitan (cimi)
Revision history for this message
Andrea Cimitan (cimi) wrote :

For the qml tests, a fix is in coming.

For the autopilot tests, the situation is more complicated: we test things like indicators which are independently running from the unity session, so if we change locale they have to restart as well... and force a restart of those services from an autopilot test seems too much.

An approach that needs to be expanded, storing the value of the LC_ALL before setting it to C and dealing with underlying services is http://paste.ubuntu.com/7260650/

Andrea Cimitan (cimi)
Changed in unity8:
status: Triaged → In Progress
Michał Sawicz (saviq)
Changed in unity8:
status: In Progress → Fix Released
Changed in unity8 (Ubuntu):
status: New → Fix Released
Michał Sawicz (saviq)
Changed in unity8 (Ubuntu):
assignee: nobody → Andrea Cimitan (cimi)
importance: Undecided → Medium
no longer affects: unity8
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.