[tracker/wip/sam/meson-functional-tests] functional-tests: Fix configuration to work with Meson



commit d8cddb51fc8b4c341bb928674034b47fe1c0e723
Author: Sam Thursfield <sam thursfield codethink co uk>
Date:   Wed Nov 1 18:05:50 2017 +0000

    functional-tests: Fix configuration to work with Meson
    
    Previously the functional-test suite would test the installed version of
    Tracker, but would need to be run from a configured Tracker source+build tree.
    
    I have changed how things are configured and now with Meson the functional tests
    can be run completely from the build tree, without needing to install
    anything. The Autotools `make functional-test` target works the same as
    before.
    
    Instead of generating a Python source file that contains the build-time
    configuration, we write that to a .json file which is read when the
    common.utils.configuration module is imported. This controls the
    locations of the various things that the tests require, which allows us
    to support any kind fo build tree layout.
    
    With the new setup it should also be possible to add a target that
    explicitly installs the functional tests, with a different
    configuration.json file such that they test the installed version of
    Tracker. That's not yet implemented.

 configure.ac                                       |    5 ++-
 meson.build                                        |   16 +++++++
 tests/functional-tests/10-sqlite-misused.py        |   27 +++++++-----
 tests/functional-tests/11-sqlite-batch-misused.py  |   27 ++++++------
 tests/functional-tests/13-threaded-store.py        |    4 +-
 tests/functional-tests/17-ontology-changes.py      |   11 +----
 tests/functional-tests/Makefile.am                 |    4 ++
 tests/functional-tests/common/utils/.gitignore     |    1 -
 tests/functional-tests/common/utils/Makefile.am    |    4 +-
 .../{configuration.py.in => configuration.py}      |   45 ++++++++++++--------
 tests/functional-tests/common/utils/helpers.py     |   13 ++++--
 tests/functional-tests/common/utils/system.py      |    5 +-
 tests/functional-tests/configuration.json.in       |    8 ++++
 tests/functional-tests/ipc/meson.build             |   30 +++++++++----
 tests/functional-tests/meson.build                 |   37 +++++++++++++---
 15 files changed, 156 insertions(+), 81 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2098e7a..fa88b4b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -443,6 +443,9 @@ fi
 
 AM_CONDITIONAL(DIST_FUNCTIONAL_TESTS, test "x$enable_functional_tests" != "xno")
 
+AC_SUBST(FUNCTIONAL_TESTS_ONTOLOGIES_DIR, "${datadir}/tracker-tests/test-ontologies")
+AC_SUBST(FUNCTIONAL_TESTS_TRACKER_STORE_PATH, "${libexecdir}/tracker-store")
+
 ####################################################################
 # Check for gtk-doc and docbook-tools
 ####################################################################
@@ -936,9 +939,9 @@ AC_CONFIG_FILES([
        tests/libtracker-fts/prefix/Makefile
        tests/libtracker-sparql/Makefile
        tests/functional-tests/Makefile
+       tests/functional-tests/configuration.json
        tests/functional-tests/ipc/Makefile
        tests/functional-tests/common/Makefile
-       tests/functional-tests/common/utils/configuration.py
        tests/functional-tests/common/utils/Makefile
        tests/functional-tests/unittest2/Makefile
        tests/functional-tests/test-ontologies/Makefile
diff --git a/meson.build b/meson.build
index 17173b2..e70e9e0 100644
--- a/meson.build
+++ b/meson.build
@@ -223,6 +223,9 @@ conf.set('TRACKER_BINARY_AGE', 100 * tracker_minor_version + tracker_micro_versi
 
 # Config that goes in some other generated files (.desktop, .pc, etc)
 conf.set('exec_prefix', get_option('prefix'))
+conf.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
+conf.set('datadir', join_paths(get_option('prefix'), get_option('datadir')))
+conf.set('datarootdir', join_paths(get_option('prefix'), get_option('datadir')))
 conf.set('includedir', join_paths(get_option('prefix'), get_option('includedir')))
 conf.set('libdir', join_paths(get_option('prefix'), get_option('libdir')))
 conf.set('libexecdir', join_paths(get_option('prefix'), get_option('libexecdir')))
@@ -230,6 +233,19 @@ conf.set('prefix', get_option('prefix'))
 conf.set('TRACKER_API_VERSION', tracker_api_version)
 conf.set('VERSION', meson.project_version())
 
+# Configure functional tests to run completely from source tree.
+conf.set('FUNCTIONAL_TESTS_ONTOLOGIES_DIR', join_paths(meson.current_source_dir(), 'tests', 
'functional-tests', 'test-ontologies'))
+conf.set('FUNCTIONAL_TESTS_TRACKER_STORE_PATH', join_paths(meson.current_build_dir(), 'src', 
'tracker-store', 'tracker-store'))
+
+# This is set in an awkward way for compatibility with Autoconf. Switch it
+# to a normal boolean once we get rid of the Autotools build system. It's
+# only used in tests/functional-tests/common/utils/configuration.py.in.
+if get_option('journal')
+    conf.set('DISABLE_JOURNAL_TRUE', 'true')
+else
+    conf.set('DISABLE_JOURNAL_TRUE', '')
+endif
+
 configure_file(input: 'config.h.meson.in',
                output: 'config.h',
                configuration: conf)
diff --git a/tests/functional-tests/10-sqlite-misused.py b/tests/functional-tests/10-sqlite-misused.py
index e9203e3..0b7dc9d 100755
--- a/tests/functional-tests/10-sqlite-misused.py
+++ b/tests/functional-tests/10-sqlite-misused.py
@@ -36,20 +36,24 @@ class TestSqliteMisused (CommonTrackerStoreTest):
     def setUp (self):
         self.main_loop = GObject.MainLoop ()
         self.files_counter = 0
-        
+
     def test_queries_while_import (self):
-        self.assertTrue (os.path.exists ('ttl'))
-        for root, dirs, files in os.walk('ttl'):
+        assert os.path.isdir(cfg.generated_ttl_dir())
+
+        for root, dirs, files in os.walk(cfg.generated_ttl_dir()):
             for ttl_file in filter (lambda f: f.endswith (".ttl"), files):
                 full_path = os.path.abspath(os.path.join (root, ttl_file))
                 self.files_counter += 1
-                self.tracker.query(
+
+                self.tracker.load(
                     "file://" + full_path, timeout=30000,
                     result_handler=self.loaded_success_cb,
-                    error_handler=self.loaded_failed_cb)
+                    error_handler=self.loaded_failed_cb,
+                    user_data = full_path)
 
         GObject.timeout_add_seconds (2, self.run_a_query)
         # Safeguard of 60 seconds. The last reply should quit the loop
+        # It doesn't matter if we didn't import all of the files yet.
         GObject.timeout_add_seconds (60, self.timeout_cb)
         self.main_loop.run ()
 
@@ -64,19 +68,18 @@ class TestSqliteMisused (CommonTrackerStoreTest):
     def reply_cb (self, obj, results, data):
         print "Query replied correctly"
 
-    def error_handler (self, error_msg):
-        print "ERROR in DBus call", error_msg
+    def error_handler (self, obj, error, data):
+        print "ERROR in DBus call: %s" % error
 
-    def loaded_success_cb (self, obj, results, data):
+    def loaded_success_cb (self, obj, results, user_data):
         self.files_counter -= 1
         if (self.files_counter == 0):
             print "Last file loaded"
             self.timeout_cb ()
-        print "Success loading a file"
+        print "Success loading %s" % user_data
 
-    def loaded_failed_cb (self, error):
-        print "Failed loading a file"
-        self.assertTrue (False)
+    def loaded_failed_cb (self, obj, error, user_data):
+        raise RuntimeError("Failed loading %s: %s" % (user_data, error))
 
     def timeout_cb (self):
         print "Forced timeout after 60 sec."
diff --git a/tests/functional-tests/11-sqlite-batch-misused.py 
b/tests/functional-tests/11-sqlite-batch-misused.py
index c4ef0be..cc810f2 100755
--- a/tests/functional-tests/11-sqlite-batch-misused.py
+++ b/tests/functional-tests/11-sqlite-batch-misused.py
@@ -41,11 +41,11 @@ class TestSqliteBatchMisused (CommonTrackerStoreTest):
     def setUp (self):
         self.main_loop = GObject.MainLoop ()
         self.batch_counter = 0
-        
+
     def test_queries_while_batch_insert (self):
-        self.assertTrue (os.path.exists ('ttl'))
-        
-        for root, dirs, files in os.walk('ttl'):
+        self.assertTrue (os.path.exists (cfg.generated_ttl_dir()))
+
+        for root, dirs, files in os.walk(cfg.generated_ttl_dir()):
             for ttl_file in filter (lambda f: f.endswith (".ttl"), files):
                 full_path = os.path.abspath(os.path.join (root, ttl_file))
                 print full_path
@@ -58,10 +58,10 @@ class TestSqliteBatchMisused (CommonTrackerStoreTest):
                     current_batch += line
                     if len(line) > 1 and line[:-1].endswith ('.'):
                         counter += 1
-                
-                    if counter == BATCH_SIZE:
+
+                    if counter >= BATCH_SIZE:
                         query = "INSERT {" + current_batch + "}"
-                        self.tracker.batch_update(
+                        token = self.tracker.batch_update(
                             query,
                             timeout=20000,
                             result_handler=self.batch_success_cb,
@@ -70,8 +70,7 @@ class TestSqliteBatchMisused (CommonTrackerStoreTest):
                         counter = 0
                         current_batch = ""
                         self.batch_counter += 1
-                        
-        
+
         GObject.timeout_add_seconds (2, self.run_a_query)
         # Safeguard of 60 seconds. The last reply should quit the loop
         GObject.timeout_add_seconds (60, self.timeout_cb)
@@ -84,22 +83,24 @@ class TestSqliteBatchMisused (CommonTrackerStoreTest):
             reply_handler=self.reply_cb,
             error_handler=self.error_handler)
         return True
-        
+
     def reply_cb (self, obj, results, data):
         print "Query replied correctly"
 
     def error_handler (self, error_msg):
         print "Query failed", error_msg
+        raise error_msg
 
-    def batch_success_cb (self):
+    def batch_success_cb (self, obj, result, user_data):
         self.batch_counter -= 1
         if (self.batch_counter == 0):
             print "Last batch was success"
             self.timeout_cb ()
         print "Success processing a batch"
 
-    def batch_failed_cb (self, error):
-        print "Failed processing a batch"
+    def batch_failed_cb (self, obj, error, user_data):
+        print "Failed processing a batch: %s" % error
+        raise error
 
     def timeout_cb (self):
         print "Forced timeout after 60 sec."
diff --git a/tests/functional-tests/13-threaded-store.py b/tests/functional-tests/13-threaded-store.py
index 55d76c1..d24da78 100755
--- a/tests/functional-tests/13-threaded-store.py
+++ b/tests/functional-tests/13-threaded-store.py
@@ -52,7 +52,7 @@ class TestThreadedStore (CommonTrackerStoreTest):
 
     def __populate_database (self):
 
-        self.assertTrue (os.path.exists ('ttl'))
+        self.assertTrue (os.path.exists (cfg.generated_ttl_dir()))
         for ttl_file in ["010-nco_EmailAddress.ttl",
                          "011-nco_PostalAddress.ttl",
                          "012-nco_PhoneNumber.ttl",
@@ -61,7 +61,7 @@ class TestThreadedStore (CommonTrackerStoreTest):
                          "018-nco_PersonContact.ttl",
                          "012-nco_PhoneNumber.ttl",
                          "016-nco_ContactIM.ttl"]:
-            full_path = os.path.abspath(os.path.join ("ttl", ttl_file))
+            full_path = os.path.abspath(os.path.join (cfg.generated_ttl_dir(), ttl_file))
             print full_path
             self.tracker.get_tracker_iface().Load(
                 '(s)', "file://" + full_path, timeout=30000)
diff --git a/tests/functional-tests/17-ontology-changes.py b/tests/functional-tests/17-ontology-changes.py
index 8665a5d..3a5581e 100755
--- a/tests/functional-tests/17-ontology-changes.py
+++ b/tests/functional-tests/17-ontology-changes.py
@@ -62,19 +62,14 @@ class OntologyChangeTestTemplate (ut.TestCase):
     """
         
     def get_ontology_dir (self, param):
-        local = os.path.join (os.getcwd (), "test-ontologies", param)
-        if (os.path.exists (local)):
-            # Use local directory if available
-            return local
-        else:
-            return os.path.join (cfg.DATADIR, "tracker-tests",
-                                    "test-ontologies", param)
+        return os.path.join(cfg.TEST_ONTOLOGIES_DIR, param)
 
     def setUp (self):
         self.system = TrackerSystemAbstraction ()
 
     def tearDown (self):
-        self.system.tracker_store_testing_stop ()
+        if self.system.store is not None:
+            self.system.tracker_store_testing_stop ()
 
     def template_test_ontology_change (self):
 
diff --git a/tests/functional-tests/Makefile.am b/tests/functional-tests/Makefile.am
index db62255..ddad7e0 100644
--- a/tests/functional-tests/Makefile.am
+++ b/tests/functional-tests/Makefile.am
@@ -8,6 +8,7 @@ SUBDIRS = \
 configdir = $(datadir)/tracker-tests
 
 config_DATA = \
+       configuration.json \
        trackertest
 
 config_SCRIPTS = \
@@ -51,16 +52,19 @@ TEST_RUNNER = $(top_srcdir)/tests/functional-tests/test-runner.sh
 
 functional-test: ${standard_tests}
        for test in ${standard_tests} ; do \
+               export 
TRACKER_FUNCTIONAL_TEST_CONFIG=$(top_builddir)/tests/functional-tests/configuration.json ; \
                $(TEST_RUNNER) python $(top_srcdir)/tests/functional-tests/$$test; \
        done
 
 functional-test-slow: ${slow_tests}
        @for test in ${slow_tests} ; do \
+               export 
TRACKER_FUNCTIONAL_TEST_CONFIG=$(top_builddir)/tests/functional-tests/configuration.json \
                $(TEST_RUNNER) python $(top_srcdir)/tests/functional-tests/$$test; \
        done
 
 EXTRA_DIST = \
        $(config_SCRIPTS) \
        $(config_DATA) \
+       configuration.json.in \
        test-runner.sh \
        meson.build
diff --git a/tests/functional-tests/common/utils/Makefile.am b/tests/functional-tests/common/utils/Makefile.am
index b32b781..2f989d5 100644
--- a/tests/functional-tests/common/utils/Makefile.am
+++ b/tests/functional-tests/common/utils/Makefile.am
@@ -10,6 +10,4 @@ utils_SCRIPTS =                                        \
        options.py                                     \
        system.py
 
-EXTRA_DIST =                                           \
-       configuration.py.in                            \
-       $(utils_SCRIPTS)
+EXTRA_DIST = $(utils_SCRIPTS)
diff --git a/tests/functional-tests/common/utils/configuration.py.in 
b/tests/functional-tests/common/utils/configuration.py
similarity index 70%
rename from tests/functional-tests/common/utils/configuration.py.in
rename to tests/functional-tests/common/utils/configuration.py
index 6bc3b1b..182bdce 100644
--- a/tests/functional-tests/common/utils/configuration.py.in
+++ b/tests/functional-tests/common/utils/configuration.py
@@ -20,8 +20,17 @@
 
 "Constants describing Tracker D-Bus services"
 
+import json
 import os
 
+if 'TRACKER_FUNCTIONAL_TEST_CONFIG' not in os.environ:
+    raise RuntimeError("The TRACKER_FUNCTIONAL_TEST_CONFIG environment "
+                       "variable must be set to point to the location of "
+                       "the generated configuration.json file.")
+
+with open(os.environ['TRACKER_FUNCTIONAL_TEST_CONFIG']) as f:
+    config = json.load(f)
+
 TRACKER_BUSNAME = 'org.freedesktop.Tracker1'
 TRACKER_OBJ_PATH = '/org/freedesktop/Tracker1/Resources'
 RESOURCES_IFACE = "org.freedesktop.Tracker1.Resources"
@@ -32,7 +41,7 @@ MINER_IFACE = "org.freedesktop.Tracker1.Miner"
 MINERFS_INDEX_OBJ_PATH = "/org/freedesktop/Tracker1/Miner/Files/Index"
 MINER_INDEX_IFACE = "org.freedesktop.Tracker1.Miner.Files.Index"
 
-TRACKER_BACKUP_OBJ_PATH = "/org/freedesktop/Tracker1/Backup"                                            
+TRACKER_BACKUP_OBJ_PATH = "/org/freedesktop/Tracker1/Backup"
 BACKUP_IFACE = "org.freedesktop.Tracker1.Backup"
 
 TRACKER_STATS_OBJ_PATH = "/org/freedesktop/Tracker1/Statistics"
@@ -49,6 +58,8 @@ WRITEBACK_BUSNAME = "org.freedesktop.Tracker1.Writeback"
 
 DCONF_MINER_SCHEMA = "org.freedesktop.Tracker.Miner.Files"
 
+# Autoconf substitutes paths in the configuration.json file without
+# expanding variables, so we need to manually insert these.
 def expandvars (variable):
     # Note: the order matters!
     result = variable
@@ -57,29 +68,18 @@ def expandvars (variable):
                        ("${prefix}", PREFIX)]:
         result = result.replace (var, value)
 
-
     return result
 
 
+PREFIX = config['PREFIX']
+RAW_EXEC_PREFIX = config['RAW_EXEC_PREFIX']
+RAW_DATAROOT_DIR = config['RAW_DATAROOT_DIR']
 
-PREFIX = "@prefix@"
-#
-# This raw variables are set by autotools without translating vars:
-#   E.G. bindir='${exec_prefix}/bin
-#
-# So we do the translation by hand in the expandvars function
-#
-RAW_EXEC_PREFIX = "@exec_prefix@"
-RAW_EXEC_DIR = "@libexecdir@"
-RAW_DATA_DIR = "@datadir@"
-RAW_DATAROOT_DIR = "@datarootdir@"
-RAW_BINDIR = "@bindir@"
+TEST_ONTOLOGIES_DIR = os.path.normpath(expandvars(config['TEST_ONTOLOGIES_DIR']))
 
-EXEC_PREFIX = os.path.normpath (expandvars (RAW_EXEC_DIR))
-DATADIR = os.path.normpath (expandvars (RAW_DATA_DIR))
-BINDIR = os.path.normpath (expandvars (RAW_BINDIR))
+TRACKER_STORE_PATH = os.path.normpath(expandvars(config['TRACKER_STORE_PATH']))
 
-disableJournal = ("@DISABLE_JOURNAL_TRUE@" == "")
+disableJournal = (len(config['disableJournal']) == 0)
 
 TEST_TMP_DIR = os.path.join (os.environ["HOME"], "tracker-tests")
 
@@ -92,3 +92,12 @@ if TEST_TMP_DIR.startswith('/tmp'):
                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.")
+
+
+BUILD_DIR = os.environ.get('TRACKER_FUNCTIONAL_TEST_BUILD_DIR')
+
+def generated_ttl_dir():
+    if BUILD_DIR:
+        return os.path.join(BUILD_DIR, 'tests', 'functional-tests', 'ttl')
+    else:
+        return 'ttl'
diff --git a/tests/functional-tests/common/utils/helpers.py b/tests/functional-tests/common/utils/helpers.py
index d085e26..95e4840 100644
--- a/tests/functional-tests/common/utils/helpers.py
+++ b/tests/functional-tests/common/utils/helpers.py
@@ -78,9 +78,7 @@ class Helper:
         sys.excepthook = new_hook
 
     def _start_process (self):
-        path = getattr (self,
-                        "PROCESS_PATH",
-                        os.path.join (cfg.EXEC_PREFIX, self.PROCESS_NAME))
+        path = self.PROCESS_PATH
         flags = getattr (self,
                          "FLAGS",
                          [])
@@ -93,7 +91,10 @@ class Helper:
 
         command = [path] + flags
         log ("Starting %s" % ' '.join(command))
-        return subprocess.Popen ([path] + flags, **kws)
+        try:
+            return subprocess.Popen ([path] + flags, **kws)
+        except OSError as e:
+            raise RuntimeError("Error starting %s: %s" % (path, e))
 
     def _bus_name_appeared(self, name, owner, data):
         log ("[%s] appeared in the bus as %s" % (self.PROCESS_NAME, owner))
@@ -212,6 +213,7 @@ class StoreHelper (Helper):
     """
 
     PROCESS_NAME = "tracker-store"
+    PROCESS_PATH = cfg.TRACKER_STORE_PATH
     BUS_NAME = cfg.TRACKER_BUSNAME
 
     graph_updated_handler_id = 0
@@ -469,6 +471,9 @@ class StoreHelper (Helper):
     def update (self, update_sparql, timeout=5000, **kwargs):
         return self.resources.SparqlUpdate ('(s)', update_sparql, timeout=timeout, **kwargs)
 
+    def load (self, ttl_uri, timeout=5000, **kwargs):
+        return self.resources.Load ('(s)', ttl_uri, timeout=timeout, **kwargs)
+
     def batch_update (self, update_sparql, **kwargs):
         return self.resources.BatchSparqlUpdate ('(s)', update_sparql, **kwargs)
 
diff --git a/tests/functional-tests/common/utils/system.py b/tests/functional-tests/common/utils/system.py
index bf8433d..3d15a37 100644
--- a/tests/functional-tests/common/utils/system.py
+++ b/tests/functional-tests/common/utils/system.py
@@ -19,9 +19,7 @@ import helpers
 TEST_ENV_DIRS =  { "XDG_DATA_HOME" : os.path.join (cfg.TEST_TMP_DIR, "data"),
                    "XDG_CACHE_HOME": os.path.join (cfg.TEST_TMP_DIR, "cache")}
 
-TEST_ENV_VARS = {  "LC_COLLATE": "en_GB.utf8",
-                   "DCONF_PROFILE": os.path.join (cfg.DATADIR, "tracker-tests",
-                                                  "trackertest") }
+TEST_ENV_VARS = {  "LC_COLLATE": "en_GB.utf8" }
 
 EXTRA_DIRS = [os.path.join (cfg.TEST_TMP_DIR, "data", "tracker"),
               os.path.join (cfg.TEST_TMP_DIR, "cache", "tracker")]
@@ -35,6 +33,7 @@ class UnableToBootException (Exception):
 class TrackerSystemAbstraction (object):
     def __init__(self, settings=None, ontodir=None):
         self.set_up_environment (settings=settings, ontodir=ontodir)
+        self.store = None
 
     def set_up_environment (self, settings=None, ontodir=None):
         """
diff --git a/tests/functional-tests/configuration.json.in b/tests/functional-tests/configuration.json.in
new file mode 100644
index 0000000..06a5be1
--- /dev/null
+++ b/tests/functional-tests/configuration.json.in
@@ -0,0 +1,8 @@
+{
+    "PREFIX": "@prefix@",
+    "RAW_EXEC_PREFIX": "@exec_prefix@",
+    "RAW_DATAROOT_DIR": "@datarootdir@",
+    "TEST_ONTOLOGIES_DIR": "@FUNCTIONAL_TESTS_ONTOLOGIES_DIR@",
+    "TRACKER_STORE_PATH": "@FUNCTIONAL_TESTS_TRACKER_STORE_PATH@",
+    "disableJournal": "@DISABLE_JOURNAL_TRUE@"
+}
diff --git a/tests/functional-tests/ipc/meson.build b/tests/functional-tests/ipc/meson.build
index c458ac8..5b88160 100644
--- a/tests/functional-tests/ipc/meson.build
+++ b/tests/functional-tests/ipc/meson.build
@@ -1,53 +1,63 @@
 insert_or_replace_test = executable('test-insert-or-replace',
   'test-insert-or-replace.vala',
   dependencies: [tracker_common_dep, tracker_sparql_dep])
-test('functional-ipc-insert-or-replace', insert_or_replace_test)
+test('functional-ipc-insert-or-replace', insert_or_replace_test,
+  env: test_env)
 
 busy_handling_test = executable('test-busy-handling',
   'test-busy-handling.vala',
   dependencies: [tracker_common_dep, tracker_sparql_dep])
-test('functional-ipc-busy-handling', busy_handling_test)
+test('functional-ipc-busy-handling', busy_handling_test,
+  env: test_env)
 
 direct_query_test = executable('test-direct-query',
   'test-direct-query.vala',
   'test-shared-query.vala',
   dependencies: [tracker_common_dep, tracker_sparql_dep])
-test('functional-ipc-direct-query', direct_query_test)
+test('functional-ipc-direct-query', direct_query_test,
+  env: test_env)
 
 bus_query_test = executable('test-bus-query',
   'test-bus-query.vala',
   'test-shared-query.vala',
   dependencies: [tracker_common_dep, tracker_sparql_dep, tracker_sparql_bus_dep])
-test('functional-ipc-bus-query', bus_query_test)
+test('functional-ipc-bus-query', bus_query_test,
+  env: test_env)
 
 default_update_test = executable('test-default-update',
   'test-default-update.vala',
   'test-shared-update.vala',
   dependencies: [tracker_common_dep, tracker_sparql_dep])
-test('functional-ipc-default-update', default_update_test)
+test('functional-ipc-default-update', default_update_test,
+  env: test_env)
 
 bus_update_test = executable('test-bus-update',
   'test-bus-update.vala',
   'test-shared-update.vala',
   dependencies: [tracker_common_dep, tracker_sparql_dep, tracker_sparql_bus_dep])
-test('functional-ipc-bus-update', bus_update_test)
+test('functional-ipc-bus-update', bus_update_test,
+  env: test_env)
 
 class_signal_test = executable('test-class-signal',
   'test-class-signal.vala',
   dependencies: [tracker_common_dep, tracker_sparql_dep])
-test('functional-ipc-class-signal', class_signal_test)
+test('functional-ipc-class-signal', class_signal_test,
+  env: test_env)
 
 class_signal_performance_test = executable('test-class-signal-performance',
   'test-class-signal-performance.vala',
   dependencies: [tracker_common_dep, tracker_sparql_dep])
-test('functional-ipc-class-signal-performance', class_signal_performance_test)
+test('functional-ipc-class-signal-performance', class_signal_performance_test,
+  env: test_env)
 
 class_signal_performance_batch_test = executable('test-class-signal-performance-batch',
   'test-class-signal-performance-batch.vala',
   dependencies: [tracker_common_dep, tracker_sparql_dep])
-test('functional-ipc-class-signal-performance-batch', class_signal_performance_batch_test)
+test('functional-ipc-class-signal-performance-batch', class_signal_performance_batch_test,
+  env: test_env)
 
 update_array_performance_test = executable('test-update-array-performance',
   'test-update-array-performance.c',
   dependencies: [tracker_common_dep, tracker_sparql_dep])
-test('functional-ipc-update-array-performance', update_array_performance_test)
+test('functional-ipc-update-array-performance', update_array_performance_test,
+  env: test_env)
diff --git a/tests/functional-tests/meson.build b/tests/functional-tests/meson.build
index 8261e14..57de81f 100644
--- a/tests/functional-tests/meson.build
+++ b/tests/functional-tests/meson.build
@@ -1,7 +1,11 @@
-subdir('ipc')
-
 test_runner = find_program('test-runner.sh')
 
+config_json = configure_file(
+  input: 'configuration.json.in',
+  output: 'configuration.json',
+  configuration: conf
+)
+
 functional_tests = [
   '01-insertion',
   '02-sparql-bugs',
@@ -12,10 +16,7 @@ functional_tests = [
   '07-graph',
   '08-unique-insertions',
   '09-concurrent-query',
-  '10-sqlite-misused',
-  '11-sqlite-batch-misused',
   '12-transactions',
-  '13-threaded-store',
   '14-signals',
   '15-statistics',
   '16-collation',
@@ -23,10 +24,34 @@ functional_tests = [
   '200-backup-restore',
 ]
 
-foreach t: functional_tests
+subdir('ttl')
+functional_tests_with_test_data = [
+  '10-sqlite-misused',
+  '11-sqlite-batch-misused',
+  '13-threaded-store',
+]
+
+config_json_full_path = join_paths(meson.current_build_dir(), 'configuration.json')
+dconf_profile_full_path = join_paths(meson.current_source_dir(), 'trackertest')
+tracker_nepomuk_ontologies = join_paths(meson.current_source_dir(), '..', '..', 'src', 'ontologies', 
'nepomuk')
+tracker_stop_words_dir = join_paths(meson.current_source_dir(), '..', '..', 'src', 'libtracker-common', 
'stop-words')
+tracker_test_domain_ontology = join_paths(meson.current_source_dir(), '..', '..', 'src', 'tracker-store', 
'default.rule')
+
+test_env = environment()
+test_env.set('DCONF_PROFILE', dconf_profile_full_path)
+
+test_env.set('TRACKER_DB_ONTOLOGIES_DIR', tracker_nepomuk_ontologies)
+test_env.set('TRACKER_FUNCTIONAL_TEST_CONFIG', config_json_full_path)
+test_env.set('TRACKER_LANGUAGE_STOP_WORDS_DIR', tracker_stop_words_dir)
+test_env.set('TRACKER_TEST_DOMAIN_ONTOLOGY_RULE', tracker_test_domain_ontology)
+
+foreach t: functional_tests + functional_tests_with_test_data
   test('functional-' + t, test_runner,
     args: './' + t + '.py',
+    env: test_env,
     workdir: meson.current_source_dir(),
     # FIXME: these tests are all too slow
     timeout: 180)
 endforeach
+
+subdir('ipc')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]