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