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.
This commit is contained in:
Руслан Ижбулатов 2019-02-11 23:55:08 +00:00 committed by Philip Withnall
parent 4bc1aa23a9
commit 1cc78bf082

View File

@ -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);