[glib: 3/4] GSubprocess test: Adjust the cwd test to pass on Windows



commit 1cc78bf082e93f1e53cc4bb56b9d9714a3699384
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date:   Mon Feb 11 23:55:08 2019 +0000

    GSubprocess test: Adjust the cwd test to pass on Windows
    
    There's no /tmp directory on Windows.
    Use g_get_tmp_dir(), and adjust the test to work with that.
    The test *still* checks the basename of the new CWD, it just
    doesn't need to be "tmp" anymore.

 gio/tests/gsubprocess.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gio/tests/gsubprocess.c b/gio/tests/gsubprocess.c
index 158366444..f0b36b764 100644
--- a/gio/tests/gsubprocess.c
+++ b/gio/tests/gsubprocess.c
@@ -1454,11 +1454,15 @@ test_cwd (void)
   GInputStream *stdout_stream;
   gchar *result;
   const char *basename;
+  gchar *tmp_lineend;
+  const gchar *tmp_lineend_basename;
 
   args = get_test_subprocess_args ("cwd", NULL);
   launcher = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDOUT_PIPE);
   g_subprocess_launcher_set_flags (launcher, G_SUBPROCESS_FLAGS_STDOUT_PIPE);
-  g_subprocess_launcher_set_cwd (launcher, "/tmp");
+  g_subprocess_launcher_set_cwd (launcher, g_get_tmp_dir ());
+  tmp_lineend = g_strdup_printf ("%s%s", g_get_tmp_dir (), LINEEND);
+  tmp_lineend_basename = g_strrstr (tmp_lineend, G_DIR_SEPARATOR_S);
 
   proc = g_subprocess_launcher_spawnv (launcher, (const char * const *)args->pdata, error);
   g_ptr_array_free (args, TRUE);
@@ -1468,9 +1472,10 @@ test_cwd (void)
 
   result = splice_to_string (stdout_stream, error);
 
-  basename = g_strrstr (result, "/");
+  basename = g_strrstr (result, G_DIR_SEPARATOR_S);
   g_assert (basename != NULL);
-  g_assert_cmpstr (basename, ==, "/tmp" LINEEND);
+  g_assert_cmpstr (basename, ==, tmp_lineend_basename);
+  g_free (tmp_lineend);
 
   g_free (result);
   g_object_unref (proc);


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