testing: preserve XDG dirs if located inside builddir

The nightly testing configures some platforms such that
XDG_CONFIG/DATA/CACHE_HOME are inside the build dir. It also populates these
dirs with files (for example, GNOME Online Accounts) which must survive all
cleaning of these directories.

Long term it would be better to separate test files from build files,
but that's a task for some other time...
This commit is contained in:
Patrick Ohly 2013-09-16 03:23:49 -07:00
parent beb7f77d2f
commit 102c90d70c
2 changed files with 19 additions and 4 deletions

View file

@ -527,6 +527,7 @@ VERSION:3.0\r?
# We have to clean the xdg_root ourselves. We have to be nice
# to EDS and can't just wipe out the entire directory.
# Same for GNOME Online Accounts.
items = list(os.walk(xdg_root))
items.reverse()
for dirname, dirs, files in items:
@ -534,7 +535,9 @@ VERSION:3.0\r?
for dir in dirs:
# evolution-source-registry gets confused when we remove
# the "sources" directory itself.
if reldir == 'config/evolution' and dir == 'sources':
# GNOME Online Accounts settings must survive.
if (reldir == 'config/evolution' and dir == 'sources') or \
(reldir == 'config' and dir.startswith('goa')):
continue
dest = os.path.join(dirname, dir)
try:
@ -548,7 +551,8 @@ VERSION:3.0\r?
# evolution-addressbook-factory and that we may still need.
# Other DBs can be removed because we are not going to depend on
# them anymore thanks to the per-test uid prefix.
if reldir == 'data/evolution/addressbook/system':
if reldir == 'data/evolution/addressbook/system' or \
reldir.startswith('config/goa'):
continue
os.unlink(dest)

View file

@ -19,6 +19,7 @@ import shlex
import subprocess
import fnmatch
import copy
import errno
try:
import gzip
@ -48,6 +49,11 @@ def findInPaths(name, dirs):
return fullname
def del_dir(path):
# Preserve XDG dirs, if we were set up like that by caller.
# These dirs might already contain some relevant data.
xdgdirs = list(os.environ.get(x, None) for x in ("XDG_CONFIG_HOME", "XDG_DATA_HOME", "XDG_CACHE_HOME"))
if path in xdgdirs:
return
if not os.access(path, os.F_OK):
return
for file in os.listdir(path):
@ -58,8 +64,12 @@ def del_dir(path):
del_dir(file_or_dir) #it's a directory recursive call to function again
else:
os.remove(file_or_dir) #it's a file, delete it
os.rmdir(path)
# We might have skipped deleting something, allow that.
try:
os.rmdir(path)
except OSError, ex:
if ex.errno != errno.ENOTEMPTY:
raise
def copyLog(filename, dirname, htaccess, lineFilter=None):
"""Make a gzipped copy (if possible) with the original time stamps and find the most severe problem in it.
@ -575,6 +585,7 @@ class AutotoolsBuild(Action):
self.builddir = os.path.join(context.tmpdir, "build")
def execute(self):
print "removing builddir: %s" % self.builddir
del_dir(self.builddir)
cd(self.builddir)
context.runCommand("%s %s/configure %s" % (self.runner, self.src, self.configargs))