[glib] gtestutils: fix "-p" logic
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gtestutils: fix "-p" logic
- Date: Wed, 19 Dec 2012 19:49:18 +0000 (UTC)
commit 723a8f55880f1e7bf1b475901ce40e6cd443b72d
Author: Dan Winship <danw gnome org>
Date: Sat Aug 25 11:54:31 2012 -0400
gtestutils: fix "-p" logic
If you had two tests "/foo/bar" and "/foo/bar/baz", and ran the test
program with "-p /foo/bar/baz", it would run "/foo/bar" too. Fix that.
And add a test to tests/testing for it.
https://bugzilla.gnome.org/show_bug.cgi?id=679683
glib/gtestutils.c | 2 +-
glib/tests/testing.c | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 126 insertions(+), 1 deletions(-)
---
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index 0fabe84..f281949 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -1835,7 +1835,7 @@ g_test_run_suite_internal (GTestSuite *suite,
{
GTestCase *tc = slist->data;
guint n = l ? strlen (tc->name) : 0;
- if (l == n && strncmp (path, tc->name, n) == 0)
+ if (l == n && !rest && strncmp (path, tc->name, n) == 0)
{
if (!test_case_run (tc))
n_bad++;
diff --git a/glib/tests/testing.c b/glib/tests/testing.c
index b9695d1..a6c0cb4 100644
--- a/glib/tests/testing.c
+++ b/glib/tests/testing.c
@@ -450,6 +450,121 @@ test_expected_messages (void)
g_test_trap_assert_stderr ("*Did not see expected message CRITICAL*nope*");
}
+static void
+test_dash_p_colon (void)
+{
+ if (!g_test_subprocess ())
+ g_assert_not_reached ();
+
+ g_print ("Test /misc/dash-p:colon ran\n");
+}
+
+/* The rest of the dash_p tests will get run by the toplevel test
+ * process, but they shouldn't do anything there.
+ */
+static void
+test_dash_p_colon_sub (void)
+{
+ if (!g_test_subprocess ())
+ return;
+
+ g_print ("Test /misc/dash-p:colon/sub ran\n");
+}
+
+static void
+test_dash_p_colon_sub2 (void)
+{
+ if (!g_test_subprocess ())
+ return;
+
+ g_print ("Test /misc/dash-p:colon/sub2 ran\n");
+}
+
+static void
+test_dash_p_colon_sub_child (void)
+{
+ if (!g_test_subprocess ())
+ return;
+
+ g_print ("Test /misc/dash-p:colon/sub:child ran\n");
+}
+
+static void
+test_dash_p_slash (void)
+{
+ if (!g_test_subprocess ())
+ return;
+
+ g_print ("Test /misc/dash-p/slash ran\n");
+}
+
+static void
+test_dash_p_slash_sub (void)
+{
+ if (!g_test_subprocess ())
+ return;
+
+ g_print ("Test /misc/dash-p/slash/sub ran\n");
+}
+
+static void
+test_dash_p_slash_sub2 (void)
+{
+ if (!g_test_subprocess ())
+ return;
+
+ g_print ("Test /misc/dash-p/slash/sub2 ran\n");
+}
+
+static void
+test_dash_p_slash_sub_child (void)
+{
+ if (!g_test_subprocess ())
+ return;
+
+ g_print ("Test /misc/dash-p/slash/sub:child ran\n");
+}
+
+static void
+test_dash_p (void)
+{
+ g_test_trap_subprocess ("/misc/dash-p:colon", 0,
+ G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR);
+ g_test_trap_assert_passed ();
+ g_test_trap_assert_stdout ("*Test /misc/dash-p:colon ran*");
+ g_test_trap_assert_stdout ("*Test /misc/dash-p:colon/sub ran*");
+ g_test_trap_assert_stdout ("*Test /misc/dash-p:colon/sub2 ran*");
+ g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p:colon/sub:child ran*");
+ g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/slash*");
+
+ g_test_trap_subprocess ("/misc/dash-p:colon/sub", 0,
+ G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR);
+ g_test_trap_assert_passed ();
+ g_test_trap_assert_stdout ("*Test /misc/dash-p:colon/sub ran*");
+ g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p:colon ran*");
+ g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p:colon/sub2 ran*");
+ g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p:colon/sub:child ran*");
+ g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/slash*");
+
+ g_test_trap_subprocess ("/misc/dash-p/slash", 0,
+ G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR);
+ g_test_trap_assert_passed ();
+ g_test_trap_assert_stdout ("*Test /misc/dash-p/slash ran*");
+ g_test_trap_assert_stdout ("*Test /misc/dash-p/slash/sub ran*");
+ g_test_trap_assert_stdout ("*Test /misc/dash-p/slash/sub2 ran*");
+ g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/slash/sub:child ran*");
+ g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p:colon*");
+
+ g_test_trap_subprocess ("/misc/dash-p/slash/sub", 0,
+ G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR);
+ g_test_trap_assert_passed ();
+ g_test_trap_assert_stdout ("*Test /misc/dash-p/slash/sub ran*");
+ g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/slash ran*");
+ g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/slash/sub2 ran*");
+ g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p/slash/sub:child ran*");
+ g_test_trap_assert_stdout_unmatched ("*Test /misc/dash-p:colon*");
+}
+
int
main (int argc,
char *argv[])
@@ -499,5 +614,15 @@ main (int argc,
g_test_add_func ("/misc/expected-messages:extra-warning", test_expected_messages_extra_warning);
g_test_add_func ("/misc/expected-messages:unexpected-extra-warning", test_expected_messages_unexpected_extra_warning);
+ g_test_add_func ("/misc/dash-p", test_dash_p);
+ g_test_add_func ("/misc/dash-p:colon", test_dash_p_colon);
+ g_test_add_func ("/misc/dash-p:colon/sub", test_dash_p_colon_sub);
+ g_test_add_func ("/misc/dash-p:colon/sub:child", test_dash_p_colon_sub_child);
+ g_test_add_func ("/misc/dash-p:colon/sub2", test_dash_p_colon_sub2);
+ g_test_add_func ("/misc/dash-p/slash", test_dash_p_slash);
+ g_test_add_func ("/misc/dash-p/slash/sub", test_dash_p_slash_sub);
+ g_test_add_func ("/misc/dash-p/slash/sub:child", test_dash_p_slash_sub_child);
+ g_test_add_func ("/misc/dash-p/slash/sub2", test_dash_p_slash_sub2);
+
return g_test_run();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]