gnu: Add gnome-shell-extension-dash-to-dock.
[jackhill/guix/guix.git] / tests / import-utils.scm
CommitLineData
a132f7d6 1;;; GNU Guix --- Functional package management for GNU
5e892bc3 2;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net>
a132f7d6
BW
3;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
4;;;
5;;; This file is part of GNU Guix.
6;;;
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.
11;;;
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.
16;;;
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/>.
19
20(define-module (test-import-utils)
21 #:use-module (guix tests)
22 #:use-module (guix import utils)
11e296ef 23 #:use-module ((guix licenses) #:prefix license:)
5e892bc3
RW
24 #:use-module (guix packages)
25 #:use-module (guix build-system)
81c3dc32 26 #:use-module (gnu packages)
a132f7d6
BW
27 #:use-module (srfi srfi-64))
28
29(test-begin "import-utils")
30
31(test-equal "beautify-description: use double spacing"
32 "This is a package. It is great. Trust me Mr. Hendrix."
33 (beautify-description
34 "This is a package. It is great. Trust me Mr. Hendrix."))
35
36(test-equal "beautify-description: transform fragment into sentence"
37 "This package provides a function to establish world peace"
38 (beautify-description "A function to establish world peace"))
39
11e296ef
DC
40(test-equal "license->symbol"
41 'license:lgpl2.0
42 (license->symbol license:lgpl2.0))
43
5e892bc3
RW
44(test-assert "alist->package with simple source"
45 (let* ((meta '(("name" . "hello")
46 ("version" . "2.10")
8b920d70
LC
47 ("source" .
48 ;; Use a 'file://' URI so that we don't cause a download.
49 ,(string-append "file://"
50 (search-path %load-path "guix.scm")))
5e892bc3
RW
51 ("build-system" . "gnu")
52 ("home-page" . "https://gnu.org")
53 ("synopsis" . "Say hi")
54 ("description" . "This package says hi.")
55 ("license" . "GPL-3.0+")))
56 (pkg (alist->package meta)))
57 (and (package? pkg)
58 (license:license? (package-license pkg))
59 (build-system? (package-build-system pkg))
60 (origin? (package-source pkg)))))
61
62(test-assert "alist->package with explicit source"
63 (let* ((meta '(("name" . "hello")
64 ("version" . "2.10")
65 ("source" . (("method" . "url-fetch")
66 ("uri" . "mirror://gnu/hello/hello-2.10.tar.gz")
67 ("sha256" .
68 (("base32" .
69 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
70 ("build-system" . "gnu")
71 ("home-page" . "https://gnu.org")
72 ("synopsis" . "Say hi")
73 ("description" . "This package says hi.")
74 ("license" . "GPL-3.0+")))
75 (pkg (alist->package meta)))
76 (and (package? pkg)
77 (license:license? (package-license pkg))
78 (build-system? (package-build-system pkg))
79 (origin? (package-source pkg))
80 (equal? (origin-sha256 (package-source pkg))
81 (base32 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
82
5e2495d0
LC
83(test-equal "alist->package with false license" ;<https://bugs.gnu.org/30470>
84 'license-is-false
85 (let* ((meta '(("name" . "hello")
86 ("version" . "2.10")
87 ("source" . (("method" . "url-fetch")
88 ("uri" . "mirror://gnu/hello/hello-2.10.tar.gz")
89 ("sha256" .
90 (("base32" .
91 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
92 ("build-system" . "gnu")
93 ("home-page" . "https://gnu.org")
94 ("synopsis" . "Say hi")
95 ("description" . "This package says hi.")
96 ("license" . #f))))
97 ;; Note: Use 'or' because comparing with #f otherwise succeeds when
98 ;; there's an exception instead of an actual #f.
99 (or (package-license (alist->package meta))
100 'license-is-false)))
101
81c3dc32
LC
102(test-equal "alist->package with dependencies"
103 `(("gettext" ,(specification->package "gettext")))
104 (let* ((meta '(("name" . "hello")
105 ("version" . "2.10")
106 ("source" . (("method" . "url-fetch")
107 ("uri" . "mirror://gnu/hello/hello-2.10.tar.gz")
108 ("sha256" .
109 (("base32" .
110 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
111 ("build-system" . "gnu")
112 ("home-page" . "https://gnu.org")
113 ("synopsis" . "Say hi")
114 ("description" . "This package says hi.")
115 ;
116 ;; Note: As with Guile-JSON 3.x, JSON arrays are represented
117 ;; by vectors.
118 ("native-inputs" . #("gettext"))
119
120 ("license" . #f))))
121 (package-native-inputs (alist->package meta))))
122
a132f7d6 123(test-end "import-utils")