Revert "nls: Use xgettext and msgmerge with --no-wrap."
[jackhill/guix/guix.git] / tests / profiles.scm
CommitLineData
a2078770 1;;; GNU Guix --- Functional package management for GNU
a54c94a4 2;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
a2078770
LC
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-profiles)
20 #:use-module (guix profiles)
462f5cca
LC
21 #:use-module (guix store)
22 #:use-module (guix monads)
23 #:use-module (guix packages)
24 #:use-module (guix derivations)
25 #:use-module (gnu packages bootstrap)
a2078770
LC
26 #:use-module (ice-9 match)
27 #:use-module (srfi srfi-64))
28
29;; Test the (guix profile) module.
30
462f5cca
LC
31(define %store
32 (open-connection))
33
34(define guile-for-build
35 (package-derivation %store %bootstrap-guile))
36
37;; Make it the default.
38(%guile-for-build guile-for-build)
39
a2078770
LC
40
41;; Example manifest entries.
42
43(define guile-2.0.9
44 (manifest-entry
45 (name "guile")
46 (version "2.0.9")
a54c94a4 47 (item "/gnu/store/...")
a2078770
LC
48 (output "out")))
49
50(define guile-2.0.9:debug
51 (manifest-entry (inherit guile-2.0.9)
52 (output "debug")))
53
54\f
55(test-begin "profiles")
56
57(test-assert "manifest-installed?"
58 (let ((m (manifest (list guile-2.0.9 guile-2.0.9:debug))))
59 (and (manifest-installed? m (manifest-pattern (name "guile")))
60 (manifest-installed? m (manifest-pattern
61 (name "guile") (output "debug")))
62 (manifest-installed? m (manifest-pattern
63 (name "guile") (output "out")
64 (version "2.0.9")))
65 (not (manifest-installed?
66 m (manifest-pattern (name "guile") (version "1.8.8"))))
67 (not (manifest-installed?
68 m (manifest-pattern (name "guile") (output "foobar")))))))
69
70(test-assert "manifest-matching-entries"
71 (let* ((e (list guile-2.0.9 guile-2.0.9:debug))
72 (m (manifest e)))
73 (and (null? (manifest-matching-entries m
74 (list (manifest-pattern
75 (name "python")))))
76 (equal? e
77 (manifest-matching-entries m
78 (list (manifest-pattern
79 (name "guile")
80 (output #f)))))
81 (equal? (list guile-2.0.9)
82 (manifest-matching-entries m
83 (list (manifest-pattern
84 (name "guile")
85 (version "2.0.9"))))))))
86
87(test-assert "manifest-remove"
88 (let* ((m0 (manifest (list guile-2.0.9 guile-2.0.9:debug)))
89 (m1 (manifest-remove m0
90 (list (manifest-pattern (name "guile")))))
91 (m2 (manifest-remove m1
92 (list (manifest-pattern (name "guile"))))) ; same
93 (m3 (manifest-remove m2
94 (list (manifest-pattern
95 (name "guile") (output "debug")))))
96 (m4 (manifest-remove m3
97 (list (manifest-pattern (name "guile"))))))
98 (match (manifest-entries m2)
99 ((($ <manifest-entry> "guile" "2.0.9" "debug"))
100 (and (equal? m1 m2)
101 (null? (manifest-entries m3))
102 (null? (manifest-entries m4)))))))
103
462f5cca
LC
104(test-assert "profile-derivation"
105 (run-with-store %store
106 (mlet* %store-monad
107 ((entry -> (package->manifest-entry %bootstrap-guile))
108 (guile (package->derivation %bootstrap-guile))
109 (drv (profile-derivation (manifest (list entry))))
110 (profile -> (derivation->output-path drv))
111 (bindir -> (string-append profile "/bin"))
112 (_ (built-derivations (list drv))))
113 (return (and (file-exists? (string-append bindir "/guile"))
114 (string=? (dirname (readlink bindir))
115 (derivation->output-path guile)))))))
116
a2078770
LC
117(test-end "profiles")
118
119\f
120(exit (= (test-runner-fail-count (test-runner-current)) 0))
121
122;;; Local Variables:
123;;; eval: (put 'dummy-package 'scheme-indent-function 1)
124;;; End: