[gegl] test-buffer-sharing: Use temp path instead of pwd



commit 66c1026434b3876cd159b114703f94110291488b
Author: Jon Nordby <jononor gmail com>
Date:   Sun Jan 29 02:56:39 2017 +0100

    test-buffer-sharing: Use temp path instead of pwd

 tests/simple/.gitignore            |    1 -
 tests/simple/test-buffer-sharing.c |   21 ++++++++++++++-------
 2 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/tests/simple/.gitignore b/tests/simple/.gitignore
index 4e86370..f69167d 100644
--- a/tests/simple/.gitignore
+++ b/tests/simple/.gitignore
@@ -33,5 +33,4 @@
 /test-buffer-hot-tile
 /test-node-passthrough
 /test-serialize
-/test-buffer-sharing.data.gegl
 /test-buffer-sharing
diff --git a/tests/simple/test-buffer-sharing.c b/tests/simple/test-buffer-sharing.c
index 46975ca..94eccda 100644
--- a/tests/simple/test-buffer-sharing.c
+++ b/tests/simple/test-buffer-sharing.c
@@ -36,6 +36,8 @@ typedef struct _TestData {
     GeglBuffer *a;
     GeglBuffer *b;
     TestState state;
+    gchar *temp_dir;
+    gchar *file_path;
 } TestData;
 
 static void
@@ -164,14 +166,13 @@ on_timeout(gpointer user_data) {
 
 static void
 test_init(TestData *data) {
-    const gchar *file_path = "test-buffer-sharing.data.gegl";
 
-    // ensure we're starting from nothing
-    if (g_access(file_path, 0) == 0) {
-        g_remove(file_path);
-    }
     data->loop = g_main_loop_new(NULL, TRUE);
-    data->a = gegl_buffer_open(file_path);
+    data->temp_dir = g_strdup("test-buffer-sharing-XXXXXX");
+    data->temp_dir = g_mkdtemp(data->temp_dir);
+    data->file_path = g_strjoin(G_DIR_SEPARATOR_S, data->temp_dir, "buffer.gegl", NULL);
+
+    data->a = gegl_buffer_open(data->file_path);
     // FIXME: if not setting an extent and adding some data, the written on-disk file seems to be corrupt
     GeglRectangle rect = { 0, 0, 100, 100 };
     GeglColor *blank = gegl_color_new("transparent");
@@ -182,7 +183,7 @@ test_init(TestData *data) {
     sleep(1);
 
     // B observes the same on-disk buffer
-    data->b = gegl_buffer_open(file_path);
+    data->b = gegl_buffer_open(data->file_path);
     data->state = TestInitialized;
 
     gegl_buffer_signal_connect(data->b, "changed", on_buffer_changed, data);
@@ -192,6 +193,12 @@ test_init(TestData *data) {
 static void
 test_destroy(TestData *data) {
 
+    g_remove(data->file_path);
+    g_free(data->file_path);
+
+    g_rmdir(data->temp_dir);
+    g_free(data->temp_dir);
+
     g_object_unref(data->a);
     g_object_unref(data->b);
 }


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