diff mbox series

[bug#67947,1/3] guix: build-system: cargo: Add cargo-skip-tests.

Message ID a6fe9279323eb1fac32153134c5a0bf34ce8cb17.1703135457.git.jaeme@runbox.com
State New
Headers show
Series guix: cargo-build-system: Add test keys. | expand

Commit Message

Jaeme Sifat Dec. 21, 2023, 5:28 a.m. UTC
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 mbox series

Patch

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