mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-05 08:56:16 +01:00
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
This commit is contained in:
parent
ea06ec8063
commit
723a8f5588
@ -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++;
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user