gio/tests/gsubprocess.c: Fix on Windows
authorChun-wei Fan <fanchunwei@src.gnome.org>
Tue, 5 Nov 2013 09:33:09 +0000 (17:33 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Mon, 11 Nov 2013 14:38:05 +0000 (22:38 +0800)
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

gio/tests/gsubprocess.c

index f38bbdc..48de292 100644 (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);