Bug 295383 - KTzfileTimeZoneSource and KTimeZoneBackend are too noisy when running Dolphin
Summary: KTzfileTimeZoneSource and KTimeZoneBackend are too noisy when running Dolphin
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: kdecore (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: David Jarvie
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-05 20:52 UTC by Frank Reininghaus
Modified: 2012-04-16 20:47 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch for ktimezonestest_p.h which fixes most of the problem. (562 bytes, patch)
2012-03-12 21:28 UTC, Frank Reininghaus
Details
New patch, which should also work if KDEHOME is not set (825 bytes, patch)
2012-03-17 10:01 UTC, Frank Reininghaus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Frank Reininghaus 2012-03-05 20:52:16 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20100101 Firefox/10.0.1
Build Identifier: 

Every time I run Dolphin with my kde-devel user (kdelibs and kde-baseapps self-compiled from git), I get a lot of messages like

dolphin(7565): Cannot open  "/home/kde-devel/.kde-unit-test/ktimezonestest/Europe/Paris"

which comes from:
KTimeZoneData* KTzfileTimeZoneSource::parse(const KTimeZone &zone) const

and

-> No cache

which comes from
int KTimeZoneBackend::offsetAtZoneTime(const KTimeZone* caller, const QDateTime &zoneDateTime, int *secondOffset) const

The first message seems to be printed to the console once for every item in the view. This is a problem in particular in directories with many items (which I open frequently when testing things and triaging bugs) because any interesting debug output from Dolphin is drowned in hundreds or even thousands of these error messages.

It seems to me that these messages are related to unit testing, but if that is really the case, they should not be shown when a non-unit-test executable is run IMHO.

Reproducible: Always
Comment 1 David Jarvie 2012-03-08 23:14:30 UTC
What are the contents of your ktimezonedrc file, in the KDE config directory in your home directory?
Comment 2 Frank Reininghaus 2012-03-09 06:09:59 UTC
I'm pasting the contents below. If you need any further info, please let me know.

[TimeZones]
LocalZone=Europe/Paris
ZoneinfoDir=/home/kde-devel/.kde-unit-test/ktimezonestest
Zonetab=/home/kde-devel/.kde-unit-test/ktimezonestest/zone.tab
ZonetabCache=
Comment 3 David Jarvie 2012-03-09 13:52:44 UTC
It looks as if the ktimezonestest unit test may have been run and then cancelled before it completed. The contents of ktimezonedrc are those set up by ktimezonestest, but normally the test cleans up after each test step.

Try deleting ktimezonedrc - this may well make things run normally again.
Comment 4 Frank Reininghaus 2012-03-09 16:50:16 UTC
Thanks for the hint, but deleting ktimezonedrc only solved the problem partially and temporarily:

1. The "-> No chache" messages still appeared after the deletion.
2. After the next run of "make test" in kdelibs, which terminated correctly, the situation was as before.

I've had a quick look at the ktimezonestest sources and could not see any code that cleans up the config, but I might have missed something.
Comment 5 David Jarvie 2012-03-10 18:42:49 UTC
The config set up by ktimezonestest is cleaned up by calling cleanupTimeZoneTest() in ktimezonestest_p.h, which is called from KTimeZonesTest::cleanupTestCase(), which in turn is called automatically by the test framework at the end of each test step.

I don't think this is the problem in your case, however. The way that the test framework is supposed to work is that it sets the KDE home to ~/.kde-unit-test, so that your normal KDE home directory is left untouched. So it's strange that your ~/.kde/share/config/ktimezonedrc is being changed by the tests. I don't think the problem is due to a bug in ktimezonestest (it works ok for me), but rather to some problem with the test framework on your system.
Comment 6 Frank Reininghaus 2012-03-12 09:27:49 UTC
Thanks for the information. I had actually never noticed that unit tests are supposed to use a different KDEHOME - maybe because it doesn't work for me.

(In reply to comment #5)
> The config set up by ktimezonestest is cleaned up by calling
> cleanupTimeZoneTest() in ktimezonestest_p.h, which is called from
> KTimeZonesTest::cleanupTestCase(), which in turn is called automatically by
> the test framework at the end of each test step.

I actually saw that function, but couldn't see how cleaning up the .kde-unit-test dir can fix my config which is stored somewhere else. But I see now that this is due to the test framework not taking care of the KDEHOME properly on my system. I'll try to find out why that is the case.
Comment 7 Frank Reininghaus 2012-03-12 21:28:06 UTC
Created attachment 69556 [details]
Patch for ktimezonestest_p.h which fixes most of the problem.

Now I know why "make test" changes the ktimezonedrc in my normal $KDEHOME (i.e., not in ~/.kde-unit-test). It does not happen when running ktimezonestest, but in kdeui/tests/ktimezonewidget_unittest.

That test uses the same private header file to modify the config, but it does not set KDEHOME to .kde-unit-test (which is intentional, according to the comments in the test source). On the other hand, cleanupTimeZoneTest() in ktimezonestest_p.h uses a hardcoded path (QDir::homePath() + "/.kde-unit-test/share") when it tries to clean up the config modified by the test.

I propose to determine the path of the config file dynamically by reading the contents of $KDEHOME when cleaning up, see attached patch.

Even with that patch, the "-> No cache" messages still remain. The only easy way to get rid of them is probably to remove them altogether, but if these messages are useful to you, I think I can probably live with them - they are far less disturbing than the error messages that my patch gets rid of :-)
Comment 8 Frank Reininghaus 2012-03-12 21:33:12 UTC
Looking at the code again, one could probably also remove the line

removeDir(QLatin1String("share/config"));

in TimeZoneTestData::cleanupTimeZoneTest().
Comment 9 David Jarvie 2012-03-13 21:43:14 UTC
I don't think your patch will work on many systems, because the environment variable KDEHOME is an optional variable these days - it can be set to override the default ~/.kde, but otherwise doesn't have to exist.
Comment 10 Frank Reininghaus 2012-03-17 10:01:09 UTC
Created attachment 69689 [details]
New patch, which should also work if KDEHOME is not set

You're right, of course. My new proposed patch should work even if KDEHOME is not set.
Comment 11 David Jarvie 2012-03-21 13:01:03 UTC
Your patch seems to work, so go ahead and commit it.
Comment 12 Frank Reininghaus 2012-03-22 05:48:32 UTC
Git commit 0c7ce8d96886efdf6b2bc0ac71c4a87821ea5fd0 by Frank Reininghaus.
Committed on 22/03/2012 at 06:45.
Pushed by freininghaus into branch 'KDE/4.8'.

Clean up ktimezonedrc properly after each unit test

ktimezonestest_p.h already did try to clean up the config after testing,
but the folder to be removed was hardcoded (~/.kde-unit-test/share).
This does work for ktimezonestest, but not for ktimezonewidget_unittest.
That test uses the same private header, but does not change KDEHOME to
~/.kde-unit-test, such that the user's normal config was modified by the
test, and the changes persisted even after the test. This then caused
applications like, e.g., Dolphin to output lots of unwanted error
messages at runtime.

This commit changes that by determining the full path of ktimezonedrc at
runtime and deleting that file.

M  +2    -2    kdecore/tests/ktimezonestest_p.h

http://commits.kde.org/kdelibs/0c7ce8d96886efdf6b2bc0ac71c4a87821ea5fd0
Comment 13 Ivan Čukić 2012-04-16 20:47:41 UTC
Git commit e8a152d78eb32f1a8fc12041f7405934307c7249 by Ivan Čukić, on behalf of Frank Reininghaus.
Committed on 22/03/2012 at 06:45.
Pushed by ivan into branch 'ivan/solid-fuse-access'.

Clean up ktimezonedrc properly after each unit test

ktimezonestest_p.h already did try to clean up the config after testing,
but the folder to be removed was hardcoded (~/.kde-unit-test/share).
This does work for ktimezonestest, but not for ktimezonewidget_unittest.
That test uses the same private header, but does not change KDEHOME to
~/.kde-unit-test, such that the user's normal config was modified by the
test, and the changes persisted even after the test. This then caused
applications like, e.g., Dolphin to output lots of unwanted error
messages at runtime.

This commit changes that by determining the full path of ktimezonedrc at
runtime and deleting that file.

M  +2    -2    kdecore/tests/ktimezonestest_p.h

http://commits.kde.org/kdelibs/e8a152d78eb32f1a8fc12041f7405934307c7249