* [bug#74668] [PATCH 0/2] Golang build-system adjustments. @ 2024-12-03 11:44 Sharlatan Hellseher 2024-12-03 11:45 ` [bug#74668] [PATCH 1/2] build: go-build-system: Relax build verbosity Sharlatan Hellseher 2024-12-03 11:45 ` [bug#74668] [PATCH 2/2] build-system/go: Add test-subdirs option key Sharlatan Hellseher 0 siblings, 2 replies; 3+ messages in thread From: Sharlatan Hellseher @ 2024-12-03 11:44 UTC (permalink / raw) To: 74668 Cc: Sharlatan Hellseher, Maxim Cournoyer, Katherine Cox-Buday, Sharlatan Hellseher Hi Guixers! While working on golang refresh and shift tasks I've faced with cases when all tests files are located in subdirs and can't be run with current implementation - #:test-subdirs provides missing option to bypass that limitation, it set to "..." by default allowing to run all available tests, and accepts a list of directories to resolve cicles or failinng tests in sbubdirs. It simplifies pacakges by removing customr check phases this:o --8<---------------cut here---------------start------------->8--- ... (replace 'check (lambda* (#:key tests? import-path #:allow-other-keys) (when tests? (with-directory-excursion (string-append "src/" import-path) (invoke "go" "test" "-v" "./...")))))))) ... --8<---------------cut here---------------end--------------->8--- --8<---------------cut here---------------start------------->8--- (replace 'check (lambda* (#:key tests? import-path #:allow-other-keys) (when tests? (with-directory-excursion (string-append "src/" import-path) (invoke "go" "test" "-v" ;; acme - cycle with go-golang-org-x-net "./argon2/..." "./bcrypt/..." "./blake2b/..." "./blake2s/..." "./blowfish/..." "./bn256/..." "./cast5/..." "./chacha20/..." "./chacha20poly1305/..." "./cryptobyte/..." "./curve25519/..." "./ed25519/..." "./hkdf/..." "./internal/..." "./md4/..." "./nacl/..." "./ocsp/..." "./openpgp/..." "./otr/..." "./pbkdf2/..." "./pkcs12/..." "./poly1305/..." "./ripemd160/..." "./salsa20/..." "./scrypt/..." "./sha3/..." "./ssh/..." "./tea/..." "./twofish/..." "./x509roots/..." "./xtea/..." "./xts/...")))))))) --8<---------------cut here---------------end--------------->8--- I've applied it on go-team branch locally and started resolving missing inputs where required. The second adjustments is to make "-x" build flag optional which does not help to resolve build fails and produces a massive log output in most of my cases not helping at all. Unfortunatly, go-team contains not too many active members. CC: Maxim Cournoyer <maxim.cournoyer@gmail.com>, Efraim Flashner <efraim@flashner.co.il> Sharlatan Hellseher (2): build: go-build-system: Relax build verbosity. build-system/go: Add test-subdirs option key. guix/build-system/go.scm | 4 +++ guix/build/go-build-system.scm | 58 +++++++++++++++++++++++++++------- 2 files changed, 50 insertions(+), 12 deletions(-) base-commit: d97a67d41de142c0fbdba55e96bfc147482bfae2 prerequisite-patch-id: 7c60aacd825ea1fd299462d1ae31beb34902fbaf prerequisite-patch-id: 5136c6924ea61be099691eb9b0c227936a08954a prerequisite-patch-id: 47fb416de83dc133d647e3e07a5c398391336eb1 prerequisite-patch-id: 760115bac637e5f39738d82ed16232c8792a8f82 prerequisite-patch-id: f8b63ec4ec753bcc2c3a6022abaf47146e454a72 prerequisite-patch-id: 2d5e20587944fe26b277509396dabd362bf8105c prerequisite-patch-id: 016a80d28a5a0135ebed61b6b5acc460f6c43b32 prerequisite-patch-id: e5f81823c9ea1b93abf1f3fec60e695d16909a06 prerequisite-patch-id: 8badae173015a65a237c45b42241e36355e9f2c1 prerequisite-patch-id: af090660b016e08b3612bee7ca2125bb0e1d00b2 prerequisite-patch-id: 294de506884b2b150eba248b4a1731de95d50176 prerequisite-patch-id: 8ed8c96cf2383811b66abe15f6fa9af73689b94c prerequisite-patch-id: 6dd547d424e4eeb99715847136b3fad7f566d9fa prerequisite-patch-id: ff3892aa0acc89208f4eba1f0866f8da01d1cb21 prerequisite-patch-id: 3a9c1b8c45bb320815892e512fdf3271ea9c8f0f prerequisite-patch-id: 526f9ea0e83f7479ac37679b69f9ad18c38e9234 prerequisite-patch-id: ad91b786810c1a4c13d2d39e0eb51d0932f1060c prerequisite-patch-id: e74404537a20ed352985299432056116f2d8881b prerequisite-patch-id: 0aae6b4b352a367bd8770075b16547c060262e34 prerequisite-patch-id: 0b485c3a7c266118cdafc3b30aebd704b1018af7 prerequisite-patch-id: add3eb95e39cd65a47e86d74909f822e4fcbd542 prerequisite-patch-id: 98487d900da05e0a4f39bb28036918afa76e1d9a prerequisite-patch-id: dedc1426c51db76f30ddd92a8ed04e1793f7839c prerequisite-patch-id: e7606e328c545a4db40d37ca3aa5f99c0b4287f8 prerequisite-patch-id: 63fa87ba5ddf33561784e25199d605aa0b18133e prerequisite-patch-id: 04fe1403ea43cfbeeabbd87ee9b6707c64101c07 prerequisite-patch-id: 3f7cf90125fd223507087c94a92aa16dba2662f2 prerequisite-patch-id: e763a43853180ad952fc5eaeb60e4ef2762f6d3f prerequisite-patch-id: 284d08f1257d7e6c69e46b9e7fee165fa1aa5b07 prerequisite-patch-id: 0ebe96fd52cc9140b53b17046b2aa2b6969a6e2c prerequisite-patch-id: 87339b708e38828f9a1769b3f2740f328a9bb59b prerequisite-patch-id: f3698965b06dbb73c6b702c22830a7e400b8b765 prerequisite-patch-id: 6d464271ac1083b7f303d3ac75963a7bf91e8ce0 prerequisite-patch-id: 93d8965a1a7a4110eb7348d43df9fb39899df5cc prerequisite-patch-id: 1bb520f9ad8cc64b07041ccea8ffb6ad51fea4a7 prerequisite-patch-id: d6c45d0b7fd5a8a744f560c1ee24e90e63546196 prerequisite-patch-id: d11dbd6a272b78c06b2373196897bd02da491e66 prerequisite-patch-id: aa2d3d94d3cebd23780c0785098e728080a25063 prerequisite-patch-id: 5e76884b7109e88da98532ec66c469b39335c14d prerequisite-patch-id: dfaa606ac8721e076b9870eca03721b731e3cc65 prerequisite-patch-id: 26a9585f84c5be0cf6ac60eeab3f62e2c1b59a32 prerequisite-patch-id: 790109ae7b8db35051f0532fb9820cc794f6e90e prerequisite-patch-id: cdcb8df8b8060543aeb46727c6097640784c5f77 prerequisite-patch-id: cef60c111cfd4c7c77b8402196710a334ed4244a prerequisite-patch-id: 6801272b174236af0bb5a94be1e105887f525660 prerequisite-patch-id: 3d03b39da9fcc5961b7672ea82784d68512cc9ef prerequisite-patch-id: 56410b64255826975d87f89c6bca96d96b3bddfa prerequisite-patch-id: 455428488cdc812b099c8a0aed3763632dbdc60c prerequisite-patch-id: 66d83739e60670e4a0bd3db34199da0346e84062 prerequisite-patch-id: cb91e8091b251ad54b16ab0c26145ec1e3207cd9 prerequisite-patch-id: 2b1d8e54b873c0c373a5c1fd3117a73c5c9df7a5 prerequisite-patch-id: 4a31a50b43fa9275f7f7801e658d593fe48798a4 prerequisite-patch-id: 43d9065cfb585329af82ff9b7510896ed5be6ea5 prerequisite-patch-id: 0742f873787eafc96b5bf2711e1ff19bc2c55970 prerequisite-patch-id: 0620608a1dfe736dc00327ee00b8bc9b24d374ae -- 2.46.0 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [bug#74668] [PATCH 1/2] build: go-build-system: Relax build verbosity. 2024-12-03 11:44 [bug#74668] [PATCH 0/2] Golang build-system adjustments Sharlatan Hellseher @ 2024-12-03 11:45 ` Sharlatan Hellseher 2024-12-03 11:45 ` [bug#74668] [PATCH 2/2] build-system/go: Add test-subdirs option key Sharlatan Hellseher 1 sibling, 0 replies; 3+ messages in thread From: Sharlatan Hellseher @ 2024-12-03 11:45 UTC (permalink / raw) To: 74668; +Cc: Sharlatan Hellseher, Katherine Cox-Buday, Sharlatan Hellseher During the build phase "-x" option forces go compiler to generate quite a noisy build log which does not help too much when the build is failed. This change makes it optional and governed by #:verbosity key passed to `build' procedure. * guix/build/go-build-system.scm (build): Provide a link to online example. Consolidate options in GOFLAGS environment variable, make "-x" optional. Add description for "-trimpath" option. Change-Id: Icf1b03eb79db8a6f79f86f3cc212a53de5aa7c1c --- guix/build/go-build-system.scm | 40 +++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm index e53d8cb53c..a463189011 100644 --- a/guix/build/go-build-system.scm +++ b/guix/build/go-build-system.scm @@ -283,23 +283,43 @@ (define (go-inputs inputs) (_ #f)) inputs)))) -(define* (build #:key import-path build-flags (parallel-build? #t) +(define* (build #:key + build-flags + import-path + (parallel-build? #t) + (verbosity 1) #:allow-other-keys) "Build the package named by IMPORT-PATH." - (let* ((njobs (if parallel-build? (parallel-job-count) 1))) + (let* ((njobs (if parallel-build? (parallel-job-count) 1)) + ;; Utilizing GOFLAGS for flexible build options passthrough, refer + ;; for more examples to online documentation of Golang + ;; <https://go.dev/src/cmd/go/testdata/script/goflags.txt>. + (goflags (string-join + (list + ;; Print the name of packages (pathes) as they are compiled. + "-v" + ;; Print each command as it is invoked. When enabled, it + ;; generates a lot of noisy logs which makes identifying + ;; build failures harder to determine. + (if (> verbosity 1) "-x" "") + ;; Respectively, strip the symbol table and debug + ;; information, and the DWARF symbol table. + "-ldflags=-s -w" + ;; Remove all file system paths from the resulting + ;; executable. Instead of absolute file system paths, the + ;; recorded file names will begin either a module + ;; path@version (when using modules), or a plain import + ;; path (when using the standard library, or GOPATH). + "-trimpath") + " "))) + (setenv "GOFLAGS" goflags) (setenv "GOMAXPROCS" (number->string njobs))) (with-throw-handler #t (lambda _ - (apply invoke "go" "install" - "-v" ; print the name of packages as they are compiled - "-x" ; print each command as it is invoked - ;; Respectively, strip the symbol table and debug - ;; information, and the DWARF symbol table. - "-ldflags=-s -w" - "-trimpath" - `(,@build-flags ,import-path))) + (apply invoke "go" "install" `(,@build-flags ,import-path))) + (lambda (key . args) (display (string-append "Building '" import-path "' failed.\n" "Here are the results of `go env`:\n")) -- 2.46.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [bug#74668] [PATCH 2/2] build-system/go: Add test-subdirs option key. 2024-12-03 11:44 [bug#74668] [PATCH 0/2] Golang build-system adjustments Sharlatan Hellseher 2024-12-03 11:45 ` [bug#74668] [PATCH 1/2] build: go-build-system: Relax build verbosity Sharlatan Hellseher @ 2024-12-03 11:45 ` Sharlatan Hellseher 1 sibling, 0 replies; 3+ messages in thread From: Sharlatan Hellseher @ 2024-12-03 11:45 UTC (permalink / raw) To: 74668; +Cc: Sharlatan Hellseher, Katherine Cox-Buday, Sharlatan Hellseher 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 --- guix/build-system/go.scm | 4 ++++ guix/build/go-build-system.scm | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/guix/build-system/go.scm b/guix/build-system/go.scm index 97581a14c6..66cb5e8b05 100644 --- a/guix/build-system/go.scm +++ b/guix/build-system/go.scm @@ -205,6 +205,7 @@ (define* (go-build name inputs (build-flags ''()) (tests? #t) (test-flags ''()) + (test-subdirs ''("...")) (parallel-build? #t) (parallel-tests? #t) (allow-go-reference? #f) @@ -239,6 +240,7 @@ (define* (go-build name inputs #:build-flags #$build-flags #:tests? #$tests? #:test-flags #$test-flags + #:test-subdirs #$test-subdirs #:parallel-build? #$parallel-build? #:parallel-tests? #$parallel-tests? #:allow-go-reference? #$allow-go-reference? @@ -264,6 +266,7 @@ (define* (go-cross-build name (build-flags ''()) (tests? #f) ; nothing can be done (test-flags ''()) + (test-subdirs ''("...")) (allow-go-reference? #f) (system (%current-system)) (goarch (first (go-target target))) @@ -316,6 +319,7 @@ (define* (go-cross-build name #:build-flags #$build-flags #:tests? #$tests? #:test-flags #$test-flags + #:test-subdirs #$test-subdirs #: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 a463189011..7d702d7f1f 100644 --- a/guix/build/go-build-system.scm +++ b/guix/build/go-build-system.scm @@ -98,6 +98,10 @@ (define-module (guix build go-build-system) ;; * Remove module packages, only offering the full Git repos? This is ;; more idiomatic, I think, because Go downloads Git repos, not modules. ;; 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`: ;; https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies @@ -325,13 +329,23 @@ (define* (build #:key "Here are the results of `go env`:\n")) (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) "Run the tests for the package named by IMPORT-PATH." (when tests? (let* ((njobs (if parallel-tests? (parallel-job-count) 1))) (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) (define* (install #:key install-source? outputs import-path unpack-path #:allow-other-keys) -- 2.46.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-03 11:47 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-12-03 11:44 [bug#74668] [PATCH 0/2] Golang build-system adjustments Sharlatan Hellseher 2024-12-03 11:45 ` [bug#74668] [PATCH 1/2] build: go-build-system: Relax build verbosity Sharlatan Hellseher 2024-12-03 11:45 ` [bug#74668] [PATCH 2/2] build-system/go: Add test-subdirs option key Sharlatan Hellseher
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/guix.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).