[glib: 2/4] gtestutils: Allow full URIs in g_test_bug()




commit 46ab6821a30909503296e44a3ec222097d8b262e
Author: Philip Withnall <pwithnall endlessos org>
Date:   Thu May 13 21:57:40 2021 +0100

    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>

 glib/gtestutils.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index 58c59ca26..2c3ea24a8 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -2029,15 +2029,19 @@ g_test_bug_base (const char *uri_pattern)
 
 /**
  * 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
  * 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. 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 GLib 2.70, the base URI is not prepended to @bug_uri_snippet if it
+ * is already a valid URI.
+ *
  * Since: 2.16
  * 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);
 
+  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)
     c = strstr (test_uri_base, "%s");
   if (c)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]