gnu: signify: Update to 26.
[guix.git] / tests / import-utils.scm
blobc3ab25d78833ea11aef942543e2c173516aff1c2
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>
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/>.
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))
29 (test-begin "import-utils")
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."))
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"))
40 (test-equal "license->symbol"
41   'license:lgpl2.0
42   (license->symbol license:lgpl2.0))
44 (test-assert "alist->package with simple source"
45   (let* ((meta '(("name" . "hello")
46                  ("version" . "2.10")
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")))
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)))))
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")))))
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)))
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"))
120                  ("license" . #f))))
121     (package-native-inputs (alist->package meta))))
123 (test-end "import-utils")