1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (run-system-tests)
20 #:use-module (gnu tests)
21 #:use-module (guix store)
22 #:use-module ((guix status) #:select (with-status-verbosity))
23 #:use-module (guix monads)
24 #:use-module (guix derivations)
25 #:use-module (guix ui)
26 #:use-module (srfi srfi-1)
27 #:use-module (srfi srfi-34)
28 #:use-module (ice-9 match)
29 #:export (run-system-tests))
31 (define (built-derivations* drv)
33 (guard (c ((store-protocol-error? c)
35 (values (build-derivations store drv) store))))
37 (define (filterm mproc lst) ;XXX: move to (guix monads)
38 (with-monad %store-monad
39 (>>= (foldm %store-monad
41 (mlet %store-monad ((keep? (mproc item)))
47 (lift1 reverse %store-monad))))
49 (define (run-system-tests . args)
51 ;; Honor the 'TESTS' environment variable so that one can select a subset
52 ;; of tests to run in the usual way:
54 ;; make check-system TESTS=installed-os
55 (match (getenv "TESTS")
58 ((= string-tokenize (tests ...))
59 (filter (lambda (test)
60 (member (system-test-name test) tests))
61 (all-system-tests)))))
63 (format (current-error-port) "Running ~a system tests...~%"
67 (with-status-verbosity 2
69 (mlet* %store-monad ((drv (mapm %store-monad system-test-value tests))
70 (out -> (map derivation->output-path drv)))
72 (show-what-to-build* drv)
73 (set-build-options* #:keep-going? #t #:keep-failed? #t
74 #:print-build-trace #t
75 #:print-extended-build-trace? #t
77 (built-derivations* drv)
78 (mlet %store-monad ((valid (filterm (store-lift valid-path?)
80 (failed (filterm (store-lift
83 (format #t "TOTAL: ~a\n" (length drv))
84 (for-each (lambda (item)
85 (format #t "PASS: ~a~%" item))
87 (for-each (lambda (item)
88 (format #t "FAIL: ~a~%" item))
90 (exit (null? failed)))))))))