[gjs] installed-tests: Avoid usage of GI_TYPELIB_PATH to override lookups



commit 482d25155505d442c73bb0c9b6bc58aba524d514
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu May 5 11:49:53 2016 +0200

    installed-tests: Avoid usage of GI_TYPELIB_PATH to override lookups
    
    As of gobject-introspection bd475c00d96, this environment variable won't
    override the search paths set through g_irepository_prepend_search_path,
    so use this function in tests, ensuring that it overrides search paths
    added internally by the GjsContext.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=765905

 Makefile-test.am             |    2 +-
 installed-tests/gjs-unit.cpp |   10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/Makefile-test.am b/Makefile-test.am
index 5d9274f..648b375 100644
--- a/Makefile-test.am
+++ b/Makefile-test.am
@@ -110,6 +110,7 @@ check-local: gjs-tests
 # resources
 TESTS_ENVIRONMENT =                                                    \
        TOP_SRCDIR=$(abs_top_srcdir)                                    \
+       TOP_BUILDDIR=$(abs_top_builddir)                                \
        DBUS_SESSION_BUS_ADDRESS=''                                     \
        XDG_DATA_HOME=test_user_data                                    \
        GJS_DEBUG_OUTPUT=test_user_data/logs/gjs.log                    \
@@ -117,7 +118,6 @@ TESTS_ENVIRONMENT =                                                 \
        GJS_USE_UNINSTALLED_FILES=1                                     \
        GJS_TEST_TIMEOUT=420                                            \
        GJS_PATH= \
-       GI_TYPELIB_PATH=$(builddir):$(GI_TYPELIB_PATH)                                  \
        LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(FIREFOX_JS_LIBDIR)"       \
        G_FILENAME_ENCODING=latin1      # ensure filenames are not utf8 \
        UUIDGEN="$(UUIDGEN)"
diff --git a/installed-tests/gjs-unit.cpp b/installed-tests/gjs-unit.cpp
index 3f93364..def4a38 100644
--- a/installed-tests/gjs-unit.cpp
+++ b/installed-tests/gjs-unit.cpp
@@ -147,6 +147,7 @@ main(int argc, char **argv)
     char *js_test_dir;
     GSList *all_tests, *iter;
     GSList *all_registered_test_data = NULL;
+    gpointer context_class;
     int retval;
 
     /* The tests are known to fail in the presence of the JIT;
@@ -160,8 +161,13 @@ main(int argc, char **argv)
     setlocale(LC_ALL, "");
     g_test_init(&argc, &argv, NULL);
 
+    /* Make sure to create the GjsContext class first, so we
+     * can override the GjsPrivate lookup path.
+     */
+    context_class = g_type_class_ref (gjs_context_get_type ());
+
     if (g_getenv ("GJS_USE_UNINSTALLED_FILES") != NULL) {
-        /* typelib path is handled by the environment */
+        g_irepository_prepend_search_path(g_getenv ("TOP_BUILDDIR"));
         js_test_dir = g_build_filename(g_getenv ("TOP_SRCDIR"), "installed-tests", "js", NULL);
     } else {
         g_irepository_prepend_search_path(INSTTESTDIR);
@@ -207,5 +213,7 @@ main(int argc, char **argv)
                     all_registered_test_data);
     g_slist_free(all_registered_test_data);
 
+    g_type_class_unref (context_class);
+
     return retval;
 }


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