Test what happens when GTestSkipCount is 0 or more than number of tests

Using --GTestSkipCount 0 is the same as omitting it. A skip count
greater than the number of tests is the same as equalling the number
of tests: they are all skipped.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2019-04-29 16:02:09 +01:00
parent bcee67e29c
commit dfec3c6789

View File

@ -1091,6 +1091,60 @@ test_tap (void)
g_free (output);
g_ptr_array_unref (argv);
g_test_message ("--GTestSkipCount=0 is the same as omitting it");
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, "--GTestSkipCount");
g_ptr_array_add (argv, "0");
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\n"));
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\n"));
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);
g_test_message ("--GTestSkipCount > number of tests skips all");
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, "--GTestSkipCount");
g_ptr_array_add (argv, "6");
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\n"));
g_assert_nonnull (strstr (output, "\nok 2 /b/a # SKIP\n"));
g_assert_nonnull (strstr (output, "\nok 3 /b/b # SKIP\n"));
g_assert_nonnull (strstr (output, "\nok 4 /c/a # SKIP\n"));
g_assert_nonnull (strstr (output, "\nok 5 /d/a # SKIP\n"));
g_spawn_check_exit_status (status, &error);
g_assert_no_error (error);
g_free (output);
g_ptr_array_unref (argv);
g_test_message ("-p");
argv = g_ptr_array_new ();
g_ptr_array_add (argv, (char *) testing_helper);