gnu: linux-libre: Update to 5.0.10.
[guix.git] / tests / import-utils.scm
blob5c0c041360fd6931b281a2c777d1499f5510834f
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 (srfi srfi-64))
28 (test-begin "import-utils")
30 (test-equal "beautify-description: use double spacing"
31   "This is a package.  It is great.  Trust me Mr.  Hendrix."
32   (beautify-description
33    "This is a package. It is great. Trust me Mr. Hendrix."))
35 (test-equal "beautify-description: transform fragment into sentence"
36   "This package provides a function to establish world peace"
37   (beautify-description "A function to establish world peace"))
39 (test-equal "license->symbol"
40   'license:lgpl2.0
41   (license->symbol license:lgpl2.0))
43 (test-assert "alist->package with simple source"
44   (let* ((meta '(("name" . "hello")
45                  ("version" . "2.10")
46                  ("source" .
47                   ;; Use a 'file://' URI so that we don't cause a download.
48                   ,(string-append "file://"
49                                   (search-path %load-path "guix.scm")))
50                  ("build-system" . "gnu")
51                  ("home-page" . "https://gnu.org")
52                  ("synopsis" . "Say hi")
53                  ("description" . "This package says hi.")
54                  ("license" . "GPL-3.0+")))
55          (pkg (alist->package meta)))
56     (and (package? pkg)
57          (license:license? (package-license pkg))
58          (build-system? (package-build-system pkg))
59          (origin? (package-source pkg)))))
61 (test-assert "alist->package with explicit source"
62   (let* ((meta '(("name" . "hello")
63                  ("version" . "2.10")
64                  ("source" . (("method" . "url-fetch")
65                               ("uri"    . "mirror://gnu/hello/hello-2.10.tar.gz")
66                               ("sha256" .
67                                (("base32" .
68                                  "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
69                  ("build-system" . "gnu")
70                  ("home-page" . "https://gnu.org")
71                  ("synopsis" . "Say hi")
72                  ("description" . "This package says hi.")
73                  ("license" . "GPL-3.0+")))
74          (pkg (alist->package meta)))
75     (and (package? pkg)
76          (license:license? (package-license pkg))
77          (build-system? (package-build-system pkg))
78          (origin? (package-source pkg))
79          (equal? (origin-sha256 (package-source pkg))
80                  (base32 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
82 (test-equal "alist->package with false license"  ;<https://bugs.gnu.org/30470>
83   'license-is-false
84   (let* ((meta '(("name" . "hello")
85                  ("version" . "2.10")
86                  ("source" . (("method" . "url-fetch")
87                               ("uri"    . "mirror://gnu/hello/hello-2.10.tar.gz")
88                               ("sha256" .
89                                (("base32" .
90                                  "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
91                  ("build-system" . "gnu")
92                  ("home-page" . "https://gnu.org")
93                  ("synopsis" . "Say hi")
94                  ("description" . "This package says hi.")
95                  ("license" . #f))))
96     ;; Note: Use 'or' because comparing with #f otherwise succeeds when
97     ;; there's an exception instead of an actual #f.
98     (or (package-license (alist->package meta))
99         'license-is-false)))
101 (test-end "import-utils")