Commit | Line | Data |
---|---|---|
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) | |
25 | #:use-module (srfi srfi-64)) | |
26 | ||
27 | \f | |
28 | (test-begin "scripts-build") | |
29 | ||
30 | (test-assert "options->transformation, no transformations" | |
31 | (let ((p (dummy-package "foo")) | |
32 | (t (options->transformation '()))) | |
33 | (with-store store | |
34 | (eq? (t store p) p)))) | |
35 | ||
36 | (test-assert "options->transformation, with-source" | |
37 | ;; Our pseudo-package is called 'guix.scm' so the 'guix.scm' source should | |
38 | ;; be applicable. | |
39 | (let* ((p (dummy-package "guix.scm")) | |
40 | (s (search-path %load-path "guix.scm")) | |
41 | (t (options->transformation `((with-source . ,s))))) | |
42 | (with-store store | |
43 | (let ((new (t store p))) | |
44 | (and (not (eq? new p)) | |
45 | (string=? (package-source new) | |
46 | (add-to-store store "guix.scm" #t | |
47 | "sha256" s))))))) | |
48 | ||
49 | (test-assert "options->transformation, with-source, no matches" | |
50 | ;; When a transformation in not applicable, a warning must be raised. | |
51 | (let* ((p (dummy-package "foobar")) | |
52 | (s (search-path %load-path "guix.scm")) | |
53 | (t (options->transformation `((with-source . ,s))))) | |
54 | (with-store store | |
55 | (let* ((port (open-output-string)) | |
56 | (new (parameterize ((guix-warning-port port)) | |
57 | (t store p)))) | |
58 | (and (eq? new p) | |
59 | (string-contains (get-output-string port) | |
60 | "had no effect")))))) | |
61 | ||
62 | (test-end) | |
63 | ||
64 | \f | |
65 | (exit (= (test-runner-fail-count (test-runner-current)) 0)) |