[glib: 1/3] gtestutils: Allow g_test_bug() to be used without g_test_bug_base()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/3] gtestutils: Allow g_test_bug() to be used without g_test_bug_base()
- Date: Wed, 21 Aug 2019 17:22:07 +0000 (UTC)
commit e7b857a44a23598b18fac3222e42ae40ad0f6409
Author: Philip Withnall <withnall endlessm com>
Date: Wed Aug 21 19:39:01 2019 +0300
gtestutils: Allow g_test_bug() to be used without g_test_bug_base()
Since we transitioned from Bugzilla to GitLab, we have two forms of bug
references in the GLib source code: old (but still relevant) Bugzilla
links, and newer GitLab links. We can’t use a single base for the two,
so have to either build incorrect URIs, or provide the full URI in
g_test_bug().
It’s always seemed a bit of an over-optimisation to provide the bug base
separately from the bug ID, so relax the assertions and documentation
around g_test_bug_base() so that g_test_bug() can be used on its own.
The old usage patterns are still supported unchanged.
Signed-off-by: Philip Withnall <withnall endlessm com>
glib/gtestutils.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index 881789087..80f7b4961 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -150,7 +150,6 @@
* setlocale (LC_ALL, "");
*
* g_test_init (&argc, &argv, NULL);
- * g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=");
*
* // Define the tests.
* g_test_add ("/my-object/test1", MyObjectFixture, "some-user-data",
@@ -1887,6 +1886,9 @@ g_test_message (const char *format,
* portion to @uri_pattern, or by replacing the special string
* '\%s' within @uri_pattern if that is present.
*
+ * If g_test_bug_base() is not called, bug URIs are formed solely
+ * from the value provided by g_test_bug().
+ *
* Since: 2.16
*/
void
@@ -1903,7 +1905,9 @@ g_test_bug_base (const char *uri_pattern)
* This function adds a message to test reports that
* associates a bug URI with a test case.
* Bug URIs are constructed from a base URI set with g_test_bug_base()
- * and @bug_uri_snippet.
+ * 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
+ * g_test_bug() instead.
*
* Since: 2.16
* See also: g_test_summary()
@@ -1911,12 +1915,12 @@ g_test_bug_base (const char *uri_pattern)
void
g_test_bug (const char *bug_uri_snippet)
{
- char *c;
+ const char *c = NULL;
- g_return_if_fail (test_uri_base != NULL);
g_return_if_fail (bug_uri_snippet != NULL);
- c = strstr (test_uri_base, "%s");
+ if (test_uri_base != NULL)
+ c = strstr (test_uri_base, "%s");
if (c)
{
char *b = g_strndup (test_uri_base, c - test_uri_base);
@@ -1926,7 +1930,8 @@ g_test_bug (const char *bug_uri_snippet)
g_free (s);
}
else
- g_test_message ("Bug Reference: %s%s", test_uri_base, bug_uri_snippet);
+ g_test_message ("Bug Reference: %s%s",
+ test_uri_base ? test_uri_base : "", bug_uri_snippet);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]