Commit | Line | Data |
---|---|---|
a2078770 | 1 | ;;; GNU Guix --- Functional package management for GNU |
a54c94a4 | 2 | ;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org> |
343745c8 | 3 | ;;; Copyright © 2014 Alex Kost <alezost@gmail.com> |
a2078770 LC |
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/>. | |
19 | ||
20 | (define-module (test-profiles) | |
c1bc358f | 21 | #:use-module (guix tests) |
a2078770 | 22 | #:use-module (guix profiles) |
462f5cca LC |
23 | #:use-module (guix store) |
24 | #:use-module (guix monads) | |
25 | #:use-module (guix packages) | |
26 | #:use-module (guix derivations) | |
27 | #:use-module (gnu packages bootstrap) | |
a2078770 LC |
28 | #:use-module (ice-9 match) |
29 | #:use-module (srfi srfi-64)) | |
30 | ||
343745c8 | 31 | ;; Test the (guix profiles) module. |
a2078770 | 32 | |
462f5cca | 33 | (define %store |
c1bc358f | 34 | (open-connection-for-tests)) |
a2078770 LC |
35 | |
36 | ;; Example manifest entries. | |
37 | ||
f7554030 AK |
38 | (define guile-1.8.8 |
39 | (manifest-entry | |
40 | (name "guile") | |
41 | (version "1.8.8") | |
42 | (item "/gnu/store/...") | |
43 | (output "out"))) | |
44 | ||
a2078770 LC |
45 | (define guile-2.0.9 |
46 | (manifest-entry | |
47 | (name "guile") | |
48 | (version "2.0.9") | |
a54c94a4 | 49 | (item "/gnu/store/...") |
a2078770 LC |
50 | (output "out"))) |
51 | ||
52 | (define guile-2.0.9:debug | |
53 | (manifest-entry (inherit guile-2.0.9) | |
54 | (output "debug"))) | |
55 | ||
56 | \f | |
57 | (test-begin "profiles") | |
58 | ||
59 | (test-assert "manifest-installed?" | |
60 | (let ((m (manifest (list guile-2.0.9 guile-2.0.9:debug)))) | |
61 | (and (manifest-installed? m (manifest-pattern (name "guile"))) | |
62 | (manifest-installed? m (manifest-pattern | |
63 | (name "guile") (output "debug"))) | |
64 | (manifest-installed? m (manifest-pattern | |
65 | (name "guile") (output "out") | |
66 | (version "2.0.9"))) | |
67 | (not (manifest-installed? | |
68 | m (manifest-pattern (name "guile") (version "1.8.8")))) | |
69 | (not (manifest-installed? | |
70 | m (manifest-pattern (name "guile") (output "foobar"))))))) | |
71 | ||
72 | (test-assert "manifest-matching-entries" | |
73 | (let* ((e (list guile-2.0.9 guile-2.0.9:debug)) | |
74 | (m (manifest e))) | |
75 | (and (null? (manifest-matching-entries m | |
76 | (list (manifest-pattern | |
77 | (name "python"))))) | |
78 | (equal? e | |
79 | (manifest-matching-entries m | |
80 | (list (manifest-pattern | |
81 | (name "guile") | |
82 | (output #f))))) | |
83 | (equal? (list guile-2.0.9) | |
84 | (manifest-matching-entries m | |
85 | (list (manifest-pattern | |
86 | (name "guile") | |
87 | (version "2.0.9")))))))) | |
88 | ||
89 | (test-assert "manifest-remove" | |
90 | (let* ((m0 (manifest (list guile-2.0.9 guile-2.0.9:debug))) | |
91 | (m1 (manifest-remove m0 | |
92 | (list (manifest-pattern (name "guile"))))) | |
93 | (m2 (manifest-remove m1 | |
94 | (list (manifest-pattern (name "guile"))))) ; same | |
95 | (m3 (manifest-remove m2 | |
96 | (list (manifest-pattern | |
97 | (name "guile") (output "debug"))))) | |
98 | (m4 (manifest-remove m3 | |
99 | (list (manifest-pattern (name "guile")))))) | |
100 | (match (manifest-entries m2) | |
101 | ((($ <manifest-entry> "guile" "2.0.9" "debug")) | |
102 | (and (equal? m1 m2) | |
103 | (null? (manifest-entries m3)) | |
104 | (null? (manifest-entries m4))))))) | |
105 | ||
f7554030 AK |
106 | (test-assert "manifest-add" |
107 | (let* ((m0 (manifest '())) | |
108 | (m1 (manifest-add m0 (list guile-1.8.8))) | |
109 | (m2 (manifest-add m1 (list guile-2.0.9))) | |
110 | (m3 (manifest-add m2 (list guile-2.0.9:debug))) | |
111 | (m4 (manifest-add m3 (list guile-2.0.9:debug)))) | |
112 | (and (match (manifest-entries m1) | |
113 | ((($ <manifest-entry> "guile" "1.8.8" "out")) #t) | |
114 | (_ #f)) | |
115 | (match (manifest-entries m2) | |
116 | ((($ <manifest-entry> "guile" "2.0.9" "out")) #t) | |
117 | (_ #f)) | |
118 | (equal? m3 m4)))) | |
119 | ||
343745c8 AK |
120 | (test-assert "manifest-perform-transaction" |
121 | (let* ((m0 (manifest (list guile-2.0.9 guile-2.0.9:debug))) | |
122 | (t1 (manifest-transaction | |
123 | (install (list guile-1.8.8)) | |
124 | (remove (list (manifest-pattern (name "guile") | |
125 | (output "debug")))))) | |
126 | (t2 (manifest-transaction | |
127 | (remove (list (manifest-pattern (name "guile") | |
128 | (version "2.0.9") | |
129 | (output #f)))))) | |
130 | (m1 (manifest-perform-transaction m0 t1)) | |
131 | (m2 (manifest-perform-transaction m1 t2)) | |
132 | (m3 (manifest-perform-transaction m0 t2))) | |
133 | (and (match (manifest-entries m1) | |
134 | ((($ <manifest-entry> "guile" "1.8.8" "out")) #t) | |
135 | (_ #f)) | |
136 | (equal? m1 m2) | |
137 | (null? (manifest-entries m3))))) | |
138 | ||
462f5cca LC |
139 | (test-assert "profile-derivation" |
140 | (run-with-store %store | |
141 | (mlet* %store-monad | |
142 | ((entry -> (package->manifest-entry %bootstrap-guile)) | |
143 | (guile (package->derivation %bootstrap-guile)) | |
79ee406d LC |
144 | (drv (profile-derivation (manifest (list entry)) |
145 | #:info-dir? #f)) | |
462f5cca LC |
146 | (profile -> (derivation->output-path drv)) |
147 | (bindir -> (string-append profile "/bin")) | |
148 | (_ (built-derivations (list drv)))) | |
149 | (return (and (file-exists? (string-append bindir "/guile")) | |
150 | (string=? (dirname (readlink bindir)) | |
151 | (derivation->output-path guile))))))) | |
152 | ||
a2078770 LC |
153 | (test-end "profiles") |
154 | ||
155 | \f | |
156 | (exit (= (test-runner-fail-count (test-runner-current)) 0)) | |
157 | ||
158 | ;;; Local Variables: | |
159 | ;;; eval: (put 'dummy-package 'scheme-indent-function 1) | |
160 | ;;; End: |