[tracker/sam/ft-dirs] functional-tests: Rationalize handling of test directories
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/sam/ft-dirs] functional-tests: Rationalize handling of test directories
- Date: Sat, 5 Jan 2019 14:43:37 +0000 (UTC)
commit 31bd258a921603cff7ceadead8155a8a8c4ad413
Author: Sam Thursfield <sam afuera me uk>
Date: Sat Jan 5 15:41:55 2019 +0100
functional-tests: Rationalize handling of test directories
This corresponds with a fix from tracker-miners.git in
https://gitlab.gnome.org/GNOME/tracker-miners/merge_requests/27.
tests/functional-tests/17-ontology-changes.py | 40 +++++++++++++---------
.../functional-tests/common/utils/configuration.py | 13 -------
2 files changed, 24 insertions(+), 29 deletions(-)
---
diff --git a/tests/functional-tests/17-ontology-changes.py b/tests/functional-tests/17-ontology-changes.py
index fcfe0074b..dbc36fa25 100755
--- a/tests/functional-tests/17-ontology-changes.py
+++ b/tests/functional-tests/17-ontology-changes.py
@@ -64,6 +64,12 @@ class TrackerSystemAbstraction (object):
def __init__(self, settings=None):
self.store = None
+ def xdg_data_home(self):
+ return os.path.join(self._basedir, 'data')
+
+ def xdg_cache_home(self):
+ return os.path.join(self._basedir, 'cache')
+
def set_up_environment (self, settings=None, ontodir=None):
"""
Sets up the XDG_*_HOME variables and make sure the directories exist
@@ -73,14 +79,17 @@ class TrackerSystemAbstraction (object):
should map key->value, where key is a key name and value is a suitable
GLib.Variant instance.
"""
+ self._basedir = tempfile.mkdtemp()
- for var, directory in TEST_ENV_DIRS.iteritems ():
- helpers.log ("export %s=%s" %(var, directory))
- self.__recreate_directory (directory)
- os.environ [var] = directory
+ self._dirs = {
+ "XDG_DATA_HOME" : self.xdg_data_home(),
+ "XDG_CACHE_HOME": self.xdg_cache_home()
+ }
- for directory in EXTRA_DIRS:
- self.__recreate_directory (directory)
+ for var, directory in self._dirs.items():
+ os.makedirs (directory)
+ os.makedirs (os.path.join(directory, 'tracker'))
+ os.environ [var] = directory
if ontodir:
helpers.log ("export %s=%s" % ("TRACKER_DB_ONTOLOGIES_DIR", ontodir))
@@ -120,17 +129,17 @@ class TrackerSystemAbstraction (object):
except GLib.Error:
raise UnableToBootException ("Unable to boot the store \n(" + str(e) + ")")
- def tracker_store_testing_stop (self):
+ def finish (self):
"""
- Stops a running tracker-store
+ Stop all running processes and remove all test data.
"""
- assert self.store
- self.store.stop ()
- def __recreate_directory (self, directory):
- if (os.path.exists (directory)):
- shutil.rmtree (directory)
- os.makedirs (directory)
+ if self.store:
+ self.store.stop ()
+
+ for path in self._dirs.values():
+ shutil.rmtree(path)
+ os.rmdir(self._basedir)
class OntologyChangeTestTemplate (ut.TestCase):
@@ -154,8 +163,7 @@ class OntologyChangeTestTemplate (ut.TestCase):
self.system = TrackerSystemAbstraction ()
def tearDown (self):
- if self.system.store is not None:
- self.system.tracker_store_testing_stop ()
+ self.system.finish()
def template_test_ontology_change (self):
diff --git a/tests/functional-tests/common/utils/configuration.py
b/tests/functional-tests/common/utils/configuration.py
index c8a125bae..5d965f6d2 100644
--- a/tests/functional-tests/common/utils/configuration.py
+++ b/tests/functional-tests/common/utils/configuration.py
@@ -86,19 +86,6 @@ TRACKER_STORE_PATH = os.path.normpath(expandvars(config['TRACKER_STORE_PATH']))
disableJournal = (len(config['disableJournal']) == 0)
-TEST_TMP_DIR = os.path.join (os.environ["HOME"], "tracker-tests")
-
-TEST_MONITORED_TMP_DIR = TEST_TMP_DIR
-
-if TEST_TMP_DIR.startswith('/tmp'):
- if os.environ.has_key('REAL_HOME'):
- TEST_MONITORED_TMP_DIR = os.path.join (os.environ["REAL_HOME"], "tracker-tests")
- else:
- print ("HOME is in the /tmp prefix - this will cause tests that rely " +
- "on filesystem monitoring to fail as changes in that prefix are " +
- "ignored.")
-
-
def generated_ttl_dir():
if TOP_BUILDDIR:
return os.path.join(TOP_BUILDDIR, 'tests', 'functional-tests', 'ttl')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]