gio/tests/gsubprocess.c: Fix on Windows

We need to check for the correct line endings on Windows (\r\n) for the
echo tests and currently need to skip the test_echo_eof test there, as
it depends on the cat utility that is not normally found on Windows, and
using an external installation of cat via MSYS or Cygwin would render the
test program to hang as cat waits for user input.

https://bugzilla.gnome.org/show_bug.cgi?id=711047
This commit is contained in:
Chun-wei Fan 2013-11-05 17:33:09 +08:00
parent fd41363e02
commit b27a2d436b

View File

@ -8,6 +8,14 @@
#include <gio/gfiledescriptorbased.h>
#endif
#ifdef G_OS_WIN32
#define LINEEND "\r\n"
#define EXEEXT ".exe"
#else
#define LINEEND "\n"
#define EXEEXT
#endif
static GPtrArray *
get_test_subprocess_args (const char *mode,
...) G_GNUC_NULL_TERMINATED;
@ -199,7 +207,7 @@ test_echo1 (void)
result = splice_to_string (stdout, error);
g_assert_no_error (local_error);
g_assert_cmpstr (result, ==, "hello\nworld!\n");
g_assert_cmpstr (result, ==, "hello" LINEEND "world!" LINEEND);
g_free (result);
g_object_unref (proc);
@ -337,6 +345,11 @@ test_cat_eof (void)
gchar buffer;
gssize s;
#ifdef G_OS_WIN32
g_test_skip ("This test has not been ported to Win32");
return;
#endif
/* Spawn 'cat' */
cat = g_subprocess_new (G_SUBPROCESS_FLAGS_STDIN_PIPE | G_SUBPROCESS_FLAGS_STDOUT_PIPE, &error, "cat", NULL);
g_assert_no_error (error);