all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jaeme Sifat via Guix-patches via <guix-patches@gnu.org>
To: 67947@debbugs.gnu.org
Cc: Jaeme Sifat <jaeme@runbox.com>, Efraim Flashner <efraim@flashner.co.il>
Subject: [bug#67947] [PATCH 2/3] guix: build-system: cargo: Add cargo-test-targets.
Date: Thu, 21 Dec 2023 00:28:41 -0500	[thread overview]
Message-ID: <413c758092a856dae0c8e8b2e02a36dd1649e4cb.1703135457.git.jaeme@runbox.com> (raw)
In-Reply-To: <cover.1703135457.git.jaeme@runbox.com>

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





  parent reply	other threads:[~2023-12-21  5:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=413c758092a856dae0c8e8b2e02a36dd1649e4cb.1703135457.git.jaeme@runbox.com \
    --to=guix-patches@gnu.org \
    --cc=67947@debbugs.gnu.org \
    --cc=efraim@flashner.co.il \
    --cc=jaeme@runbox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.