gnu: libressl: Update to 2.3.3.
[jackhill/guix/guix.git] / tests / scripts-build.scm
CommitLineData
629a064f
LC
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
3;;;
4;;; This file is part of GNU Guix.
5;;;
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.
10;;;
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.
15;;;
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/>.
18
19(define-module (test-scripts-build)
20 #:use-module (guix tests)
21 #:use-module (guix store)
22 #:use-module (guix packages)
23 #:use-module (guix scripts build)
24 #:use-module (guix ui)
47c0f92c
LC
25 #:use-module (gnu packages base)
26 #:use-module (gnu packages busybox)
27 #:use-module (ice-9 match)
629a064f
LC
28 #:use-module (srfi srfi-64))
29
30\f
31(test-begin "scripts-build")
32
33(test-assert "options->transformation, no transformations"
34 (let ((p (dummy-package "foo"))
35 (t (options->transformation '())))
36 (with-store store
37 (eq? (t store p) p))))
38
39(test-assert "options->transformation, with-source"
40 ;; Our pseudo-package is called 'guix.scm' so the 'guix.scm' source should
41 ;; be applicable.
42 (let* ((p (dummy-package "guix.scm"))
43 (s (search-path %load-path "guix.scm"))
44 (t (options->transformation `((with-source . ,s)))))
45 (with-store store
46 (let ((new (t store p)))
47 (and (not (eq? new p))
48 (string=? (package-source new)
49 (add-to-store store "guix.scm" #t
50 "sha256" s)))))))
51
52(test-assert "options->transformation, with-source, no matches"
53 ;; When a transformation in not applicable, a warning must be raised.
54 (let* ((p (dummy-package "foobar"))
55 (s (search-path %load-path "guix.scm"))
56 (t (options->transformation `((with-source . ,s)))))
57 (with-store store
58 (let* ((port (open-output-string))
59 (new (parameterize ((guix-warning-port port))
60 (t store p))))
61 (and (eq? new p)
62 (string-contains (get-output-string port)
63 "had no effect"))))))
64
47c0f92c
LC
65(test-assert "options->transformation, with-input"
66 (let* ((p (dummy-package "guix.scm"
67 (inputs `(("foo" ,coreutils)
68 ("bar" ,grep)
69 ("baz" ,(dummy-package "chbouib"
70 (native-inputs `(("x" ,grep)))))))))
71 (t (options->transformation '((with-input . "coreutils=busybox")
72 (with-input . "grep=findutils")))))
73 (with-store store
74 (let ((new (t store p)))
75 (and (not (eq? new p))
76 (match (package-inputs new)
77 ((("foo" dep1) ("bar" dep2) ("baz" dep3))
78 (and (eq? dep1 busybox)
79 (eq? dep2 findutils)
80 (string=? (package-name dep3) "chbouib")
81 (match (package-native-inputs dep3)
82 ((("x" dep))
83 (eq? dep findutils)))))))))))
84
629a064f
LC
85(test-end)
86
87\f
88(exit (= (test-runner-fail-count (test-runner-current)) 0))