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,25 +2151,30 @@ 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);
g_timer_start (test_run_timer); if (test_paths_skipped && g_slist_find_custom (test_paths_skipped, test_run_name, (GCompareFunc)g_strcmp0))
fixture = tc->fixture_size ? g_malloc0 (tc->fixture_size) : tc->test_data; g_test_skip ("by request (-s option)");
test_run_seed (test_run_seedstr); else
if (tc->fixture_setup)
tc->fixture_setup (fixture, tc->test_data);
tc->fixture_test (fixture, tc->test_data);
test_trap_clear();
while (test_destroy_queue)
{ {
DestroyEntry *dentry = test_destroy_queue; g_timer_start (test_run_timer);
test_destroy_queue = dentry->next; fixture = tc->fixture_size ? g_malloc0 (tc->fixture_size) : tc->test_data;
dentry->destroy_func (dentry->destroy_data); test_run_seed (test_run_seedstr);
g_slice_free (DestroyEntry, dentry); if (tc->fixture_setup)
tc->fixture_setup (fixture, tc->test_data);
tc->fixture_test (fixture, tc->test_data);
test_trap_clear();
while (test_destroy_queue)
{
DestroyEntry *dentry = test_destroy_queue;
test_destroy_queue = dentry->next;
dentry->destroy_func (dentry->destroy_data);
g_slice_free (DestroyEntry, dentry);
}
if (tc->fixture_teardown)
tc->fixture_teardown (fixture, tc->test_data);
if (tc->fixture_size)
g_free (fixture);
g_timer_stop (test_run_timer);
} }
if (tc->fixture_teardown)
tc->fixture_teardown (fixture, tc->test_data);
if (tc->fixture_size)
g_free (fixture);
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 */