mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
build-system/go: Add test-subdirs option key.
Golang projects may contain subdirectories with test files, which can't be reached by providing just IMPORT-PATH to the test runner. This change implements a TEST-SUBDIRS key parameter which is by default set to "import-path/..." to run all available tests in the project, and may be limited to particular subdirs list. * guix/build-system/go.scm (go-build, go-cross-build): Add "test-subdirs" key parameter. * guix/build/go-build-system.scm (check): Add "test-subdirs" key parameter and adjust test invokation accordingly. Change-Id: Ibc107deea060f0d71e6f4e1e37c81d3b7c9992f5
This commit is contained in:
parent
f33d794020
commit
1e4a22c4d7
2 changed files with 20 additions and 2 deletions
|
@ -205,6 +205,7 @@ commit hash and its date rather than a proper release tag."
|
||||||
(build-flags ''())
|
(build-flags ''())
|
||||||
(tests? #t)
|
(tests? #t)
|
||||||
(test-flags ''())
|
(test-flags ''())
|
||||||
|
(test-subdirs ''("..."))
|
||||||
(parallel-build? #t)
|
(parallel-build? #t)
|
||||||
(parallel-tests? #t)
|
(parallel-tests? #t)
|
||||||
(allow-go-reference? #f)
|
(allow-go-reference? #f)
|
||||||
|
@ -239,6 +240,7 @@ commit hash and its date rather than a proper release tag."
|
||||||
#:build-flags #$build-flags
|
#:build-flags #$build-flags
|
||||||
#:tests? #$tests?
|
#:tests? #$tests?
|
||||||
#:test-flags #$test-flags
|
#:test-flags #$test-flags
|
||||||
|
#:test-subdirs #$test-subdirs
|
||||||
#:parallel-build? #$parallel-build?
|
#:parallel-build? #$parallel-build?
|
||||||
#:parallel-tests? #$parallel-tests?
|
#:parallel-tests? #$parallel-tests?
|
||||||
#:allow-go-reference? #$allow-go-reference?
|
#:allow-go-reference? #$allow-go-reference?
|
||||||
|
@ -264,6 +266,7 @@ commit hash and its date rather than a proper release tag."
|
||||||
(build-flags ''())
|
(build-flags ''())
|
||||||
(tests? #f) ; nothing can be done
|
(tests? #f) ; nothing can be done
|
||||||
(test-flags ''())
|
(test-flags ''())
|
||||||
|
(test-subdirs ''("..."))
|
||||||
(allow-go-reference? #f)
|
(allow-go-reference? #f)
|
||||||
(system (%current-system))
|
(system (%current-system))
|
||||||
(goarch (first (go-target target)))
|
(goarch (first (go-target target)))
|
||||||
|
@ -316,6 +319,7 @@ commit hash and its date rather than a proper release tag."
|
||||||
#:build-flags #$build-flags
|
#:build-flags #$build-flags
|
||||||
#:tests? #$tests?
|
#:tests? #$tests?
|
||||||
#:test-flags #$test-flags
|
#:test-flags #$test-flags
|
||||||
|
#:test-subdirs #$test-subdirs
|
||||||
#:make-dynamic-linker-cache? #f ;cross-compiling
|
#:make-dynamic-linker-cache? #f ;cross-compiling
|
||||||
#:allow-go-reference? #$allow-go-reference?
|
#:allow-go-reference? #$allow-go-reference?
|
||||||
#:inputs %build-inputs))))
|
#:inputs %build-inputs))))
|
||||||
|
|
|
@ -98,6 +98,10 @@
|
||||||
;; * Remove module packages, only offering the full Git repos? This is
|
;; * Remove module packages, only offering the full Git repos? This is
|
||||||
;; more idiomatic, I think, because Go downloads Git repos, not modules.
|
;; more idiomatic, I think, because Go downloads Git repos, not modules.
|
||||||
;; What are the trade-offs?
|
;; What are the trade-offs?
|
||||||
|
;; * Figurie out how to passthrough --verbosity option to "build" and "check"
|
||||||
|
;; procedures.
|
||||||
|
;; * Implement test-backend option, which would be similar to pyproject's
|
||||||
|
;; one, allowing to provide custom test runner.
|
||||||
;;
|
;;
|
||||||
;; [0] `go build`:
|
;; [0] `go build`:
|
||||||
;; https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies
|
;; https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies
|
||||||
|
@ -326,13 +330,23 @@ unpacking."
|
||||||
"Here are the results of `go env`:\n"))
|
"Here are the results of `go env`:\n"))
|
||||||
(invoke "go" "env"))))
|
(invoke "go" "env"))))
|
||||||
|
|
||||||
(define* (check #:key tests? import-path test-flags (parallel-tests? #t)
|
(define* (check #:key
|
||||||
|
tests?
|
||||||
|
import-path
|
||||||
|
test-flags
|
||||||
|
test-subdirs
|
||||||
|
(parallel-tests? #t)
|
||||||
#:allow-other-keys)
|
#:allow-other-keys)
|
||||||
"Run the tests for the package named by IMPORT-PATH."
|
"Run the tests for the package named by IMPORT-PATH."
|
||||||
(when tests?
|
(when tests?
|
||||||
(let* ((njobs (if parallel-tests? (parallel-job-count) 1)))
|
(let* ((njobs (if parallel-tests? (parallel-job-count) 1)))
|
||||||
(setenv "GOMAXPROCS" (number->string njobs)))
|
(setenv "GOMAXPROCS" (number->string njobs)))
|
||||||
(apply invoke "go" "test" `(,import-path ,@test-flags)))
|
(apply invoke "go" "test"
|
||||||
|
`(,@(map (lambda (dir)
|
||||||
|
(format #f "~a~:[/~;~]~a"
|
||||||
|
import-path (string-null? dir) dir))
|
||||||
|
test-subdirs)
|
||||||
|
,@test-flags)))
|
||||||
#t)
|
#t)
|
||||||
|
|
||||||
(define* (install #:key install-source? outputs import-path unpack-path #:allow-other-keys)
|
(define* (install #:key install-source? outputs import-path unpack-path #:allow-other-keys)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue