[tracker/wip/carlosg/domain-ontologies: 124/124] libtracker-common: Add a last resort envvar to load default domain ontology
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/domain-ontologies: 124/124] libtracker-common: Add a last resort envvar to load default domain ontology
- Date: Thu, 29 Jun 2017 18:49:33 +0000 (UTC)
commit 377897231e864d0dd86529abd579dbc6187b07f3
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Jun 29 17:17:01 2017 +0200
libtracker-common: Add a last resort envvar to load default domain ontology
This can only be used if the default domain ontology file is not found, and
is now used on tests that do rely on the default tracker-store instance.
Also, add back the TRACKER_DB_ONTOLOGIES_DIR, under the same restrictions.
src/libtracker-common/tracker-domain-ontology.c | 12 ++++++++++++
src/libtracker-miner/Makefile.am | 2 +-
tests/libtracker-sparql/Makefile.am | 2 ++
tests/libtracker-sparql/tracker-gb-737023.c | 3 +++
tests/libtracker-sparql/tracker-sparql-test.c | 6 +++++-
tests/tracker-steroids/Makefile.am | 2 ++
tests/tracker-steroids/tracker-test.c | 2 ++
7 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-common/tracker-domain-ontology.c b/src/libtracker-common/tracker-domain-ontology.c
index 6b962d3..248cd7b 100644
--- a/src/libtracker-common/tracker-domain-ontology.c
+++ b/src/libtracker-common/tracker-domain-ontology.c
@@ -315,6 +315,12 @@ tracker_domain_ontology_initable_init (GInitable *initable,
} else {
path = g_build_filename (SHAREDIR, "tracker", "domain-ontologies",
DEFAULT_RULE, NULL);
+
+ if (!g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
+ /* This is only for uninstalled tests */
+ g_free (path);
+ path = g_strdup (g_getenv ("TRACKER_TEST_DOMAIN_ONTOLOGY_RULE"));
+ }
}
key_file = g_key_file_new ();
@@ -368,6 +374,12 @@ tracker_domain_ontology_initable_init (GInitable *initable,
ontology_path = g_build_filename (SHAREDIR, "tracker", "ontologies",
priv->ontology_name, NULL);
+
+ if (!g_file_test (ontology_path, G_FILE_TEST_IS_DIR)) {
+ g_free (ontology_path);
+ ontology_path = g_strdup (g_getenv ("TRACKER_DB_ONTOLOGIES_DIR"));
+ }
+
priv->ontology_location = g_file_new_for_path (ontology_path);
g_free (ontology_path);
}
diff --git a/src/libtracker-miner/Makefile.am b/src/libtracker-miner/Makefile.am
index 913fdb0..6737d88 100644
--- a/src/libtracker-miner/Makefile.am
+++ b/src/libtracker-miner/Makefile.am
@@ -158,7 +158,7 @@ INTROSPECTION_SCANNER_ARGS = \
--symbol-prefix=tracker \
--warn-all
-INTROSPECTION_COMPILER_ARGS = --includedir=$(top_srcdir)/src/libtracker-sparql-backend
+INTROSPECTION_COMPILER_ARGS = --includedir=$(top_builddir)/src/libtracker-sparql-backend
if HAVE_INTROSPECTION
INTROSPECTION_CFLAGS += $(AM_CPPFLAGS)
diff --git a/tests/libtracker-sparql/Makefile.am b/tests/libtracker-sparql/Makefile.am
index 388eb9c..ebc4137 100644
--- a/tests/libtracker-sparql/Makefile.am
+++ b/tests/libtracker-sparql/Makefile.am
@@ -12,6 +12,8 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src \
-I$(top_builddir)/src \
-I$(top_srcdir)/tests/common \
+ -DTEST_DOMAIN_ONTOLOGY_RULE=\""$(abs_top_srcdir)/src/tracker-store/default.rule"\" \
+ -DTEST_ONTOLOGIES_DIR=\""$(abs_top_srcdir)/src/ontologies/nepomuk"\" \
$(LIBTRACKER_SPARQL_CFLAGS)
LDADD = \
diff --git a/tests/libtracker-sparql/tracker-gb-737023.c b/tests/libtracker-sparql/tracker-gb-737023.c
index 816da6b..0955ffc 100644
--- a/tests/libtracker-sparql/tracker-gb-737023.c
+++ b/tests/libtracker-sparql/tracker-gb-737023.c
@@ -99,6 +99,9 @@ main (gint argc, gchar **argv)
setlocale (LC_ALL, "");
+ g_setenv ("TRACKER_TEST_DOMAIN_ONTOLOGY_RULE", TEST_DOMAIN_ONTOLOGY_RULE, TRUE);
+ g_setenv ("TRACKER_DB_ONTOLOGIES_DIR", TEST_ONTOLOGIES_DIR, TRUE);
+
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/libtracker-sparql/tracker/gb737023",
diff --git a/tests/libtracker-sparql/tracker-sparql-test.c b/tests/libtracker-sparql/tracker-sparql-test.c
index 5cd4b7a..9a73bd7 100644
--- a/tests/libtracker-sparql/tracker-sparql-test.c
+++ b/tests/libtracker-sparql/tracker-sparql-test.c
@@ -341,7 +341,8 @@ test_tracker_sparql_nb237150 (void)
*/
g_test_trap_subprocess ("/libtracker-sparql/tracker-sparql/nb237150/subprocess",
G_USEC_PER_SEC * 2,
- G_TEST_SUBPROCESS_INHERIT_STDOUT);
+ G_TEST_SUBPROCESS_INHERIT_STDOUT |
+ G_TEST_SUBPROCESS_INHERIT_STDERR);
g_test_trap_assert_passed ();
@@ -396,6 +397,9 @@ main (gint argc, gchar **argv)
setlocale (LC_ALL, "");
+ g_setenv ("TRACKER_TEST_DOMAIN_ONTOLOGY_RULE", TEST_DOMAIN_ONTOLOGY_RULE, TRUE);
+ g_setenv ("TRACKER_DB_ONTOLOGIES_DIR", TEST_ONTOLOGIES_DIR, TRUE);
+
g_test_init (&argc, &argv, NULL);
#if HAVE_TRACKER_FTS
diff --git a/tests/tracker-steroids/Makefile.am b/tests/tracker-steroids/Makefile.am
index 53c4e76..2e55538 100644
--- a/tests/tracker-steroids/Makefile.am
+++ b/tests/tracker-steroids/Makefile.am
@@ -10,6 +10,8 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src \
-I$(top_builddir)/src \
-I$(top_srcdir)/tests/common \
+ -DTEST_DOMAIN_ONTOLOGY_RULE=\""$(abs_top_srcdir)/src/tracker-store/default.rule"\" \
+ -DTEST_ONTOLOGIES_DIR=\""$(abs_top_srcdir)/src/ontologies/nepomuk"\" \
$(LIBTRACKER_SPARQL_CFLAGS)
LDADD = \
diff --git a/tests/tracker-steroids/tracker-test.c b/tests/tracker-steroids/tracker-test.c
index b5ed7d5..e9782dc 100644
--- a/tests/tracker-steroids/tracker-test.c
+++ b/tests/tracker-steroids/tracker-test.c
@@ -693,6 +693,8 @@ main (gint argc, gchar **argv)
/* test D-Bus backend */
g_setenv ("TRACKER_SPARQL_BACKEND", "bus", TRUE);
+ g_setenv ("TRACKER_TEST_DOMAIN_ONTOLOGY_RULE", TEST_DOMAIN_ONTOLOGY_RULE, TRUE);
+ g_setenv ("TRACKER_DB_ONTOLOGIES_DIR", TEST_ONTOLOGIES_DIR, TRUE);
connection = tracker_sparql_connection_get (NULL, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]