[gnome-software/wip/hughsie/libxmlb: 7/13] trivial: Allow self tests to override the chosen cachedir



commit c5da3742a50baae2323e6e7cbcda6f7a2fab8669
Author: Richard Hughes <richard hughsie com>
Date:   Mon Oct 15 12:25:29 2018 +0100

    trivial: Allow self tests to override the chosen cachedir

 lib/gs-utils.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/lib/gs-utils.c b/lib/gs-utils.c
index 23d24995..dbb7c1cc 100644
--- a/lib/gs-utils.c
+++ b/lib/gs-utils.c
@@ -165,11 +165,17 @@ gs_utils_get_cache_filename (const gchar *kind,
                             GsUtilsCacheFlags flags,
                             GError **error)
 {
+       const gchar *tmp;
        g_autofree gchar *basename = NULL;
        g_autofree gchar *cachedir = NULL;
        g_autoptr(GFile) cachedir_file = NULL;
        g_autoptr(GPtrArray) candidates = g_ptr_array_new_with_free_func (g_free);
 
+       /* in the self tests */
+       tmp = g_getenv ("GS_SELF_TEST_CACHEDIR");
+       if (tmp != NULL)
+               return g_build_filename (tmp, kind, resource, NULL);
+
        /* get basename */
        if (flags & GS_UTILS_CACHE_FLAG_USE_HASH) {
                g_autofree gchar *basename_tmp = g_path_get_basename (resource);


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