[tracker-miners/sam/uninstalled-tests-fix: 3/4] Make TRACKER_TEST_DOMAIN_ONTOLOGY_RULE work even when Tracker is installed



commit 94c87ee42ea1c4adbac8b2efcfa68ade8f4d4ba3
Author: Sam Thursfield <sam afuera me uk>
Date:   Fri Apr 24 22:54:45 2020 +0200

    Make TRACKER_TEST_DOMAIN_ONTOLOGY_RULE work even when Tracker is installed
    
    After 241b0d89c59984a the functional tests behave differently
    depending on whether Tracker is installed in $prefix or not.
    The functional tests should always be able to use the uninstalled domain
    rule as this is what causes the uninstalled versions of the ontologies
    to be used.

 .../tracker-domain-ontology.c                       | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/src/libtracker-miners-common/tracker-domain-ontology.c 
b/src/libtracker-miners-common/tracker-domain-ontology.c
index 0e0dc4a7f..308cc0727 100644
--- a/src/libtracker-miners-common/tracker-domain-ontology.c
+++ b/src/libtracker-miners-common/tracker-domain-ontology.c
@@ -222,7 +222,7 @@ tracker_domain_ontology_new (const gchar   *domain_name,
        TrackerDomainOntology *domain_ontology;
        GError *inner_error = NULL;
        GKeyFile *key_file = NULL;
-       gchar *path, *path_for_tests;
+       gchar *path;
 
        domain_ontology = g_new0 (TrackerDomainOntology, 1);
        domain_ontology->name = g_strdup (domain_name);
@@ -249,19 +249,20 @@ tracker_domain_ontology_new (const gchar   *domain_name,
                        goto end;
                }
        } else {
-               path = g_build_filename (SHAREDIR, TRACKERSHAREDIR, "domain-ontologies",
-                                        DEFAULT_RULE, NULL);
-
-               if (!g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
+               if (g_getenv ("TRACKER_TEST_DOMAIN_ONTOLOGY_RULE")) {
                        /* This is only for uninstalled tests */
-                       path_for_tests = g_strdup (g_getenv ("TRACKER_TEST_DOMAIN_ONTOLOGY_RULE"));
+                       path = g_strdup (g_getenv ("TRACKER_TEST_DOMAIN_ONTOLOGY_RULE"));
 
-                       if (path_for_tests == NULL) {
-                               g_error ("Unable to find default domain ontology rule %s", path);
+                       if (!g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
+                               g_error ("Unable to find test domain ontology rule %s", path);
                        }
+               } else {
+                       path = g_build_filename (SHAREDIR, TRACKERSHAREDIR, "domain-ontologies",
+                                            DEFAULT_RULE, NULL);
 
-                       g_free (path);
-                       path = path_for_tests;
+                       if (!g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
+                               g_error ("Unable to find default domain ontology rule %s", path);
+                       }
                }
        }
 


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