[libmediaart] tests: Don't clear existing caches with unit tests, set XDG_CACHE_HOME



commit 3efb47019cca38752bf60f29222c0b4b38d6c201
Author: Martyn Russell <martyn lanedo com>
Date:   Wed Sep 10 09:54:58 2014 +0100

    tests: Don't clear existing caches with unit tests, set XDG_CACHE_HOME
    
    https://bugzilla.gnome.org/show_bug.cgi?id=731681

 tests/mediaarttest.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/tests/mediaarttest.c b/tests/mediaarttest.c
index 4abb08b..df34497 100644
--- a/tests/mediaarttest.c
+++ b/tests/mediaarttest.c
@@ -379,11 +379,17 @@ test_mediaart_process_failures_subprocess (void)
 int
 main (int argc, char **argv)
 {
+       const gchar *cache_home_originally;
+       const gchar *test_dir;
        gint success = EXIT_SUCCESS;
        gint i;
 
         g_test_init (&argc, &argv, NULL);
 
+       test_dir = g_test_get_dir (G_TEST_BUILT);
+       cache_home_originally = g_getenv ("XDG_CACHE_HOME");
+       g_setenv ("XDG_CACHE_HOME", test_dir, TRUE);
+
         g_test_add ("/mediaart/new", TestInfo, NULL, setup, test_mediaart_new, teardown);
 
        for (i = 0; strip_test_cases[i].test_name; i++) {
@@ -414,5 +420,11 @@ main (int argc, char **argv)
 
         success = g_test_run ();
 
+        if (cache_home_originally) {
+               g_setenv ("XDG_CACHE_HOME", cache_home_originally, TRUE);
+        } else {
+               g_unsetenv ("XDG_CACHE_HOME");
+        }
+
         return success;
 }


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