guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#67947] [PATCH 2/3] guix: build-system: cargo: Add cargo-test-target


From: Jaeme Sifat
Subject: [bug#67947] [PATCH 2/3] guix: build-system: cargo: Add cargo-test-targets.
Date: Thu, 21 Dec 2023 00:28:41 -0500

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]