Subject: [bug#50035] [PATCH 3/3] gnu: go-github-com-godbus-dbus-v5: Fix and enable tests.

From: Sarah Morgensen <[email-masked]>
Date: Thu, 12 Aug 2021 20:12:59 -0700

Disable system D-Bus tests.  Fix session D-Bus tests by running them
within our own session.

* gnu/packages/golang.scm (go-github-com-godbus-dbus-v5)[source]: Add
snippet to disable system D-Bus tests.
[arguments]: Enable tests, override 'check phase to run tests within a
dbus session.
---
 gnu/packages/golang.scm | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 359c5a987d..28ead635f2 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -7431,13 +7431,27 @@ and @code{ioutil} packages that is easy to test.")
                     (url "https://github.com/godbus/dbus")
                     (commit (string-append "v" version))))
               (file-name (git-file-name name version))
+              (modules '((guix build utils)))
+              (snippet
+               '(begin
+                  ;; Disable tests which require a system D-Bus instance.
+                  (substitute* "conn_test.go"
+                    (("func TestSystemBus")
+                     "func DisabledTestSystemBus")
+                    (("func TestConnectSystemBus")
+                     "func DisabledTestConnectSystemBus"))))
               (sha256
                (base32
                 "0znax8kskb5gmp5fj75w56bc9p7b22wrdswzlh4d04sprlc471yi"))))
     (build-system go-build-system)
     (arguments
-     `(#:tests? #f ;no /var/run/dbus/system_bus_socket
-       #:import-path "github.com/godbus/dbus"))
+     `(#:import-path "github.com/godbus/dbus"
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'check
+           (lambda* (#:key tests? import-path #:allow-other-keys)
+             (when tests?
+               (invoke "dbus-run-session" "--" "go" "test" import-path)))))))
     (native-inputs
      `(("dbus" ,dbus))) ;dbus-launch
     (home-page "https://github.com/godbus/dbus/")
-- 
2.31.1