1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (test-import-utils)
21 #:use-module (guix tests)
22 #:use-module (guix import utils)
23 #:use-module ((guix licenses) #:prefix license:)
24 #:use-module (guix packages)
25 #:use-module (guix build-system)
26 #:use-module (gnu packages)
27 #:use-module (srfi srfi-64)
28 #:use-module (ice-9 match))
30 (test-begin "import-utils")
32 (test-equal "beautify-description: use double spacing"
33 "This is a package. It is great. Trust me Mr. Hendrix."
35 "This is a package. It is great. Trust me Mr. Hendrix."))
37 (test-equal "beautify-description: transform fragment into sentence"
38 "This package provides a function to establish world peace"
39 (beautify-description "A function to establish world peace"))
41 (test-equal "license->symbol"
43 (license->symbol license:lgpl2.0))
45 (test-equal "recursive-import"
46 '((package ;package expressions in topological order
50 (inputs `(("bar" ,bar)))))
51 (recursive-import "foo" 'repo
57 (inputs `(("bar" ,bar))))
63 #:guix-name identity))
65 (test-assert "alist->package with simple source"
66 (let* ((meta '(("name" . "hello")
69 ;; Use a 'file://' URI so that we don't cause a download.
70 ,(string-append "file://"
71 (search-path %load-path "guix.scm")))
72 ("build-system" . "gnu")
73 ("home-page" . "https://gnu.org")
74 ("synopsis" . "Say hi")
75 ("description" . "This package says hi.")
76 ("license" . "GPL-3.0+")))
77 (pkg (alist->package meta)))
79 (license:license? (package-license pkg))
80 (build-system? (package-build-system pkg))
81 (origin? (package-source pkg)))))
83 (test-assert "alist->package with explicit source"
84 (let* ((meta '(("name" . "hello")
86 ("source" . (("method" . "url-fetch")
87 ("uri" . "mirror://gnu/hello/hello-2.10.tar.gz")
90 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
91 ("build-system" . "gnu")
92 ("home-page" . "https://gnu.org")
93 ("synopsis" . "Say hi")
94 ("description" . "This package says hi.")
95 ("license" . "GPL-3.0+")))
96 (pkg (alist->package meta)))
98 (license:license? (package-license pkg))
99 (build-system? (package-build-system pkg))
100 (origin? (package-source pkg))
101 (equal? (origin-sha256 (package-source pkg))
102 (base32 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
104 (test-equal "alist->package with false license" ;<https://bugs.gnu.org/30470>
106 (let* ((meta '(("name" . "hello")
108 ("source" . (("method" . "url-fetch")
109 ("uri" . "mirror://gnu/hello/hello-2.10.tar.gz")
112 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
113 ("build-system" . "gnu")
114 ("home-page" . "https://gnu.org")
115 ("synopsis" . "Say hi")
116 ("description" . "This package says hi.")
118 ;; Note: Use 'or' because comparing with #f otherwise succeeds when
119 ;; there's an exception instead of an actual #f.
120 (or (package-license (alist->package meta))
123 (test-equal "alist->package with dependencies"
124 `(("gettext" ,(specification->package "gettext")))
125 (let* ((meta '(("name" . "hello")
127 ("source" . (("method" . "url-fetch")
128 ("uri" . "mirror://gnu/hello/hello-2.10.tar.gz")
131 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
132 ("build-system" . "gnu")
133 ("home-page" . "https://gnu.org")
134 ("synopsis" . "Say hi")
135 ("description" . "This package says hi.")
137 ;; Note: As with Guile-JSON 3.x, JSON arrays are represented
139 ("native-inputs" . #("gettext"))
142 (package-native-inputs (alist->package meta))))
144 (test-end "import-utils")