all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#67947] [PATCH 0/3 rust-team] guix: cargo-build-system: Add test keys.
@ 2023-12-21  5:11 Jaeme Sifat via Guix-patches via
  2023-12-21  5:28 ` [bug#67947] [PATCH 1/3] guix: build-system: cargo: Add cargo-skip-tests Jaeme Sifat via Guix-patches via
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jaeme Sifat via Guix-patches via @ 2023-12-21  5:11 UTC (permalink / raw)
  To: 67947; +Cc: Jaeme Sifat, Efraim Flashner

I propose adding two new keys for the 'check phase of the
cargo-build-system. One is #:cargo-skip-tests which accepts a list of
strings representing the names of the tests to be skipped and the
other is #:cargo-test-targets which accepts a list of strings
representing the test targets to be ran.

The goal of adding these two keys is to make it so that the packager
doesn't have to interface directly with #:cargo-test-flags which is
set to --release mode by default. I believe that this leads to cleaner
looking build definitions that should be easier to bind to something
say, a web-based package definition editor that exists right now.

These patches are just a draft of this feature I cooked up. Here's
what they should look like in action with the rust-alsa crate:

--8<---------------cut here---------------start------------->8---
(define-public rust-alsa-0.8
  (package
    ...
    (build-system cargo-build-system)
    (arguments
     `(#:cargo-test-targets
       (list "lib"
             "bins"
             "tests")
       #:cargo-skip-tests
       (list "pcm::drop"
             "pcm::info_from_default"
             "pcm::playback_to_default"
             "pcm::record_from_default"
             "seq::print_seqs"
             "seq::seq_loopback"
             "seq::seq_portsubscribeiter"
             "seq::seq_subscribe")
       #:cargo-inputs
       (("rust-alsa-sys" ,rust-alsa-sys-0.3)
        ("rust-bitflags" ,rust-bitflags-2)
        ("rust-libc" ,rust-libc-0.2)
        ("rust-nix" ,rust-nix-0.26))))
     ...))
--8<---------------cut here---------------end--------------->8---

I would like to hear the feedback on this change and its
implementation. Of course, if this change is accepted, then there
ought to be an update to the Rust crates section of 'Contributing' in
the Guix manual that details this.

Jaeme Sifat (3):
  guix: build-system: cargo: Add cargo-skip-tests.
  guix: build-system: cargo: Add cargo-test-targets.
  guix: Add copyright notice.

 guix/build-system/cargo.scm       |  9 +++++++++
 guix/build/cargo-build-system.scm | 20 +++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)


base-commit: 49a7a95ba44e231e9e15a274f9a96de6fa012daf
--
2.41.0




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [bug#67947] [PATCH 1/3] guix: build-system: cargo: Add cargo-skip-tests.
  2023-12-21  5:11 [bug#67947] [PATCH 0/3 rust-team] guix: cargo-build-system: Add test keys Jaeme Sifat via Guix-patches via
@ 2023-12-21  5:28 ` Jaeme Sifat via Guix-patches via
  2023-12-21  5:28 ` [bug#67947] [PATCH 2/3] guix: build-system: cargo: Add cargo-test-targets Jaeme Sifat via Guix-patches via
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jaeme Sifat via Guix-patches via @ 2023-12-21  5:28 UTC (permalink / raw)
  To: 67947; +Cc: Jaeme Sifat, Efraim Flashner

The #:cargo-skip-tests key accepts a list of strings that represent the names
of tests to be skipped by passing the "--skip=<test-name>" to cargo test. This
is so that the packager doesn't have to edit #:cargo-test-flags directly when
trying to skip tests.

* guix/build-system/cargo.scm (cargo-build): Add cargo-skip-tests.
* guix/build-system/cargo.scm (builder): Add cargo-skip-tests.
* guix/build-system/cargo.scm (cargo-cross-build): Add cargo-skip-tests.
* guix/build/cargo-build-system.scm (check): Add cargo-skip-tests.

Change-Id: I2f64370cf29b9495a33a8e072ab930b8635e742d
---
 guix/build-system/cargo.scm       |  4 ++++
 guix/build/cargo-build-system.scm | 10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index c029cc1dda..d2a45f0609 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -86,6 +86,7 @@ (define* (cargo-build name inputs
                       (vendor-dir "guix-vendor")
                       (cargo-build-flags ''("--release"))
                       (cargo-test-flags ''("--release"))
+                      (cargo-skip-tests ''())
                       (cargo-package-flags ''("--no-metadata" "--no-verify"))
                       (features ''())
                       (skip-build? #f)
@@ -112,6 +113,7 @@ (define* (cargo-build name inputs
                        #:vendor-dir #$vendor-dir
                        #:cargo-build-flags #$(sexp->gexp cargo-build-flags)
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
+                       #:cargo-skip-tests #$(sexp->gexp cargo-skip-tests)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
                        #:features #$(sexp->gexp features)
                        #:skip-build? #$skip-build?
@@ -141,6 +143,7 @@ (define* (cargo-cross-build name
                             (vendor-dir "guix-vendor")
                             (cargo-build-flags ''("--release"))
                             (cargo-test-flags ''("--release"))
+                            (cargo-skip-tests ''())
                             (cargo-package-flags ''("--no-metadata" "--no-verify"))
                             (features ''())
                             (skip-build? #f)
@@ -169,6 +172,7 @@ (define* (cargo-cross-build name
                        #:vendor-dir #$vendor-dir
                        #:cargo-build-flags #$(sexp->gexp cargo-build-flags)
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
+                       #:cargo-skip-tests #$(sexp->gexp cargo-skip-tests)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
                        #:features #$(sexp->gexp features)
                        #:skip-build? #$skip-build?
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index ffb2ec898e..7cdb2a72d3 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -258,11 +258,19 @@ (define* (build #:key
 
 (define* (check #:key
                 tests?
+                cargo-skip-tests
                 (cargo-test-flags '("--release"))
                 #:allow-other-keys)
   "Run tests for a given Cargo package."
   (if tests?
-      (apply invoke "cargo" "test" cargo-test-flags)
+      (if cargo-skip-tests
+          (let ((test-lst (map (lambda (test)
+                              (string-append "--skip=" test))
+                            cargo-skip-tests)))
+            (apply invoke "cargo" "test" (append
+                                          cargo-test-flags
+                                          (cons* "--" test-lst))))
+          (apply invoke "cargo" "test" cargo-test-flags))
       #t))
 
 (define* (package #:key
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#67947] [PATCH 2/3] guix: build-system: cargo: Add cargo-test-targets.
  2023-12-21  5:11 [bug#67947] [PATCH 0/3 rust-team] guix: cargo-build-system: Add test keys Jaeme Sifat via Guix-patches via
  2023-12-21  5:28 ` [bug#67947] [PATCH 1/3] guix: build-system: cargo: Add cargo-skip-tests Jaeme Sifat via Guix-patches via
@ 2023-12-21  5:28 ` Jaeme Sifat via Guix-patches via
  2023-12-21  5:28 ` [bug#67947] [PATCH 3/3] guix: Add copyright notice Jaeme Sifat via Guix-patches via
  2024-10-31 15:19 ` [bug#67947] cargo-build-system: Add test keys Steve George
  3 siblings, 0 replies; 5+ messages in thread
From: Jaeme Sifat via Guix-patches via @ 2023-12-21  5:28 UTC (permalink / raw)
  To: 67947; +Cc: Jaeme Sifat, Efraim Flashner

In addition to adding a key for skipping tests, there ought be a key for
specifying which test target(s) should be ran without having to edit
the #:cargo-test-flags key directly.

* guix/build-system/cargo.scm (cargo-build): Add cargo-test-targets.
* guix/build-system/cargo.scm (builder): Add cargo-test-targets.
* guix/build-system/cargo.scm (cargo-cross-build): Add cargo-test-targets.
* guix/build/cargo-build-system.scm (check): Add cargo-test-targets.

Change-Id: Ibdf3cffd2b0f3fdbfe269189975c739192c14f64
---
 guix/build-system/cargo.scm       |  4 ++++
 guix/build/cargo-build-system.scm | 25 +++++++++++++++++--------
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index d2a45f0609..7878a3bd6d 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -86,6 +86,7 @@ (define* (cargo-build name inputs
                       (vendor-dir "guix-vendor")
                       (cargo-build-flags ''("--release"))
                       (cargo-test-flags ''("--release"))
+                      (cargo-test-targets ''())
                       (cargo-skip-tests ''())
                       (cargo-package-flags ''("--no-metadata" "--no-verify"))
                       (features ''())
@@ -113,6 +114,7 @@ (define* (cargo-build name inputs
                        #:vendor-dir #$vendor-dir
                        #:cargo-build-flags #$(sexp->gexp cargo-build-flags)
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
+                       #:cargo-test-targets #$(sexp->gexp cargo-test-targets)
                        #:cargo-skip-tests #$(sexp->gexp cargo-skip-tests)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
                        #:features #$(sexp->gexp features)
@@ -143,6 +145,7 @@ (define* (cargo-cross-build name
                             (vendor-dir "guix-vendor")
                             (cargo-build-flags ''("--release"))
                             (cargo-test-flags ''("--release"))
+                            (cargo-test-targets ''())
                             (cargo-skip-tests ''())
                             (cargo-package-flags ''("--no-metadata" "--no-verify"))
                             (features ''())
@@ -172,6 +175,7 @@ (define* (cargo-cross-build name
                        #:vendor-dir #$vendor-dir
                        #:cargo-build-flags #$(sexp->gexp cargo-build-flags)
                        #:cargo-test-flags #$(sexp->gexp cargo-test-flags)
+                       #:cargo-test-targets #$(sexp->gexp cargo-test-targets)
                        #:cargo-skip-tests #$(sexp->gexp cargo-skip-tests)
                        #:cargo-package-flags #$(sexp->gexp cargo-package-flags)
                        #:features #$(sexp->gexp features)
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 7cdb2a72d3..5abedfc726 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -258,19 +258,28 @@ (define* (build #:key
 
 (define* (check #:key
                 tests?
+                cargo-test-targets
                 cargo-skip-tests
                 (cargo-test-flags '("--release"))
                 #:allow-other-keys)
   "Run tests for a given Cargo package."
   (if tests?
-      (if cargo-skip-tests
-          (let ((test-lst (map (lambda (test)
-                              (string-append "--skip=" test))
-                            cargo-skip-tests)))
-            (apply invoke "cargo" "test" (append
-                                          cargo-test-flags
-                                          (cons* "--" test-lst))))
-          (apply invoke "cargo" "test" cargo-test-flags))
+      (let* ((cargo-test-targets-flags
+              (when cargo-test-targets
+                (map (lambda (section)
+                       (string-append "--" section))
+                     cargo-test-targets)))
+             (cargo-skip-tests-flags
+              (when cargo-skip-tests
+                (map (lambda (test)
+                       (string-append "--skip=" test))
+                     cargo-skip-tests)))
+             (cargo-test-flags
+              (append cargo-test-flags
+                      cargo-test-targets-flags
+                      '("--")
+                      cargo-skip-tests-flags)))
+        (apply invoke "cargo" "test" cargo-test-flags))
       #t))
 
 (define* (package #:key
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#67947] [PATCH 3/3] guix: Add copyright notice.
  2023-12-21  5:11 [bug#67947] [PATCH 0/3 rust-team] guix: cargo-build-system: Add test keys Jaeme Sifat via Guix-patches via
  2023-12-21  5:28 ` [bug#67947] [PATCH 1/3] guix: build-system: cargo: Add cargo-skip-tests Jaeme Sifat via Guix-patches via
  2023-12-21  5:28 ` [bug#67947] [PATCH 2/3] guix: build-system: cargo: Add cargo-test-targets Jaeme Sifat via Guix-patches via
@ 2023-12-21  5:28 ` Jaeme Sifat via Guix-patches via
  2024-10-31 15:19 ` [bug#67947] cargo-build-system: Add test keys Steve George
  3 siblings, 0 replies; 5+ messages in thread
From: Jaeme Sifat via Guix-patches via @ 2023-12-21  5:28 UTC (permalink / raw)
  To: 67947; +Cc: Jaeme Sifat, Efraim Flashner

* guix/build-system/cargo.scm: Add copyright notice.
* guix/build/cargo-build-system.scm: Add copyright notice.

Change-Id: I1ccffda9ce10e9bbe75ba573b7de763d0c42d899
---
 guix/build-system/cargo.scm       | 1 +
 guix/build/cargo-build-system.scm | 1 +
 2 files changed, 2 insertions(+)

diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm
index 7878a3bd6d..ef78a18b5f 100644
--- a/guix/build-system/cargo.scm
+++ b/guix/build-system/cargo.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
 ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2023 Jaeme Sifat <jaeme@runbox.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 5abedfc726..3c74d11911 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -5,6 +5,7 @@
 ;;; Copyright © 2019-2023 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
 ;;; Copyright © 2020 Marius Bakke <marius@gnu.org>
+;;; Copyright © 2023 Jaeme Sifat <jaeme@runbox.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#67947] cargo-build-system: Add test keys.
  2023-12-21  5:11 [bug#67947] [PATCH 0/3 rust-team] guix: cargo-build-system: Add test keys Jaeme Sifat via Guix-patches via
                   ` (2 preceding siblings ...)
  2023-12-21  5:28 ` [bug#67947] [PATCH 3/3] guix: Add copyright notice Jaeme Sifat via Guix-patches via
@ 2024-10-31 15:19 ` Steve George
  3 siblings, 0 replies; 5+ messages in thread
From: Steve George @ 2024-10-31 15:19 UTC (permalink / raw)
  To: 67947; +Cc: Efraim Flashner

Hi,

#67947 was the idea of adding some test keys to make testing easier.
Unsure if it aligns with the other build-systems, but sounds great.
Bumping ...

Futurile




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-10-31 15:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-21  5:11 [bug#67947] [PATCH 0/3 rust-team] guix: cargo-build-system: Add test keys Jaeme Sifat via Guix-patches via
2023-12-21  5:28 ` [bug#67947] [PATCH 1/3] guix: build-system: cargo: Add cargo-skip-tests Jaeme Sifat via Guix-patches via
2023-12-21  5:28 ` [bug#67947] [PATCH 2/3] guix: build-system: cargo: Add cargo-test-targets Jaeme Sifat via Guix-patches via
2023-12-21  5:28 ` [bug#67947] [PATCH 3/3] guix: Add copyright notice Jaeme Sifat via Guix-patches via
2024-10-31 15:19 ` [bug#67947] cargo-build-system: Add test keys Steve George

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.