[folks] tests: Fix creation of temporary directory for all unit tests



commit a1f42aeb278845dbf12be1d587a891995f3fb8de
Author: Philip Withnall <withnall endlessm com>
Date:   Sun Jul 2 20:50:56 2017 +0100

    tests: Fix creation of temporary directory for all unit tests
    
    A temporary directory was being created, but then the tests were writing
    all their files to the temporary directory *template* (i.e.
    ‘folks-test.XXXXXX’) because Vala doesn’t modify the template string in
    place with mkdtemp() calls.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 tests/lib/test-case.vala |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/tests/lib/test-case.vala b/tests/lib/test-case.vala
index bdf7930..cfed521 100644
--- a/tests/lib/test-case.vala
+++ b/tests/lib/test-case.vala
@@ -128,13 +128,14 @@ public abstract class Folks.TestCase : Object
   public virtual string create_transient_dir ()
     {
       unowned string tmp = Environment.get_tmp_dir ();
-      string transient = "%s/folks-test.XXXXXX".printf (tmp);
+      string transient_template = "%s/folks-test.XXXXXX".printf (tmp);
 
-      if (GLib.DirUtils.mkdtemp (transient) == null)
-        error ("unable to create temporary directory in '%s': %s",
+      string transient = GLib.DirUtils.mkdtemp (transient_template);
+      if (transient == null)
+        error ("Unable to create temporary directory in '%s': %s",
             tmp, GLib.strerror (GLib.errno));
 
-      debug ("setting up in transient directory %s", transient);
+      debug ("Setting up in transient directory %s", transient);
 
       /* Don't try to use dconf */
       Environment.set_variable ("GSETTINGS_BACKEND", "memory", true);


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