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 +;;; Copyright © 2015-2026 Ricardo Wurmus ;;; Copyright © 2021 Ludovic Courtès ;;; ;;; 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 +;;; Copyright © 2015, 2017, 2018, 2024, 2026 Ricardo Wurmus ;;; ;;; 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