Hi,
"make test" changes $HOME during the test to avoid polluting user files
(setup.vim:12 and test_gui.vim:15).
Although the change itself causes no functional problem in executing the
test at all, there's a case where it can be unexpectedly troublesome. Let
me explain this first.
Both GTK2 and 3 GUIs rely on fontconfig to choose and load fonts, and the
latter uses cache to make its font search fast enough.
When fontconfig cannot find cache, it tries creating caches, visiting all
prescribed directories and examining every font file found there.
The resulting caches are usually placed at /var/cache/fontconfig/ for the
system and $HOME/.cache/fontconfig for the user.
Now suppose that a user has installed his favorite font in $HOME/.fonts/,
and has named it as default, and that he or the system has updated the
caches as usual. Now do "make test_gui". Then, since the system-wide
cache doesn't know about the named font at all, and since there's no cache
found in $HOME/.cache due/ to the $HOME change done by the test, fontconfig
gets confused and decides to create new caches.
That makes test_gui anything but smiley :)
As long as my PC is concerned, it takes ~2 minutes with ~1.5GB RAM
consumption and ~100% single core CPU usage for fontconfig to finish
creating new caches. At first glance, it looked to me as if the PC was
going to crash because of its sudden restless but faint noises out of the
hard disk and an unusual rapid increase of memory consumption. Probably,
you can easily imagine how much I was upset by that at that time :)
A workaround to that is actually simple and easy: Specify the user cache
path on the command-line explicitly and run the test like this: "make
XDG_CACHE_HOME=$HOME/.cache test", thereby taking advantage of the XDG
specs which can be paraphrased into this: Let $XDG_CACHE_HOME take
precedence over $HOME/.cache if the former is defined and a non-empty
string.
Note that, when the $XDG_CACHE_HOME is defined, $HOME points to the genuine
home directory (= the home directory for the one who invokes "make test"),
and
that the $XDG_CACHE_HOME is not subject to any subsequent $HOME changes.
Therefore, even if $HOME is changed wildly by the test, the $XDG_CACHE_HOME
is kept pointing to the same ~/.cache/ where the existing caches reside.
The attached patch is for making the workaround handy, that is, when
$XDG_CACHE_HOME is undefined or set to an empty string, "make test"
automatically sets it to .cache in the genuine $HOME.
Best regards,
Kazunobu Kuriyama
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim
index d95d991eb..fbea706bd 100644
--- a/src/testdir/test_gui.vim
+++ b/src/testdir/test_gui.vim
@@ -10,7 +10,11 @@ func SetUp()
set guifont=Courier\ 10\ Pitch/8/-1/5/50/0/0/0/0/0
endif
- " Gnome insists on creating $HOME/.gnome2/..
+ " Gnome insists on creating $HOME/.gnome2/, and we're going to abide by
+ " that, taking care to have the font cache work normally.
+ if $XDG_CACHE_HOME == ''
+ let $XDG_CACHE_HOME = g:tester_HOME . '/.cache'
+ endif
call mkdir('Xhome')
let $HOME = fnamemodify('Xhome', ':p')
endfunc
diff --git a/src/testdir/unix.vim b/src/testdir/unix.vim
index 36dd4e1e3..2290ec9cb 100644
--- a/src/testdir/unix.vim
+++ b/src/testdir/unix.vim
@@ -2,4 +2,9 @@
" Always use "sh", don't use the value of "$SHELL".
set shell=sh
+" While some tests overwrite $HOME to prevent them from polluting user files,
+" we need to remember the original value so that we can tell external systems
+" where to ask about their own user settings.
+let g:tester_HOME = $HOME
+
source setup.vim