gnu: Add gnome-shell-extension-dash-to-dock.
[jackhill/guix/guix.git] / tests / profiles.scm
CommitLineData
a2078770 1;;; GNU Guix --- Functional package management for GNU
38b77f34 2;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 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)
2225d56a 23 #:use-module (guix gexp)
462f5cca
LC
24 #:use-module (guix store)
25 #:use-module (guix monads)
ef8de985 26 #:use-module (guix grafts)
462f5cca
LC
27 #:use-module (guix packages)
28 #:use-module (guix derivations)
a0dac7a0 29 #:use-module (guix build-system trivial)
462f5cca 30 #:use-module (gnu packages bootstrap)
e39d1461 31 #:use-module ((gnu packages base) #:prefix packages:)
dedb17ad 32 #:use-module ((gnu packages guile) #:prefix packages:)
a2078770 33 #:use-module (ice-9 match)
ef8993e2 34 #:use-module (ice-9 regex)
d664f1b4
LC
35 #:use-module (ice-9 popen)
36 #:use-module (rnrs io ports)
ccda8f7d 37 #:use-module (srfi srfi-1)
79601521 38 #:use-module (srfi srfi-11)
a654dc4b 39 #:use-module (srfi srfi-34)
a2078770
LC
40 #:use-module (srfi srfi-64))
41
343745c8 42;; Test the (guix profiles) module.
a2078770 43
462f5cca 44(define %store
c1bc358f 45 (open-connection-for-tests))
a2078770 46
ef8de985
LC
47;; Globally disable grafts because they can trigger early builds.
48(%graft? #f)
49
a2078770
LC
50;; Example manifest entries.
51
f7554030
AK
52(define guile-1.8.8
53 (manifest-entry
54 (name "guile")
55 (version "1.8.8")
56 (item "/gnu/store/...")
57 (output "out")))
58
a2078770
LC
59(define guile-2.0.9
60 (manifest-entry
61 (name "guile")
62 (version "2.0.9")
a54c94a4 63 (item "/gnu/store/...")
a2078770
LC
64 (output "out")))
65
66(define guile-2.0.9:debug
67 (manifest-entry (inherit guile-2.0.9)
68 (output "debug")))
69
79601521
LC
70(define glibc
71 (manifest-entry
72 (name "glibc")
73 (version "2.19")
74 (item "/gnu/store/...")
75 (output "out")))
76
a2078770
LC
77\f
78(test-begin "profiles")
79
80(test-assert "manifest-installed?"
81 (let ((m (manifest (list guile-2.0.9 guile-2.0.9:debug))))
82 (and (manifest-installed? m (manifest-pattern (name "guile")))
83 (manifest-installed? m (manifest-pattern
84 (name "guile") (output "debug")))
85 (manifest-installed? m (manifest-pattern
86 (name "guile") (output "out")
87 (version "2.0.9")))
88 (not (manifest-installed?
89 m (manifest-pattern (name "guile") (version "1.8.8"))))
90 (not (manifest-installed?
91 m (manifest-pattern (name "guile") (output "foobar")))))))
92
93(test-assert "manifest-matching-entries"
94 (let* ((e (list guile-2.0.9 guile-2.0.9:debug))
95 (m (manifest e)))
487cbb01 96 (and (equal? e
a2078770
LC
97 (manifest-matching-entries m
98 (list (manifest-pattern
99 (name "guile")
100 (output #f)))))
101 (equal? (list guile-2.0.9)
102 (manifest-matching-entries m
103 (list (manifest-pattern
104 (name "guile")
105 (version "2.0.9"))))))))
106
487cbb01
LC
107(test-assert "manifest-matching-entries, no match"
108 (let ((m (manifest (list guile-2.0.9)))
109 (p (manifest-pattern (name "python"))))
110 (guard (c ((unmatched-pattern-error? c)
111 (and (eq? p (unmatched-pattern-error-pattern c))
112 (eq? m (unmatched-pattern-error-manifest c)))))
113 (manifest-matching-entries m (list p))
114 #f)))
115
a2078770
LC
116(test-assert "manifest-remove"
117 (let* ((m0 (manifest (list guile-2.0.9 guile-2.0.9:debug)))
118 (m1 (manifest-remove m0
119 (list (manifest-pattern (name "guile")))))
120 (m2 (manifest-remove m1
121 (list (manifest-pattern (name "guile"))))) ; same
122 (m3 (manifest-remove m2
123 (list (manifest-pattern
124 (name "guile") (output "debug")))))
125 (m4 (manifest-remove m3
126 (list (manifest-pattern (name "guile"))))))
127 (match (manifest-entries m2)
128 ((($ <manifest-entry> "guile" "2.0.9" "debug"))
129 (and (equal? m1 m2)
130 (null? (manifest-entries m3))
131 (null? (manifest-entries m4)))))))
132
f7554030
AK
133(test-assert "manifest-add"
134 (let* ((m0 (manifest '()))
135 (m1 (manifest-add m0 (list guile-1.8.8)))
136 (m2 (manifest-add m1 (list guile-2.0.9)))
137 (m3 (manifest-add m2 (list guile-2.0.9:debug)))
138 (m4 (manifest-add m3 (list guile-2.0.9:debug))))
139 (and (match (manifest-entries m1)
140 ((($ <manifest-entry> "guile" "1.8.8" "out")) #t)
141 (_ #f))
142 (match (manifest-entries m2)
143 ((($ <manifest-entry> "guile" "2.0.9" "out")) #t)
144 (_ #f))
145 (equal? m3 m4))))
146
435603a1
LC
147(test-equal "manifest-add removes duplicates" ;<https://bugs.gnu.org/30569>
148 (list guile-2.0.9)
149 (manifest-entries (manifest-add (manifest '())
150 (list guile-2.0.9 guile-2.0.9))))
151
343745c8
AK
152(test-assert "manifest-perform-transaction"
153 (let* ((m0 (manifest (list guile-2.0.9 guile-2.0.9:debug)))
154 (t1 (manifest-transaction
155 (install (list guile-1.8.8))
156 (remove (list (manifest-pattern (name "guile")
157 (output "debug"))))))
158 (t2 (manifest-transaction
159 (remove (list (manifest-pattern (name "guile")
160 (version "2.0.9")
161 (output #f))))))
162 (m1 (manifest-perform-transaction m0 t1))
163 (m2 (manifest-perform-transaction m1 t2))
164 (m3 (manifest-perform-transaction m0 t2)))
165 (and (match (manifest-entries m1)
166 ((($ <manifest-entry> "guile" "1.8.8" "out")) #t)
167 (_ #f))
168 (equal? m1 m2)
169 (null? (manifest-entries m3)))))
170
79601521
LC
171(test-assert "manifest-transaction-effects"
172 (let* ((m0 (manifest (list guile-1.8.8)))
173 (t (manifest-transaction
487cbb01 174 (install (list guile-2.0.9 glibc)))))
46b23e1a 175 (let-values (((remove install upgrade downgrade)
79601521 176 (manifest-transaction-effects m0 t)))
46b23e1a 177 (and (null? remove) (null? downgrade)
79601521 178 (equal? (list glibc) install)
ef8993e2
LC
179 (equal? (list (cons guile-1.8.8 guile-2.0.9)) upgrade)))))
180
46b23e1a
LC
181(test-assert "manifest-transaction-effects and downgrades"
182 (let* ((m0 (manifest (list guile-2.0.9)))
183 (t (manifest-transaction (install (list guile-1.8.8)))))
184 (let-values (((remove install upgrade downgrade)
185 (manifest-transaction-effects m0 t)))
186 (and (null? remove) (null? install) (null? upgrade)
187 (equal? (list (cons guile-2.0.9 guile-1.8.8)) downgrade)))))
188
3bea13bb
LC
189(test-assert "manifest-transaction-effects and pseudo-upgrades"
190 (let* ((m0 (manifest (list guile-2.0.9)))
191 (t (manifest-transaction (install (list guile-2.0.9)))))
192 (let-values (((remove install upgrade downgrade)
193 (manifest-transaction-effects m0 t)))
194 (and (null? remove) (null? install) (null? downgrade)
195 (equal? (list (cons guile-2.0.9 guile-2.0.9)) upgrade)))))
196
c8c25704
LC
197(test-assert "manifest-transaction-null?"
198 (manifest-transaction-null? (manifest-transaction)))
199
6d382339
LC
200(test-assert "manifest-transaction-removal-candidate?"
201 (let ((m (manifest (list guile-2.0.9)))
202 (t (manifest-transaction
203 (remove (list (manifest-pattern (name "guile")))))))
204 (and (manifest-transaction-removal-candidate? guile-2.0.9 t)
205 (not (manifest-transaction-removal-candidate? glibc t)))))
206
ebf5ad46
LC
207(test-assertm "profile-derivation"
208 (mlet* %store-monad
209 ((entry -> (package->manifest-entry %bootstrap-guile))
210 (guile (package->derivation %bootstrap-guile))
211 (drv (profile-derivation (manifest (list entry))
a6562c7e
LC
212 #:hooks '()
213 #:locales? #f))
ebf5ad46
LC
214 (profile -> (derivation->output-path drv))
215 (bindir -> (string-append profile "/bin"))
216 (_ (built-derivations (list drv))))
217 (return (and (file-exists? (string-append bindir "/guile"))
218 (string=? (dirname (readlink bindir))
219 (derivation->output-path guile))))))
462f5cca 220
e00ade3f
LC
221(test-assertm "profile-derivation relative symlinks, one entry"
222 (mlet* %store-monad
223 ((entry -> (package->manifest-entry %bootstrap-guile))
224 (guile (package->derivation %bootstrap-guile))
225 (drv (profile-derivation (manifest (list entry))
226 #:relative-symlinks? #t
227 #:hooks '()
228 #:locales? #f))
229 (profile -> (derivation->output-path drv))
230 (bindir -> (string-append profile "/bin"))
231 (_ (built-derivations (list drv))))
232 (return (and (file-exists? (string-append bindir "/guile"))
233 (string=? (readlink bindir)
234 (string-append "../"
235 (basename
236 (derivation->output-path guile))
237 "/bin"))))))
238
239(unless (network-reachable?) (test-skip 1))
240(test-assertm "profile-derivation relative symlinks, two entries"
241 (mlet* %store-monad
03d76577
LC
242 ((manifest -> (packages->manifest
243 (list %bootstrap-guile gnu-make-for-tests)))
e00ade3f 244 (guile (package->derivation %bootstrap-guile))
03d76577 245 (make (package->derivation gnu-make-for-tests))
e00ade3f
LC
246 (drv (profile-derivation manifest
247 #:relative-symlinks? #t
248 #:hooks '()
249 #:locales? #f))
250 (profile -> (derivation->output-path drv))
251 (bindir -> (string-append profile "/bin"))
252 (_ (built-derivations (list drv))))
253 (return (and (file-exists? (string-append bindir "/guile"))
254 (file-exists? (string-append bindir "/make"))
255 (string=? (readlink (string-append bindir "/guile"))
256 (string-append "../../"
257 (basename
258 (derivation->output-path guile))
259 "/bin/guile"))
260 (string=? (readlink (string-append bindir "/make"))
261 (string-append "../../"
262 (basename
263 (derivation->output-path make))
264 "/bin/make"))))))
265
e39d1461
LC
266(test-assertm "profile-derivation, inputs"
267 (mlet* %store-monad
268 ((entry -> (package->manifest-entry packages:glibc "debug"))
269 (drv (profile-derivation (manifest (list entry))
a6562c7e
LC
270 #:hooks '()
271 #:locales? #f)))
e39d1461
LC
272 (return (derivation-inputs drv))))
273
176febe3
LC
274(test-assertm "profile-derivation, cross-compilation"
275 (mlet* %store-monad
276 ((manifest -> (packages->manifest (list packages:sed packages:grep)))
277 (target -> "arm-linux-gnueabihf")
278 (grep (package->cross-derivation packages:grep target))
279 (sed (package->cross-derivation packages:sed target))
280 (locales (package->derivation packages:glibc-utf8-locales))
281 (drv (profile-derivation manifest
282 #:hooks '()
283 #:locales? #t
284 #:target target)))
ede121de
CM
285 (define (find-input package)
286 (let ((name (string-append (package-full-name package "-") ".drv")))
176febe3
LC
287 (any (lambda (input)
288 (let ((input (derivation-input-path input)))
289 (and (string-suffix? name input) input)))
290 (derivation-inputs drv))))
291
292 ;; The inputs for grep and sed should be cross-build derivations, but that
293 ;; for the glibc-utf8-locales should be a native build.
294 (return (and (string=? (derivation-system drv) (%current-system))
ede121de 295 (string=? (find-input packages:grep)
176febe3 296 (derivation-file-name grep))
ede121de 297 (string=? (find-input packages:sed)
176febe3 298 (derivation-file-name sed))
ede121de 299 (string=? (find-input packages:glibc-utf8-locales)
176febe3
LC
300 (derivation-file-name locales))))))
301
9e90fc77
LC
302(test-assert "package->manifest-entry defaults to \"out\""
303 (let ((outputs (package-outputs packages:glibc)))
304 (equal? (manifest-entry-output
305 (package->manifest-entry (package
306 (inherit packages:glibc)
307 (outputs (reverse outputs)))))
308 (manifest-entry-output
309 (package->manifest-entry packages:glibc))
310 "out")))
311
dedb17ad
LC
312(test-assertm "profile-manifest, search-paths"
313 (mlet* %store-monad
314 ((guile -> (package
315 (inherit %bootstrap-guile)
316 (native-search-paths
317 (package-native-search-paths packages:guile-2.0))))
318 (entry -> (package->manifest-entry guile))
319 (drv (profile-derivation (manifest (list entry))
a6562c7e
LC
320 #:hooks '()
321 #:locales? #f))
dedb17ad
LC
322 (profile -> (derivation->output-path drv)))
323 (mbegin %store-monad
324 (built-derivations (list drv))
325
326 ;; Read the manifest back and make sure search paths are preserved.
327 (let ((manifest (profile-manifest profile)))
328 (match (manifest-entries manifest)
329 ((result)
330 (return (equal? (manifest-entry-search-paths result)
331 (manifest-entry-search-paths entry)
332 (package-native-search-paths
333 packages:guile-2.0)))))))))
d664f1b4 334
ccda8f7d
LC
335(test-assert "package->manifest-entry, search paths"
336 ;; See <http://bugs.gnu.org/22073>.
2d17a904 337 (let ((mpl (@ (gnu packages python-xyz) python2-matplotlib)))
ccda8f7d
LC
338 (lset= eq?
339 (package-transitive-native-search-paths mpl)
340 (manifest-entry-search-paths
341 (package->manifest-entry mpl)))))
342
55b4715f
LC
343(test-equal "packages->manifest, propagated inputs"
344 (map (match-lambda
345 ((label package)
346 (list (package-name package) (package-version package)
347 package)))
348 (package-propagated-inputs packages:guile-2.2))
349 (map (lambda (entry)
350 (list (manifest-entry-name entry)
351 (manifest-entry-version entry)
352 (manifest-entry-item entry)))
353 (manifest-entry-dependencies
354 (package->manifest-entry packages:guile-2.2))))
355
b3a00885
LC
356(test-assert "manifest-entry-parent"
357 (let ((entry (package->manifest-entry packages:guile-2.2)))
358 (match (manifest-entry-dependencies entry)
359 ((dependencies ..1)
360 (and (every (lambda (parent)
361 (eq? entry (force parent)))
362 (map manifest-entry-parent dependencies))
363 (not (force (manifest-entry-parent entry))))))))
364
55b4715f
LC
365(test-assertm "read-manifest"
366 (mlet* %store-monad ((manifest -> (packages->manifest
367 (list (package
368 (inherit %bootstrap-guile)
369 (native-search-paths
370 (package-native-search-paths
371 packages:guile-2.0))))))
372 (drv (profile-derivation manifest
373 #:hooks '()
374 #:locales? #f))
375 (out -> (derivation->output-path drv)))
376 (define (entry->sexp entry)
377 (list (manifest-entry-name entry)
378 (manifest-entry-version entry)
379 (manifest-entry-search-paths entry)
b3a00885
LC
380 (manifest-entry-dependencies entry)
381 (force (manifest-entry-parent entry))))
55b4715f
LC
382
383 (mbegin %store-monad
384 (built-derivations (list drv))
385 (let ((manifest2 (profile-manifest out)))
386 (return (equal? (map entry->sexp (manifest-entries manifest))
387 (map entry->sexp (manifest-entries manifest2))))))))
388
a654dc4b
LC
389(test-equal "collision"
390 '(("guile-bootstrap" "2.0") ("guile-bootstrap" "42"))
391 (guard (c ((profile-collision-error? c)
392 (let ((entry1 (profile-collision-error-entry c))
393 (entry2 (profile-collision-error-conflict c)))
394 (list (list (manifest-entry-name entry1)
395 (manifest-entry-version entry1))
396 (list (manifest-entry-name entry2)
397 (manifest-entry-version entry2))))))
398 (run-with-store %store
399 (mlet* %store-monad ((p0 -> (package
400 (inherit %bootstrap-guile)
401 (version "42")))
402 (p1 -> (dummy-package "p1"
403 (propagated-inputs `(("p0" ,p0)))))
404 (manifest -> (packages->manifest
405 (list %bootstrap-guile p1)))
406 (drv (profile-derivation manifest
407 #:hooks '()
408 #:locales? #f)))
409 (return #f)))))
410
411(test-equal "collision of propagated inputs"
412 '(("guile-bootstrap" "2.0") ("guile-bootstrap" "42"))
413 (guard (c ((profile-collision-error? c)
414 (let ((entry1 (profile-collision-error-entry c))
415 (entry2 (profile-collision-error-conflict c)))
416 (list (list (manifest-entry-name entry1)
417 (manifest-entry-version entry1))
418 (list (manifest-entry-name entry2)
419 (manifest-entry-version entry2))))))
420 (run-with-store %store
421 (mlet* %store-monad ((p0 -> (package
422 (inherit %bootstrap-guile)
423 (version "42")))
424 (p1 -> (dummy-package "p1"
425 (propagated-inputs
426 `(("guile" ,%bootstrap-guile)))))
427 (p2 -> (dummy-package "p2"
428 (propagated-inputs
429 `(("guile" ,p0)))))
430 (manifest -> (packages->manifest (list p1 p2)))
431 (drv (profile-derivation manifest
432 #:hooks '()
433 #:locales? #f)))
434 (return #f)))))
435
436(test-assertm "no collision"
437 ;; Here we have an entry that is "lowered" (its 'item' field is a store file
438 ;; name) and another entry (its 'item' field is a package) that is
439 ;; equivalent.
440 (mlet* %store-monad ((p -> (dummy-package "p"
441 (propagated-inputs
442 `(("guile" ,%bootstrap-guile)))))
443 (guile (package->derivation %bootstrap-guile))
444 (entry -> (manifest-entry
445 (inherit (package->manifest-entry
446 %bootstrap-guile))
447 (item (derivation->output-path guile))))
448 (manifest -> (manifest
449 (list entry
450 (package->manifest-entry p))))
451 (drv (profile-derivation manifest)))
452 (return (->bool drv))))
453
d664f1b4
LC
454(test-assertm "etc/profile"
455 ;; Make sure we get an 'etc/profile' file that at least defines $PATH.
456 (mlet* %store-monad
457 ((guile -> (package
458 (inherit %bootstrap-guile)
459 (native-search-paths
460 (package-native-search-paths packages:guile-2.0))))
461 (entry -> (package->manifest-entry guile))
462 (drv (profile-derivation (manifest (list entry))
a6562c7e
LC
463 #:hooks '()
464 #:locales? #f))
d664f1b4
LC
465 (profile -> (derivation->output-path drv)))
466 (mbegin %store-monad
467 (built-derivations (list drv))
468 (let* ((pipe (open-input-pipe
9e006fb3
TUBK
469 (string-append "unset GUIX_PROFILE; "
470 ;; 'source' is a Bashism; use '.' (dot).
471 ". " profile "/etc/profile; "
472 ;; Don't try to parse set(1) output because
473 ;; it differs among shells; just use echo.
474 "echo $PATH")))
475 (path (get-string-all pipe)))
d664f1b4
LC
476 (return
477 (and (zero? (close-pipe pipe))
9e006fb3 478 (string-contains path (string-append profile "/bin"))))))))
d664f1b4 479
a0dac7a0
LC
480(test-assertm "etc/profile when etc/ already exists"
481 ;; Here 'union-build' makes the profile's etc/ a symlink to the package's
482 ;; etc/ directory, which makes it read-only. Make sure the profile build
483 ;; handles that.
484 (mlet* %store-monad
485 ((thing -> (dummy-package "dummy"
486 (build-system trivial-build-system)
487 (arguments
488 `(#:guile ,%bootstrap-guile
489 #:builder
490 (let ((out (assoc-ref %outputs "out")))
491 (mkdir out)
492 (mkdir (string-append out "/etc"))
493 (call-with-output-file (string-append out "/etc/foo")
494 (lambda (port)
1e868858
MW
495 (display "foo!" port)))
496 #t)))))
a0dac7a0
LC
497 (entry -> (package->manifest-entry thing))
498 (drv (profile-derivation (manifest (list entry))
a6562c7e
LC
499 #:hooks '()
500 #:locales? #f))
a0dac7a0
LC
501 (profile -> (derivation->output-path drv)))
502 (mbegin %store-monad
503 (built-derivations (list drv))
504 (return (and (file-exists? (string-append profile "/etc/profile"))
505 (string=? (call-with-input-file
506 (string-append profile "/etc/foo")
507 get-string-all)
508 "foo!"))))))
509
113c17a0
LC
510(test-assertm "etc/profile when etc/ is a symlink"
511 ;; When etc/ is a symlink, the unsymlink code in 0.8.2 would fail
512 ;; gracelessly because 'scandir' would return #f.
513 (mlet* %store-monad
514 ((thing -> (dummy-package "dummy"
515 (build-system trivial-build-system)
516 (arguments
517 `(#:guile ,%bootstrap-guile
518 #:builder
519 (let ((out (assoc-ref %outputs "out")))
520 (mkdir out)
521 (mkdir (string-append out "/foo"))
522 (symlink "foo" (string-append out "/etc"))
523 (call-with-output-file (string-append out "/etc/bar")
524 (lambda (port)
1e868858
MW
525 (display "foo!" port)))
526 #t)))))
113c17a0
LC
527 (entry -> (package->manifest-entry thing))
528 (drv (profile-derivation (manifest (list entry))
a6562c7e
LC
529 #:hooks '()
530 #:locales? #f))
113c17a0
LC
531 (profile -> (derivation->output-path drv)))
532 (mbegin %store-monad
533 (built-derivations (list drv))
534 (return (and (file-exists? (string-append profile "/etc/profile"))
535 (string=? (call-with-input-file
536 (string-append profile "/etc/bar")
537 get-string-all)
538 "foo!"))))))
539
2225d56a
LC
540(test-assertm "profile-derivation when etc/ is a relative symlink"
541 ;; See <https://bugs.gnu.org/32686>.
542 (mlet* %store-monad
543 ((etc (gexp->derivation
544 "etc"
545 #~(begin
546 (mkdir #$output)
547 (call-with-output-file (string-append #$output "/foo")
548 (lambda (port)
549 (display "Heya!" port))))))
550 (thing -> (dummy-package "dummy"
551 (build-system trivial-build-system)
552 (inputs
553 `(("etc" ,etc)))
554 (arguments
555 `(#:guile ,%bootstrap-guile
556 #:builder
557 (let ((out (assoc-ref %outputs "out"))
558 (etc (assoc-ref %build-inputs "etc")))
559 (mkdir out)
560 (symlink etc (string-append out "/etc"))
561 #t)))))
562 (entry -> (package->manifest-entry thing))
563 (drv (profile-derivation (manifest (list entry))
564 #:relative-symlinks? #t
565 #:hooks '()
566 #:locales? #f))
567 (profile -> (derivation->output-path drv)))
568 (mbegin %store-monad
569 (built-derivations (list drv))
570 (return (string=? (call-with-input-file
571 (string-append profile "/etc/foo")
572 get-string-all)
573 "Heya!")))))
574
22ef06b8
LC
575(test-equalm "union vs. dangling symlink" ;<https://bugs.gnu.org/26949>
576 "does-not-exist"
577 (mlet* %store-monad
578 ((thing1 -> (dummy-package "dummy"
579 (build-system trivial-build-system)
580 (arguments
581 `(#:guile ,%bootstrap-guile
582 #:builder
583 (let ((out (assoc-ref %outputs "out")))
584 (mkdir out)
585 (symlink "does-not-exist"
586 (string-append out "/dangling"))
587 #t)))))
588 (thing2 -> (package (inherit thing1) (name "dummy2")))
589 (drv (profile-derivation (packages->manifest
590 (list thing1 thing2))
591 #:hooks '()
592 #:locales? #f))
593 (profile -> (derivation->output-path drv)))
594 (mbegin %store-monad
595 (built-derivations (list drv))
596 (return (readlink (readlink (string-append profile "/dangling")))))))
597
38b77f34
LC
598(test-equalm "profile in profile"
599 '("foo" "0")
600
601 ;; Make sure we can build a profile that has another profile has one of its
602 ;; entries. The new profile's /manifest and /etc/profile must override the
603 ;; other's.
604 (mlet* %store-monad
605 ((prof0 (profile-derivation
606 (manifest
607 (list (package->manifest-entry %bootstrap-guile)))
608 #:hooks '()
609 #:locales? #f))
610 (prof1 (profile-derivation
611 (manifest (list (manifest-entry
612 (name "foo")
613 (version "0")
614 (item prof0))))
615 #:hooks '()
616 #:locales? #f)))
617 (mbegin %store-monad
618 (built-derivations (list prof1))
619 (let ((out (derivation->output-path prof1)))
620 (return (and (file-exists?
621 (string-append out "/bin/guile"))
622 (let ((manifest (profile-manifest out)))
623 (match (manifest-entries manifest)
624 ((entry)
625 (list (manifest-entry-name entry)
626 (manifest-entry-version entry)))))))))))
627
a2078770
LC
628(test-end "profiles")
629
a2078770
LC
630;;; Local Variables:
631;;; eval: (put 'dummy-package 'scheme-indent-function 1)
632;;; End: