[gnome-software/skip-saving-install-queue] gs-plugin-loader: Skip saving install queue during unit tests



commit fa46f2e89680af32d5086685f31ef0bbcc4b22d1
Author: Phaedrus Leeds <matthew leeds endlessm com>
Date:   Thu Aug 13 12:23:58 2020 -0700

    gs-plugin-loader: Skip saving install queue during unit tests
    
    Currently some unit tests fail with a message like:
    Bail out! Gs-FATAL-WARNING: failed to create an app for */*/*/*/chiron.desktop/*
    
    This is because the tests are being run in parallel, and in
    gs_plugin_loader_setup() we load the install queue from the disk, but
    the queue is also being written to by other tests so it may have apps in
    it which can't be understood by the plugin being tested (chiron.desktop
    is only used by the dummy plugin).
    
    So avoid saving the install queue to disk during the unit tests.

 lib/gs-plugin-loader.c | 5 +++++
 meson.build            | 1 +
 2 files changed, 6 insertions(+)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 7783f778..51362f71 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -1808,6 +1808,11 @@ save_install_queue (GsPluginLoader *plugin_loader)
        g_autoptr(GString) s = NULL;
        g_autofree gchar *file = NULL;
 
+       /* Saving the install queue during unit tests could trip up other tests as
+        * they are run in parallel */
+       if (g_getenv ("GS_UNIT_TESTS_SKIP_SAVING_INSTALL_QUEUE") != NULL)
+               return;
+
        s = g_string_new ("");
        pending_apps = priv->pending_apps;
        g_mutex_lock (&priv->pending_apps_mutex);
diff --git a/meson.build b/meson.build
index 57488bc2..983f8092 100644
--- a/meson.build
+++ b/meson.build
@@ -236,6 +236,7 @@ test_env = [
   'GSETTINGS_SCHEMA_DIR=@0@/data/'.format(meson.build_root()),
   'GSETTINGS_BACKEND=memory',
   'MALLOC_CHECK_=2',
+  'GS_UNIT_TESTS_SKIP_SAVING_INSTALL_QUEUE=1',
 ]
 
 subdir('data')


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