Commit | Line | Data |
---|---|---|
e3ce5d70 LC |
1 | ;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*- |
2 | ;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org> | |
3 | ;;; | |
4 | ;;; This file is part of Guix. | |
5 | ;;; | |
6 | ;;; 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 | ;;; 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 Guix. If not, see <http://www.gnu.org/licenses/>. | |
18 | ||
19 | ||
20 | (define-module (test-packages) | |
21 | #:use-module (guix store) | |
22 | #:use-module (guix utils) | |
23 | #:use-module (guix derivations) | |
24 | #:use-module (guix packages) | |
a3d73f59 | 25 | #:use-module (guix build-system gnu) |
6b1891b0 | 26 | #:use-module (distro) |
e3ce5d70 | 27 | #:use-module (distro base) |
6b1891b0 LC |
28 | #:use-module (srfi srfi-26) |
29 | #:use-module (srfi srfi-64) | |
30 | #:use-module (ice-9 match)) | |
e3ce5d70 LC |
31 | |
32 | ;; Test the high-level packaging layer. | |
33 | ||
34 | (define %store | |
35 | (false-if-exception (open-connection))) | |
36 | ||
37 | (test-begin "packages") | |
38 | ||
a3d73f59 LC |
39 | (define-syntax-rule (dummy-package name* extra-fields ...) |
40 | (package (name name*) (version "0") (source #f) | |
41 | (build-system gnu-build-system) | |
42 | (description #f) (long-description #f) | |
43 | (home-page #f) | |
44 | extra-fields ...)) | |
45 | ||
46 | (test-assert "package-transitive-inputs" | |
47 | (let* ((a (dummy-package "a")) | |
48 | (b (dummy-package "b" | |
49 | (propagated-inputs `(("a" ,a))))) | |
50 | (c (dummy-package "c" | |
51 | (inputs `(("a" ,a))))) | |
52 | (d (dummy-package "d" | |
53 | (propagated-inputs `(("x" "something.drv"))))) | |
54 | (e (dummy-package "e" | |
55 | (inputs `(("b" ,b) ("c" ,c) ("d" ,d)))))) | |
56 | (and (null? (package-transitive-inputs a)) | |
57 | (equal? `(("a" ,a)) (package-transitive-inputs b)) | |
58 | (equal? `(("a" ,a)) (package-transitive-inputs c)) | |
59 | (equal? (package-propagated-inputs d) | |
60 | (package-transitive-inputs d)) | |
61 | (equal? `(("b" ,b) ("b/a" ,a) ("c" ,c) | |
62 | ("d" ,d) ("d/x" "something.drv")) | |
63 | (pk 'x (package-transitive-inputs e)))))) | |
64 | ||
e3ce5d70 LC |
65 | (test-skip (if (not %store) 1 0)) |
66 | ||
67 | (test-assert "GNU Hello" | |
68 | (and (package? hello) | |
35f3c5f5 LC |
69 | (or (location? (package-location hello)) |
70 | (not (package-location hello))) | |
e3ce5d70 LC |
71 | (let* ((drv (package-derivation %store hello)) |
72 | (out (derivation-path->output-path drv))) | |
73 | (and (build-derivations %store (list drv)) | |
74 | (file-exists? (string-append out "/bin/hello")))))) | |
75 | ||
6b1891b0 LC |
76 | (test-assert "find-packages-by-name" |
77 | (match (find-packages-by-name "hello") | |
78 | (((? (cut eq? hello <>))) #t) | |
79 | (wrong (pk 'find-packages-by-name wrong #f)))) | |
80 | ||
81 | (test-assert "find-packages-by-name with version" | |
82 | (match (find-packages-by-name "hello" (package-version hello)) | |
83 | (((? (cut eq? hello <>))) #t) | |
84 | (wrong (pk 'find-packages-by-name wrong #f)))) | |
85 | ||
e3ce5d70 LC |
86 | (test-end "packages") |
87 | ||
88 | \f | |
89 | (exit (= (test-runner-fail-count (test-runner-current)) 0)) | |
90 | ||
91 | ;;; Local Variables: | |
92 | ;;; eval: (put 'test-assert 'scheme-indent-function 1) | |
a3d73f59 | 93 | ;;; eval: (put 'dummy-package 'scheme-indent-function 1) |
e3ce5d70 | 94 | ;;; End: |