[PATCH go-team] build-system/go: Allow providing additional test flags.

  • Done
  • quality assurance status badge
Details
2 participants
  • Sharlatan Hellseher
  • Troy Figiel
Owner
unassigned
Submitted by
Troy Figiel
Severity
normal
T
T
Troy Figiel wrote on 25 Feb 10:06 +0100
(address . guix-patches@gnu.org)
87a5noaot3.fsf@troyfigiel.com
By allowing the use of test flags, we can more precisely skip failing tests
(for go version >=1.20), disable the vetting stage or select a subset of tests
(e.g. if an upstream flag is provided to skip tests which require a network
connection). At the moment, the only way around these test failures is to
remove the test file completely or patch the code ourselves.

* guix/build-system/go.scm (go-build): Add test-flags variable.
(go-cross-build): Add test-flags variable.
* guix/build/go-build-system.scm (check): Pass the additional test flags to the invoke call.
---
guix/build-system/go.scm | 4 ++++
guix/build/go-build-system.scm | 8 +++++---
2 files changed, 9 insertions(+), 3 deletions(-)

Toggle diff (61 lines)
diff --git a/guix/build-system/go.scm b/guix/build-system/go.scm
index 0934fded07..eb78a289f2 100644
--- a/guix/build-system/go.scm
+++ b/guix/build-system/go.scm
@@ -184,6 +184,7 @@ (define* (go-build name inputs
(unpack-path "")
(build-flags ''())
(tests? #t)
+ (test-flags ''())
(allow-go-reference? #f)
(system (%current-system))
(goarch #f)
@@ -214,6 +215,7 @@ (define builder
#:unpack-path #$unpack-path
#:build-flags #$build-flags
#:tests? #$tests?
+ #:test-flags #$test-flags
#:allow-go-reference? #$allow-go-reference?
#:inputs #$(input-tuples->gexp inputs)))))
@@ -236,6 +238,7 @@ (define* (go-cross-build name
(unpack-path "")
(build-flags ''())
(tests? #f) ; nothing can be done
+ (test-flags ''())
(allow-go-reference? #f)
(system (%current-system))
(goarch (first (go-target target)))
@@ -285,6 +288,7 @@ (define %outputs
#:unpack-path #$unpack-path
#:build-flags #$build-flags
#:tests? #$tests?
+ #:test-flags #$test-flags
#:make-dynamic-linker-cache? #f ;cross-compiling
#:allow-go-reference? #$allow-go-reference?
#:inputs %build-inputs))))
diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm
index 7f25e05d0d..24b5ec1f05 100644
--- a/guix/build/go-build-system.scm
+++ b/guix/build/go-build-system.scm
@@ -271,11 +271,13 @@ (define* (build #:key import-path build-flags #:allow-other-keys)
"Here are the results of `go env`:\n"))
(invoke "go" "env"))))
-;; Can this also install commands???
-(define* (check #:key tests? import-path #:allow-other-keys)
+;; go test builds a test binary (or multiple binaries), vets the code and then
+;; runs the test binary. Build, test and test binary flags can be provided as
+;; test-flags. See "go help test" and "go help testflag" for more details.
+(define* (check #:key tests? import-path test-flags #:allow-other-keys)
"Run the tests for the package named by IMPORT-PATH."
(when tests?
- (invoke "go" "test" import-path))
+ (apply invoke "go" "test" `(,import-path ,@test-flags)))
#t)
(define* (install #:key install-source? outputs import-path unpack-path #:allow-other-keys)

base-commit: 1306beaf3f6c8ddded2a956f5863bc65aad78882
--
2.42.0
T
S
S
Sharlatan Hellseher wrote on 7 Mar 23:59 +0100
[PATCH go-team] build-system/go: Allow providing additional test flags.
(address . 69376@debbugs.gnu.org)
87cys54pid.fsf@gmail.com
Hi Troy,

Thank you for the work!

The patch looks reasonable. Does it allow us to run all available tests
as we discussed in

One nitpick about this section:
Toggle snippet (4 lines)
+;; go test builds a test binary (or multiple binaries), vets the code and then
+;; runs the test binary. Build, test and test binary flags can be provided as
+;; test-flags. See "go help test" and "go help testflag" for more details.
It is a good material for documentation section, how about to move it
from this comment and compile a proper documentation note describing
#:test-flags for go-build-system?

Something like this:
Toggle snippet (4 lines)
#:test-flags is added. The default is '(). These flags are passed as
arguments to the test command. Note that flags for verbose output is
always enabled on supported backends.
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEmEeB3micIcJkGAhndtcnv/Ys0rUFAmXqRtoACgkQdtcnv/Ys
0rXTag/+Ombeg5CKHNO2q3hukk33hlQrXCg/tzBGhKgfKxfS0j+OGzk3Tyn6ky+A
X9q0uooSb/i0rhsdYJp84C098KhI+Vpu+MjG8/RttHNLtQmbYRqZ8aJIv/XeGzHs
om4gkcL+wC114vSIf2Me30S2ygsOjUmuZv+0gisnc2HYjkvBWiNeo9RT5C+gYbf5
VMlStAP1beCeAqkHhj4kQXD7i08bOh0RpDmk+LMvrdxOp4KL4f6VTYlPKHXIm6IY
BD1UnrEs3eBdnsx02szWTfqzNTSwRdchSYZQgZx6A0TJdI3KJvetstRNyC0n3giO
unkL+HHPx11a4D2oOqUM87dI2IKiG/uAVDw21JggyzX733qj3KaQGc8DrCP/npk2
0Tt19bLGiIWgdkm94XZ9N1GHmjPJ2YB9Rdk+AHP36uR/Ln0HNKX11/HGNQUeHXha
fabPy0rvrul2XtSLY73YWq4iJGpPGlGbTPFx4PFOrpq+/TxyyZgoC38Plu0vOyrj
bI+a6AOMa39TJO6/Az1VtQzuxmLvSp76SwN4qeNOUBzQWQMb8npTVkBgde3ZIhav
ruOyxkJb9q3tIXuIpo5izqO+qlY9prgE+WFCNIEdu0MzI9hhT3OugoL+9ZeeGD0n
3/xbgh5U43p2ei0VvlKhvL8t4JvXq8XEJwgfG+zG8ckIwGA3Spc=
=F9R7
-----END PGP SIGNATURE-----

T
T
Troy Figiel wrote on 8 Mar 10:06 +0100
(address . 69376@debbugs.gnu.org)(name . Sharlatan Hellseher)(address . sharlatanus@gmail.com)
6cdf192c-ba7c-4d4b-bcad-6b4fa710ccce@troyfigiel.com
Hi Oleg,

On 2024-03-07 23:59, Sharlatan Hellseher wrote:
Toggle quote (4 lines)
> The patch looks reasonable. Does it allow us to run all available tests
> as we discussed in
> <https://lists.gnu.org/archive/html/guix-devel/2024-01/msg00128.html>?

No, not yet. This only allows providing extra test-flags such as
"-vet=off" or "-skip ..." for Go 1.20+. An example where this is useful,
is go-github-com-wtolson-go-taglib, but I had a couple in my backlog as
well.

Toggle quote (20 lines)
> One nitpick about this section:
> --8<---------------cut here---------------start------------->8---
> +;; go test builds a test binary (or multiple binaries), vets the code and then
> +;; runs the test binary. Build, test and test binary flags can be provided as
> +;; test-flags. See "go help test" and "go help testflag" for more details.
> --8<---------------cut here---------------end--------------->8---
> It is a good material for documentation section, how about to move it
> from this comment and compile a proper documentation note describing
> #:test-flags for go-build-system?
>
> Something like this:
> --8<---------------cut here---------------start------------->8---
> #:test-flags is added. The default is '(). These flags are passed as
> arguments to the test command. Note that flags for verbose output is
> always enabled on supported backends.
> --8<---------------cut here---------------end--------------->8---
> Sourced from <https://guix.gnu.org/manual/en/html_node/Build-Systems.html>
>
> WDYT?

I think that's a great idea. Where would that go exactly? I have only
found "guix.texi" and can add a short section there. Is this the correct
location?

Best wishes,

Troy
S
S
S
Sharlatan Hellseher wrote on 12 Sep 16:29 +0200
[PATCH go-team] build-system/go: Allow providing additional test flags.
(address . 69376-done@debbugs.gnu.org)
87bk0tlzc4.fsf@gmail.com
Hi,

Pushed as bac5777791d8d75b878fcf1df9560f8d6613f7f6 to go-team with
moving documentation to doc/guix.

--
Oleg
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEmEeB3micIcJkGAhndtcnv/Ys0rUFAmbi+tsACgkQdtcnv/Ys
0rVU8hAAy4zjhFtv1hCHyDXmvoFJ2fhgjMtqKla9JBfHDPKxtci1toQGdh1/UL7W
ayKSpJcQqFkq555GyTAVOfTcDc7KV1b69Mz6pmchbJ3D+LC5eRw/A/kCyzsP1xET
6ahRvHFOgeL+tipSh/eLk55jd58bjMckx5oaMbK8efz+2obAYvH4wZ6Pd4tFOBwk
QCoHckaO+xj7dt+djbbmlu2mAEX1Ba1086aRq5DTF/psVzw4ATyrtYYjeFDSF4e7
PJ2pjwCOcwP3HBtvdFNroQU+4dfXo3mfumSgbP1HcNBahrwHgyDDT3e3AbEW0ybZ
J6HBAqBQ/9mViBA5ElDQ9KpETF5jfVV/YjHprGXO0y4tCANuIU/blXI4D8Zb7l+d
Kqo9kO3SqNom0147idL7jcRKUJKoYOBRjymBE1Kt5k/HEMJks5EWf7q+maDz9P6s
8IK+rCo+7WB692yZXRpVGa1KyvJqqmgn1SScRA8fg3femHNfltI0m7oLZsNku2fQ
iGKqtp+TiOq/zruxgC6KsT4SpHhUWwn8ehDqsaRqQPNH/gh6dF/FntOigeF5BOq6
/6lPi+K5tq4uKfF2aDPRSl44aI8iQRyPLJ3QXHU906gFLUz45LBmwRzk+gC6XPZP
1YjEjpPtPr340upCQsjWmRc9XLQMXNDwrFM1BEUjvkbu58QUs6s=
=iatW
-----END PGP SIGNATURE-----

Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 69376@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 69376
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch