D14779: Fix 'kformattest fails with installed kcoreaddons language package'
Ralf Habacker
noreply at phabricator.kde.org
Thu Aug 16 08:07:15 BST 2018
habacker added a comment.
With the drawback that the qm file need to be generated on each build and the po file needs to be updated on any translations change in the test app
BTW: I tried your approach by
1. downloaded po file from https://websvn.kde.org/trunk/l10n-kf5/en/messages/frameworks/kcoreaddons5_qt.po?revision=1522662&view=markup
2. did run lrelease on that file and placed it into kcoreaddons source dir as kcoreaddons5_qt.qm
3. added to top level CMakelists.txt
`add_definitions(-DCMAKE_SOURCE_DIR="${CMAKE_SOURCE_DIR}")`
3. add to autotests/kformattest.cpp
void KFormatTest::initTestCase()
{
QLocale::setDefault(QLocale::C);
QTranslator *l = new QTranslator();
l->load(QStringLiteral(CMAKE_SOURCE_DIR "/kcoreaddons5_qt.qm"));
QCoreApplication::installTranslator(l);
}
without kcoreaddons-lang package installed the test case returns on a system with installed de_DE
strace -e trace=file bin/kformattest 2>&1 | grep \.qm
...
access("/home/xxx/src/kf5/kcoreaddons/kcoreaddons5_qt.qm", R_OK) = 0
stat("/home/xxx/src/kf5/kcoreaddons/kcoreaddons5_qt.qm", {st_mode=S_IFREG|0644, st_size=729, ...}) = 0
open("/home/xxx/src/kf5/kcoreaddons/kcoreaddons5_qt.qm", O_RDONLY|O_CLOEXEC) = 5
~/src/kf5/kcoreaddons-build> bin/kformattest
********* Start testing of KFormatTest *********
Config: Using QtTest library 5.11.1, Qt 5.11.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 4.8.5)
PASS : KFormatTest::initTestCase()
PASS : KFormatTest::formatByteSize()
PASS : KFormatTest::formatDuration()
FAIL! : KFormatTest::formatDecimalDuration() Compared values are not the same
Actual (format.formatDecimalDuration(10)) : "10 milliseconds"
Expected (QStringLiteral("10 millisecond(s)")): "10 millisecond(s)"
Loc: [/home/xxx/src/kf5/kcoreaddons/autotests/kformattest.cpp(302)]
FAIL! : KFormatTest::formatSpelloutDuration() Compared values are not the same
Actual (format.formatSpelloutDuration(1000)): "1 second"
Expected (QStringLiteral("1 second(s)")) : "1 second(s)"
Loc: [/home/xxx/src/kf5/kcoreaddons/autotests/kformattest.cpp(318)]
PASS : KFormatTest::formatRelativeDate()
PASS : KFormatTest::formatValue()
PASS : KFormatTest::cleanupTestCase()
Totals: 6 passed, 2 failed, 0 skipped, 0 blacklisted, 1ms
********* Finished testing of KFormatTest *********
with installed kcoreaddons-lang
~/src/kf5/kcoreaddons-build> strace -e trace=file bin/kformattest 2>&1 | grep \.qm
access("/usr/share/locale/en/LC_MESSAGES/kcoreaddons5_qt.qm", R_OK) = 0
open("/usr/share/locale/en/LC_MESSAGES/kcoreaddons5_qt.qm", O_RDONLY|O_CLOEXEC) = 5
access("/usr/share/locale/de/LC_MESSAGES/kcoreaddons5_qt.qm", R_OK) = 0
open("/usr/share/locale/de/LC_MESSAGES/kcoreaddons5_qt.qm", O_RDONLY|O_CLOEXEC) = 5
access("/home/xxx/src/kf5/kcoreaddons/kcoreaddons5_qt.qm", R_OK) = 0
stat("/home/xxx/src/kf5/kcoreaddons/kcoreaddons5_qt.qm", {st_mode=S_IFREG|0644, st_size=729, ...}) = 0
open("/home/xxx/src/kf5/kcoreaddons/kcoreaddons5_qt.qm", O_RDONLY|O_CLOEXEC) = 5
```~/src/kf5/kcoreaddons-build> bin/kformattest
********* Start testing of KFormatTest *********
Config: Using QtTest library 5.11.1, Qt 5.11.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 4.8.5)
PASS : KFormatTest::initTestCase()
PASS : KFormatTest::formatByteSize()
FAIL! : KFormatTest::formatDuration() Compared values are not the same
Actual (format.formatDuration(singleSecond, options)): "0 h 00 m 04 s"
Expected (QStringLiteral("0h00m04s")) : "0h00m04s"
Loc: [/home/xxx/src/kf5/kcoreaddons/autotests/kformattest.cpp(226)]
FAIL! : KFormatTest::formatDecimalDuration() Compared values are not the same
Actual (format.formatDecimalDuration(10)) : "10 milliseconds"
Expected (QStringLiteral("10 millisecond(s)")): "10 millisecond(s)"
Loc: [/home/xxx/src/kf5/kcoreaddons/autotests/kformattest.cpp(302)]
FAIL! : KFormatTest::formatSpelloutDuration() Compared values are not the same
Actual (format.formatSpelloutDuration(1000)): "1 second"
Expected (QStringLiteral("1 second(s)")) : "1 second(s)"
Loc: [/home/xxx/src/kf5/kcoreaddons/autotests/kformattest.cpp(318)]
FAIL! : KFormatTest::formatRelativeDate() Compared values are not the same
Actual (format.formatRelativeDate(testDate, QLocale::LongFormat)): "Heute"
Expected (QStringLiteral("Today")) : "Today"
Loc: [/home/xxx/src/kf5/kcoreaddons/autotests/kformattest.cpp(341)]
PASS : KFormatTest::formatValue()
PASS : KFormatTest::cleanupTestCase()
Totals: 4 passed, 4 failed, 0 skipped, 0 blacklisted, 1ms
********* Finished testing of KFormatTest *********
Seems not to work without further changes
What is the drawback to not load any translation in the ECM qm file loader with using QLocale::C as default locale ?
REPOSITORY
R244 KCoreAddons
REVISION DETAIL
https://phabricator.kde.org/D14779
To: habacker, #frameworks
Cc: aacid, kde-frameworks-devel, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180816/81407353/attachment-0001.html>
More information about the Kde-frameworks-devel
mailing list