1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 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 (test-discovery)
20 #:use-module (guix discovery)
21 #:use-module (guix build-system)
22 #:use-module (guix utils)
23 #:use-module (srfi srfi-64)
24 #:use-module (ice-9 match))
27 (dirname (search-path %load-path "guix.scm")))
29 (test-begin "discovery")
31 (test-assert "scheme-modules"
32 (match (map module-name (scheme-modules %top-srcdir "guix/import"))
33 ((('guix 'import _ ...) ..1)
36 (test-assert "scheme-modules recurses in symlinks to directories"
37 (call-with-temporary-directory
39 (mkdir (string-append directory "/guix"))
40 (symlink (string-append %top-srcdir "/guix/import")
41 (string-append directory "/guix/import"))
43 ;; DIRECTORY/guix/import is a symlink but we want to make sure
44 ;; 'scheme-modules' recurses into it.
45 (match (map module-name (scheme-modules directory))
46 ((('guix 'import _ ...) ..1)
49 (test-equal "scheme-modules, non-existent directory"
51 (scheme-modules "/does/not/exist"))
53 (test-assert "all-modules"
54 (match (map module-name
55 (all-modules `((,%top-srcdir . "guix/build-system"))))
56 ((('guix 'build-system names) ..1)
59 (test-assert "fold-module-public-variables"
60 (let ((modules (all-modules `((,%top-srcdir . "guix/build-system")))))
61 (match (fold-module-public-variables (lambda (obj result)
62 (if (build-system? obj)
67 (((? build-system? bs) ..1)
70 (test-end "discovery")