gtest: Handle -s as explicit SKIP instead of inhibiting altogether

Improves diagnostics and makes test transcripts easier to compare

https://bugzilla.gnome.org/show_bug.cgi?id=769135
This commit is contained in:
Daniel Macks 2017-08-03 12:43:00 +01:00 committed by Philip Withnall
parent f7a14fece4
commit f591366eee

View File

@ -1179,9 +1179,10 @@ g_test_init (int *argc,
/* sanity check */ /* sanity check */
if (test_tap_log) if (test_tap_log)
{ {
if (test_paths || test_paths_skipped || test_startup_skip_count) if (test_paths || test_startup_skip_count)
{ {
g_printerr ("%s: options that skip some tests are incompatible with --tap\n", /* Not invoking every test (even if SKIPped) breaks the "1..XX" plan */
g_printerr ("%s: -p and --GTestSkipCount options are incompatible with --tap\n",
(*argv)[0]); (*argv)[0]);
exit (1); exit (1);
} }
@ -1716,9 +1717,6 @@ g_test_add_vtable (const char *testpath,
g_return_if_fail (g_path_is_absolute (testpath)); g_return_if_fail (g_path_is_absolute (testpath));
g_return_if_fail (fixture_test_func != NULL); g_return_if_fail (fixture_test_func != NULL);
if (g_slist_find_custom (test_paths_skipped, testpath, (GCompareFunc)g_strcmp0))
return;
suite = g_test_get_root(); suite = g_test_get_root();
segments = g_strsplit (testpath, "/", -1); segments = g_strsplit (testpath, "/", -1);
for (ui = 0; segments[ui] != NULL; ui++) for (ui = 0; segments[ui] != NULL; ui++)
@ -2153,6 +2151,10 @@ test_case_run (GTestCase *tc)
test_run_success = G_TEST_RUN_SUCCESS; test_run_success = G_TEST_RUN_SUCCESS;
g_clear_pointer (&test_run_msg, g_free); g_clear_pointer (&test_run_msg, g_free);
g_test_log_set_fatal_handler (NULL, NULL); g_test_log_set_fatal_handler (NULL, NULL);
if (test_paths_skipped && g_slist_find_custom (test_paths_skipped, test_run_name, (GCompareFunc)g_strcmp0))
g_test_skip ("by request (-s option)");
else
{
g_timer_start (test_run_timer); g_timer_start (test_run_timer);
fixture = tc->fixture_size ? g_malloc0 (tc->fixture_size) : tc->test_data; fixture = tc->fixture_size ? g_malloc0 (tc->fixture_size) : tc->test_data;
test_run_seed (test_run_seedstr); test_run_seed (test_run_seedstr);
@ -2172,6 +2174,7 @@ test_case_run (GTestCase *tc)
if (tc->fixture_size) if (tc->fixture_size)
g_free (fixture); g_free (fixture);
g_timer_stop (test_run_timer); g_timer_stop (test_run_timer);
}
success = test_run_success; success = test_run_success;
test_run_success = G_TEST_RUN_FAILURE; test_run_success = G_TEST_RUN_FAILURE;
largs[0] = success; /* OK */ largs[0] = success; /* OK */