summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2024-11-14 14:30:22 +0100
committerRicardo Wurmus <rekado@elephly.net>2024-12-03 16:58:06 +0100
commit0f18c1e3facbf766758c3dea68e96e7666e6d816 (patch)
treec190d02f71da73929b510bba9a01fa7047500814
parent9fe7e9137323b9d3a7975663ec6b551b957186ee (diff)
r-build-system: Fail the build on test errors.
* guix/build-system/r.scm (r-build): Accept optional TEST-TYPES argument and pass it to the build phases. * guix/build/r-build-system.scm (check): Exit R with the return value of tools:::testInstalledPackage; stop the test suite on the first error; respect TEST-TYPES argument; dump logs on test failure. Change-Id: Ia83407ceb2ef2a92cfa02f3a3d661f54cf8c8b40
-rw-r--r--guix/build-system/r.scm4
-rw-r--r--guix/build/r-build-system.scm21
2 files changed, 19 insertions, 6 deletions
diff --git a/guix/build-system/r.scm b/guix/build-system/r.scm
index a83cea4fb7..92449c7dbb 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-2023 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2015-2024 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
@@ -107,6 +107,7 @@ release corresponding to NAME and VERSION."
source
(tests? #t)
(test-target "tests")
+ (test-types #f)
(configure-flags ''())
(phases '%standard-phases)
(outputs '("out"))
@@ -128,6 +129,7 @@ release corresponding to NAME and VERSION."
#:system #$system
#:tests? #$tests?
#:test-target #$test-target
+ #:test-types #$test-types
#: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 0ab80f6a38..43d44f623b 100644
--- a/guix/build/r-build-system.scm
+++ b/guix/build/r-build-system.scm
@@ -20,6 +20,7 @@
#:use-module ((guix build gnu-build-system) #:prefix gnu:)
#:use-module (guix build utils)
#:use-module (ice-9 match)
+ #:use-module (ice-9 format)
#:use-module (ice-9 ftw)
#:use-module (ice-9 popen)
#:use-module (srfi srfi-1)
@@ -62,7 +63,7 @@
inputs))
":"))
-(define* (check #:key test-target inputs outputs tests? #:allow-other-keys)
+(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/"))
@@ -80,10 +81,20 @@
(site-path (string-append libdir ":" (generate-site-path inputs))))
(when (and tests? (file-exists? testdir))
(setenv "R_LIBS_SITE" site-path)
- (pipe-to-r (string-append "tools::testInstalledPackage(\"" pkg-name "\", "
- "lib.loc = \"" libdir "\")")
- '("--no-save" "--slave")))
- #t))
+ (guard (c ((invoke-error? c)
+ ;; Dump the test suite log to facilitate debugging.
+ (display "\nTests failed, dumping logs.\n"
+ (current-error-port))
+ (gnu:dump-file-contents "." ".*\\.Rout\\.fail$")
+ (raise c)))
+ (pipe-to-r (string-append "quit(status=tools::testInstalledPackage(\"" pkg-name "\", "
+ "lib.loc = \"" libdir "\", "
+ "errorsAreFatal=TRUE, "
+ (if test-types
+ (format #false "types=c(~{\"~a\"~^,~})" test-types)
+ "types=c(\"tests\", \"vignettes\")")
+ "))")
+ '("--no-save" "--slave"))))))
(define* (install #:key outputs inputs (configure-flags '())
#:allow-other-keys)