gtestutils: Allow full URIs in g_test_bug()

Even if `g_test_bug_base()` has been called.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/275#note_303175

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2021-05-13 21:57:40 +01:00
parent 0f7950f199
commit 46ab6821a3

View File

@ -2029,15 +2029,19 @@ g_test_bug_base (const char *uri_pattern)
/** /**
* g_test_bug: * g_test_bug:
* @bug_uri_snippet: Bug specific bug tracker URI portion. * @bug_uri_snippet: Bug specific bug tracker URI or URI portion.
* *
* This function adds a message to test reports that * This function adds a message to test reports that
* associates a bug URI with a test case. * associates a bug URI with a test case.
*
* Bug URIs are constructed from a base URI set with g_test_bug_base() * Bug URIs are constructed from a base URI set with g_test_bug_base()
* and @bug_uri_snippet. If g_test_bug_base() has not been called, it is * and @bug_uri_snippet. If g_test_bug_base() has not been called, it is
* assumed to be the empty string, so a full URI can be provided to * assumed to be the empty string, so a full URI can be provided to
* g_test_bug() instead. * g_test_bug() instead.
* *
* Since GLib 2.70, the base URI is not prepended to @bug_uri_snippet if it
* is already a valid URI.
*
* Since: 2.16 * Since: 2.16
* See also: g_test_summary() * See also: g_test_summary()
*/ */
@ -2048,6 +2052,13 @@ g_test_bug (const char *bug_uri_snippet)
g_return_if_fail (bug_uri_snippet != NULL); g_return_if_fail (bug_uri_snippet != NULL);
if (g_str_has_prefix (bug_uri_snippet, "http:") ||
g_str_has_prefix (bug_uri_snippet, "https:"))
{
g_test_message ("Bug Reference: %s", bug_uri_snippet);
return;
}
if (test_uri_base != NULL) if (test_uri_base != NULL)
c = strstr (test_uri_base, "%s"); c = strstr (test_uri_base, "%s");
if (c) if (c)