[glib] glib/tests/spawn-singlethread: Improve test for Windows
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] glib/tests/spawn-singlethread: Improve test for Windows
- Date: Mon, 11 Nov 2013 14:44:19 +0000 (UTC)
commit a7707ec60ba8155c345df58d414060e177f15804
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Wed Nov 6 15:14:06 2013 +0800
glib/tests/spawn-singlethread: Improve test for Windows
Use a Windows-style .bat script for the test_spawn_script() test, at least
when the code is built with Visual C++ (due to differences in how scripts
are written for shells and Windows cmd.exe), and account for Windows-style
line endings for that test too.
Let the MinGW builds (which are normally done in an MSYS BASH-style shell) continue to use the
*NIX-style script for that test.
https://bugzilla.gnome.org/show_bug.cgi?id=711047
glib/tests/Makefile.am | 1 +
glib/tests/echo-script.bat | 2 ++
glib/tests/spawn-singlethread.c | 22 +++++++++++++++++++---
3 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/glib/tests/Makefile.am b/glib/tests/Makefile.am
index eaa99ae..65598b4 100644
--- a/glib/tests/Makefile.am
+++ b/glib/tests/Makefile.am
@@ -22,6 +22,7 @@ dist_test_data = \
dist_test_extra_scripts = \
echo-script \
+ echo-script.bat \
$(NULL)
test_extra_programs = \
diff --git a/glib/tests/echo-script.bat b/glib/tests/echo-script.bat
new file mode 100644
index 0000000..96c45c2
--- /dev/null
+++ b/glib/tests/echo-script.bat
@@ -0,0 +1,2 @@
+ echo off
+echo echo
diff --git a/glib/tests/spawn-singlethread.c b/glib/tests/spawn-singlethread.c
index d205822..7985eef 100644
--- a/glib/tests/spawn-singlethread.c
+++ b/glib/tests/spawn-singlethread.c
@@ -26,6 +26,22 @@
#include <glib.h>
#include <string.h>
+#ifdef G_OS_WIN32
+#define LINEEND "\r\n"
+#else
+#define LINEEND "\n"
+#endif
+
+/* MinGW builds are likely done using a BASH-style shell, so run the
+ * normal script there, as on non-Windows builds, as it is more likely
+ * that one will run 'make check' in such shells to test the code
+ */
+#if defined (G_OS_WIN32) && defined (_MSC_VER)
+#define SCRIPT_EXT ".bat"
+#else
+#define SCRIPT_EXT
+#endif
+
static char *echo_prog_path;
static char *echo_script_path;
@@ -179,7 +195,7 @@ test_spawn_script (void)
g_spawn_sync (NULL, (char**)argv->pdata, NULL, 0, NULL, NULL, &stdout_str, NULL, &estatus, &error);
g_assert_no_error (error);
- g_assert_cmpstr ("echo\n", ==, stdout_str);
+ g_assert_cmpstr ("echo" LINEEND, ==, stdout_str);
g_free (stdout_str);
g_ptr_array_free (argv, TRUE);
}
@@ -200,11 +216,11 @@ main (int argc,
g_free (echo_prog_path);
echo_prog_path = g_build_filename (dirname, "lt-test-spawn-echo" EXEEXT, NULL);
}
- echo_script_path = g_build_filename (dirname, "echo-script", NULL);
+ echo_script_path = g_build_filename (dirname, "echo-script" SCRIPT_EXT, NULL);
if (!g_file_test (echo_script_path, G_FILE_TEST_EXISTS))
{
g_free (echo_script_path);
- echo_script_path = g_test_build_filename (G_TEST_DIST, "echo-script", NULL);
+ echo_script_path = g_test_build_filename (G_TEST_DIST, "echo-script" SCRIPT_EXT, NULL);
}
g_free (dirname);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]