gtestutils: Add regression test for combining -s with --tap

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2018-12-20 17:45:46 +00:00
parent 1c77c93e81
commit 88bac46287
2 changed files with 43 additions and 0 deletions

View File

@ -101,6 +101,16 @@ main (int argc,
g_test_add_func ("/incomplete", test_incomplete);
g_test_add_func ("/fail", test_fail);
}
else if (g_strcmp0 (argv1, "skip-options") == 0)
{
/* The caller is expected to skip some of these with
* -p, -s and/or --GTestSkipCount */
g_test_add_func ("/a", test_pass);
g_test_add_func ("/b/a", test_pass);
g_test_add_func ("/b/b", test_pass);
g_test_add_func ("/c/a", test_pass);
g_test_add_func ("/d/a", test_pass);
}
else
{
g_assert_not_reached ();

View File

@ -1063,6 +1063,39 @@ test_tap (void)
g_assert_no_error (error);
g_ptr_array_unref (argv);
g_test_message ("-s");
argv = g_ptr_array_new ();
g_ptr_array_add (argv, (char *) testing_helper);
g_ptr_array_add (argv, "skip-options");
g_ptr_array_add (argv, "--tap");
g_ptr_array_add (argv, "-s");
g_ptr_array_add (argv, "/a");
g_ptr_array_add (argv, "-s");
g_ptr_array_add (argv, "/b");
g_ptr_array_add (argv, "-s");
g_ptr_array_add (argv, "/c/a");
g_ptr_array_add (argv, NULL);
g_spawn_sync (NULL, (char **) argv->pdata, NULL,
G_SPAWN_STDERR_TO_DEV_NULL,
NULL, NULL, &output, NULL, &status,
&error);
g_assert_no_error (error);
g_assert_nonnull (strstr (output, "1..5\n"));
g_assert_nonnull (strstr (output, "\nok 1 /a # SKIP by request"));
/* "-s /b" would skip a test named exactly /b, but not a test named
* /b/anything */
g_assert_nonnull (strstr (output, "\nok 2 /b/a\n"));
g_assert_nonnull (strstr (output, "\nok 3 /b/b\n"));
g_assert_nonnull (strstr (output, "\nok 4 /c/a # SKIP by request"));
g_assert_nonnull (strstr (output, "\nok 5 /d/a\n"));
g_spawn_check_exit_status (status, &error);
g_assert_no_error (error);
g_free (output);
g_ptr_array_unref (argv);
}
int