guix_mirror_bot pushed a commit to branch r-team
in repository guix.

commit dd04b0f1216370f2eb89fe1793bc9eb8c137d997
Author: Ricardo Wurmus <[email protected]>
AuthorDate: Tue Feb 17 12:46:18 2026 +0100

    build-system/r: Add build phase to skip tests.
    
    * guix/build-system/r.scm (r-build): Pass TEST-DIRECTORY and SKIPPED-TESTS.
    * guix/build/r-build-system.scm (patch-tests): New procedure.
    (%standard-phases): Add it.
    
    Change-Id: I7abcd25260f5f55a342899371f4276306c911abe
---
 guix/build-system/r.scm       |  6 +++++-
 guix/build/r-build-system.scm | 34 +++++++++++++++++++++++++++++++++-
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/guix/build-system/r.scm b/guix/build-system/r.scm
index 1139e1c0e9..565c7db344 100644
--- a/guix/build-system/r.scm
+++ b/guix/build-system/r.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015-2024 Ricardo Wurmus <[email protected]>
+;;; Copyright © 2015-2026 Ricardo Wurmus <[email protected]>
 ;;; Copyright © 2021 Ludovic Courtès <[email protected]>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -110,6 +110,8 @@ release corresponding to NAME and VERSION."
                   (tests? #t)
                   (test-target "tests")
                   (test-types #f)
+                  test-directory
+                  skipped-tests
                   (configure-flags ''())
                   (phases '%standard-phases)
                   (outputs '("out"))
@@ -132,6 +134,8 @@ release corresponding to NAME and VERSION."
                    #:tests? #$tests?
                    #:test-target #$test-target
                    #:test-types #$test-types
+                   #:test-directory #$test-directory
+                   #:skipped-tests '#$skipped-tests
                    #:phases #$phases
                    #:outputs #$(outputs->gexp outputs)
                    #:search-paths '#$(sexp->gexp
diff --git a/guix/build/r-build-system.scm b/guix/build/r-build-system.scm
index 01ce5b9d49..b32df93d2d 100644
--- a/guix/build/r-build-system.scm
+++ b/guix/build/r-build-system.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015, 2017, 2018, 2024 Ricardo Wurmus <[email protected]>
+;;; Copyright © 2015, 2017, 2018, 2024, 2026 Ricardo Wurmus 
<[email protected]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -23,6 +23,7 @@
   #:use-module (ice-9 format)
   #:use-module (ice-9 ftw)
   #:use-module (ice-9 popen)
+  #:use-module (ice-9 regex)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
@@ -63,6 +64,36 @@
                             inputs))
                ":"))
 
+(define* (patch-tests #:key
+                      (skipped-tests #false)
+                      (test-directory "tests/testthat")
+                      #:allow-other-keys)
+  "Patch sources to skip tests according to SKIPPED-TESTS, a list of pairs
+each consisting of a file name under TEST-DIRECTORY and one or more names of
+tests to be skipped.  If the entry is just a file name, delete the test file."
+  (when skipped-tests
+    (with-directory-excursion "tests/testthat/"
+      (for-each (match-lambda
+                  ((file test-names ...)
+                   (substitute file
+                               (map (lambda (test-name)
+                                      (let ((pattern (make-regexp
+                                                      (string-append "^ 
*(testthat::)?test_that\\([\"']"
+                                                                     test-name 
"[\"'].*")
+                                                      regexp/extended)))
+                                        (cons pattern
+                                              (lambda (line matches)
+                                                (match matches
+                                                  ((fst . rest)
+                                                   (string-append 
(match:string fst) "skip('Guix');\n"))
+                                                  (else
+                                                   (error (format #false
+                                                                  "no matching 
test `~a' in file `~a'" test-name file))))))))
+                                    test-names)))
+                  ((? string? file)
+                   (delete-file file)))
+                skipped-tests))))
+
 (define* (check #:key test-target test-types inputs outputs tests? 
#:allow-other-keys)
   "Run the test suite of a given R package."
   (let* ((libdir    (string-append (assoc-ref outputs "out") "/site-library/"))
@@ -124,6 +155,7 @@
 (define %standard-phases
   (modify-phases gnu:%standard-phases
     (delete 'bootstrap)
+    (add-after 'unpack 'patch-tests patch-tests)
     (delete 'configure)
     (delete 'build)
     (delete 'check) ; tests must be run after installation

Reply via email to