gnu: ffmpeg-2.2: Update to 2.2.13
[jackhill/guix/guix.git] / tests / packages.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
f220a838 2;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
e3ce5d70 3;;;
233e7676 4;;; This file is part of GNU Guix.
e3ce5d70 5;;;
233e7676 6;;; GNU Guix is free software; you can redistribute it and/or modify it
e3ce5d70
LC
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;;;
233e7676 11;;; GNU Guix is distributed in the hope that it will be useful, but
e3ce5d70
LC
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
233e7676 17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
e3ce5d70 18
e3ce5d70 19(define-module (test-packages)
c1bc358f 20 #:use-module (guix tests)
e3ce5d70 21 #:use-module (guix store)
cf81a236 22 #:use-module (guix monads)
2e1bafb0
LC
23 #:use-module ((guix utils)
24 ;; Rename the 'location' binding to allow proper syntax
25 ;; matching when setting the 'location' field of a package.
26 #:renamer (lambda (name)
27 (cond ((eq? name 'location) 'make-location)
28 (else name))))
f9cc8971 29 #:use-module (guix hash)
e3ce5d70
LC
30 #:use-module (guix derivations)
31 #:use-module (guix packages)
a18eda27 32 #:use-module (guix build-system)
be13fbfa 33 #:use-module (guix build-system trivial)
a3d73f59 34 #:use-module (guix build-system gnu)
cf81a236
LC
35 #:use-module (guix profiles)
36 #:use-module (guix scripts package)
59a43334 37 #:use-module (gnu packages)
1ffa7090 38 #:use-module (gnu packages base)
05962f29 39 #:use-module (gnu packages guile)
1ffa7090 40 #:use-module (gnu packages bootstrap)
cf81a236 41 #:use-module (gnu packages xml)
05962f29 42 #:use-module (srfi srfi-1)
6b1891b0 43 #:use-module (srfi srfi-26)
9b222abe 44 #:use-module (srfi srfi-34)
dbab5150 45 #:use-module (srfi srfi-35)
6b1891b0 46 #:use-module (srfi srfi-64)
860a6f1a 47 #:use-module (rnrs io ports)
2e1bafb0 48 #:use-module (ice-9 regex)
6b1891b0 49 #:use-module (ice-9 match))
e3ce5d70
LC
50
51;; Test the high-level packaging layer.
52
53(define %store
c1bc358f 54 (open-connection-for-tests))
e3ce5d70 55
05962f29
LC
56\f
57(test-begin "packages")
58
2e1bafb0
LC
59(test-assert "printer with location"
60 (string-match "^#<package foo-0 foo.scm:42 [[:xdigit:]]+>$"
61 (with-output-to-string
62 (lambda ()
63 (write
64 (dummy-package "foo"
65 (location (make-location "foo.scm" 42 7))))))))
66
67(test-assert "printer without location"
68 (string-match "^#<package foo-0 [[:xdigit:]]+>$"
69 (with-output-to-string
70 (lambda ()
71 (write
72 (dummy-package "foo" (location #f)))))))
73
d66c7096
LC
74(test-assert "package-field-location"
75 (let ()
76 (define (goto port line column)
77 (unless (and (= (port-column port) (- column 1))
78 (= (port-line port) (- line 1)))
79 (unless (eof-object? (get-char port))
80 (goto port line column))))
81
82 (define read-at
83 (match-lambda
84 (($ <location> file line column)
85 (call-with-input-file (search-path %load-path file)
86 (lambda (port)
87 (goto port line column)
88 (read port))))))
89
ee48b283
LC
90 ;; Until Guile 2.0.6 included, source properties were added only to pairs.
91 ;; Thus, check against both VALUE and (FIELD VALUE).
92 (and (member (read-at (package-field-location %bootstrap-guile 'name))
93 (let ((name (package-name %bootstrap-guile)))
94 (list name `(name ,name))))
95 (member (read-at (package-field-location %bootstrap-guile 'version))
96 (let ((version (package-version %bootstrap-guile)))
97 (list version `(version ,version))))
f903dc05 98 (not (package-field-location %bootstrap-guile 'does-not-exist)))))
d66c7096 99
0b8749b7
LC
100;; Make sure we don't change the file name to an absolute file name.
101(test-equal "package-field-location, relative file name"
102 (location-file (package-location %bootstrap-guile))
103 (with-fluids ((%file-port-name-canonicalization 'absolute))
104 (location-file (package-field-location %bootstrap-guile 'version))))
105
a3d73f59
LC
106(test-assert "package-transitive-inputs"
107 (let* ((a (dummy-package "a"))
108 (b (dummy-package "b"
109 (propagated-inputs `(("a" ,a)))))
110 (c (dummy-package "c"
111 (inputs `(("a" ,a)))))
112 (d (dummy-package "d"
113 (propagated-inputs `(("x" "something.drv")))))
114 (e (dummy-package "e"
115 (inputs `(("b" ,b) ("c" ,c) ("d" ,d))))))
116 (and (null? (package-transitive-inputs a))
117 (equal? `(("a" ,a)) (package-transitive-inputs b))
118 (equal? `(("a" ,a)) (package-transitive-inputs c))
119 (equal? (package-propagated-inputs d)
120 (package-transitive-inputs d))
121 (equal? `(("b" ,b) ("b/a" ,a) ("c" ,c)
122 ("d" ,d) ("d/x" "something.drv"))
123 (pk 'x (package-transitive-inputs e))))))
124
7c3c0374 125(test-equal "package-transitive-supported-systems"
c37a74bd
LC
126 '(("x" "y" "z") ;a
127 ("x" "y") ;b
128 ("y") ;c
129 ("y") ;d
130 ("y")) ;e
7c3c0374
LC
131 (let* ((a (dummy-package "a" (supported-systems '("x" "y" "z"))))
132 (b (dummy-package "b" (supported-systems '("x" "y"))
133 (inputs `(("a" ,a)))))
134 (c (dummy-package "c" (supported-systems '("y" "z"))
c37a74bd
LC
135 (inputs `(("b" ,b)))))
136 (d (dummy-package "d" (supported-systems '("x" "y" "z"))
137 (inputs `(("b" ,b) ("c" ,c)))))
138 (e (dummy-package "e" (supported-systems '("x" "y" "z"))
139 (inputs `(("d" ,d))))))
7c3c0374
LC
140 (list (package-transitive-supported-systems a)
141 (package-transitive-supported-systems b)
c37a74bd
LC
142 (package-transitive-supported-systems c)
143 (package-transitive-supported-systems d)
144 (package-transitive-supported-systems e))))
7c3c0374 145
7357138b
LC
146(test-skip (if (not %store) 8 0))
147
148(test-assert "package-source-derivation, file"
149 (let* ((file (search-path %load-path "guix.scm"))
150 (package (package (inherit (dummy-package "p"))
151 (source file)))
152 (source (package-source-derivation %store
153 (package-source package))))
154 (and (store-path? source)
155 (valid-path? %store source)
156 (equal? (call-with-input-file source get-bytevector-all)
157 (call-with-input-file file get-bytevector-all)))))
158
159(test-assert "package-source-derivation, store path"
160 (let* ((file (add-to-store %store "guix.scm" #t "sha256"
161 (search-path %load-path "guix.scm")))
162 (package (package (inherit (dummy-package "p"))
163 (source file)))
164 (source (package-source-derivation %store
165 (package-source package))))
166 (string=? file source)))
e509d152 167
f80594cc
LC
168(test-assert "package-source-derivation, indirect store path"
169 (let* ((dir (add-to-store %store "guix-build" #t "sha256"
170 (dirname (search-path %load-path
171 "guix/build/utils.scm"))))
172 (package (package (inherit (dummy-package "p"))
173 (source (string-append dir "/utils.scm"))))
174 (source (package-source-derivation %store
175 (package-source package))))
176 (and (direct-store-path? source)
177 (string-suffix? "utils.scm" source))))
178
b29f947d
LC
179(unless (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV))
180 (test-skip 1))
f9cc8971
LC
181(test-equal "package-source-derivation, snippet"
182 "OK"
127ed6a9 183 (let* ((file (search-bootstrap-binary "guile-2.0.9.tar.xz"
f9cc8971
LC
184 (%current-system)))
185 (sha256 (call-with-input-file file port-sha256))
f220a838 186 (fetch (lambda* (url hash-algo hash
f9cc8971
LC
187 #:optional name #:key system)
188 (pk 'fetch url hash-algo hash name system)
f220a838 189 (interned-file url)))
f9cc8971
LC
190 (source (bootstrap-origin
191 (origin
192 (method fetch)
193 (uri file)
194 (sha256 sha256)
195 (patch-inputs
196 `(("tar" ,%bootstrap-coreutils&co)
197 ("xz" ,%bootstrap-coreutils&co)
198 ("patch" ,%bootstrap-coreutils&co)))
7db9608d 199 (patch-guile %bootstrap-guile)
f9cc8971
LC
200 (modules '((guix build utils)))
201 (imported-modules modules)
202 (snippet '(begin
203 ;; We end up in 'bin', because it's the first
204 ;; directory, alphabetically. Not a very good
205 ;; example but hey.
206 (chmod "." #o777)
207 (symlink "guile" "guile-rocks")
208 (copy-recursively "../share/guile/2.0/scripts"
209 "scripts")
210
211 ;; These variables must exist.
212 (pk %build-inputs %outputs))))))
213 (package (package (inherit (dummy-package "with-snippet"))
214 (source source)
215 (build-system trivial-build-system)
216 (inputs
217 `(("tar" ,(search-bootstrap-binary "tar"
218 (%current-system)))
219 ("xz" ,(search-bootstrap-binary "xz"
220 (%current-system)))))
221 (arguments
222 `(#:guile ,%bootstrap-guile
223 #:builder
224 (let ((tar (assoc-ref %build-inputs "tar"))
225 (xz (assoc-ref %build-inputs "xz"))
226 (source (assoc-ref %build-inputs "source")))
227 (and (zero? (system* tar "xvf" source
228 "--use-compress-program" xz))
229 (string=? "guile" (readlink "bin/guile-rocks"))
230 (file-exists? "bin/scripts/compile.scm")
231 (let ((out (assoc-ref %outputs "out")))
232 (call-with-output-file out
233 (lambda (p)
234 (display "OK" p))))))))))
235 (drv (package-derivation %store package))
236 (out (derivation->output-path drv)))
237 (and (build-derivations %store (list (pk 'snippet-drv drv)))
238 (call-with-input-file out get-string-all))))
239
59688fc4
LC
240(test-assert "return value"
241 (let ((drv (package-derivation %store (dummy-package "p"))))
242 (and (derivation? drv)
243 (file-exists? (derivation-file-name drv)))))
be13fbfa 244
d510ab46
LC
245(test-assert "package-output"
246 (let* ((package (dummy-package "p"))
59688fc4
LC
247 (drv (package-derivation %store package)))
248 (and (derivation? drv)
249 (string=? (derivation->output-path drv)
d510ab46
LC
250 (package-output %store package "out")))))
251
dbab5150
LC
252(test-assert "patch not found yields a run-time error"
253 (guard (c ((condition-has-type? c &message)
254 (and (string-contains (condition-message c)
255 "does-not-exist.patch")
256 (string-contains (condition-message c)
257 "not found"))))
258 (let ((p (package
259 (inherit (dummy-package "p"))
260 (source (origin
261 (method (const #f))
262 (uri "http://whatever")
263 (patches
264 (list (search-patch "does-not-exist.patch")))
265 (sha256
266 (base32
267 "0amn0bbwqvsvvsh6drfwz20ydc2czk374lzw5kksbh6bf78k4ks4")))))))
268 (package-derivation %store p)
269 #f)))
270
f304c9c2
LC
271(test-assert "reference to non-existent output"
272 ;; See <http://bugs.gnu.org/19630>.
862abf8f
LC
273 (parameterize ((%graft? #f))
274 (let* ((dep (dummy-package "dep"))
275 (p (dummy-package "p"
276 (inputs `(("dep" ,dep "non-existent"))))))
277 (guard (c ((derivation-missing-output-error? c)
278 (and (string=? (derivation-missing-output c) "non-existent")
279 (equal? (package-derivation %store dep)
280 (derivation-error-derivation c)))))
281 (package-derivation %store p)))))
f304c9c2 282
be13fbfa
LC
283(test-assert "trivial"
284 (let* ((p (package (inherit (dummy-package "trivial"))
285 (build-system trivial-build-system)
286 (source #f)
287 (arguments
14da91e2
LC
288 `(#:guile ,%bootstrap-guile
289 #:builder
be13fbfa
LC
290 (begin
291 (mkdir %output)
292 (call-with-output-file (string-append %output "/test")
293 (lambda (p)
294 (display '(hello guix) p))))))))
295 (d (package-derivation %store p)))
296 (and (build-derivations %store (list d))
59688fc4 297 (let ((p (pk 'drv d (derivation->output-path d))))
be13fbfa
LC
298 (equal? '(hello guix)
299 (call-with-input-file (string-append p "/test") read))))))
e3ce5d70 300
860a6f1a
LC
301(test-assert "trivial with local file as input"
302 (let* ((i (search-path %load-path "ice-9/boot-9.scm"))
303 (p (package (inherit (dummy-package "trivial-with-input-file"))
304 (build-system trivial-build-system)
305 (source #f)
306 (arguments
307 `(#:guile ,%bootstrap-guile
308 #:builder (copy-file (assoc-ref %build-inputs "input")
309 %output)))
310 (inputs `(("input" ,i)))))
311 (d (package-derivation %store p)))
312 (and (build-derivations %store (list d))
59688fc4 313 (let ((p (pk 'drv d (derivation->output-path d))))
860a6f1a
LC
314 (equal? (call-with-input-file p get-bytevector-all)
315 (call-with-input-file i get-bytevector-all))))))
316
03761a44
LC
317(test-assert "trivial with source"
318 (let* ((i (search-path %load-path "ice-9/boot-9.scm"))
319 (p (package (inherit (dummy-package "trivial-with-source"))
320 (build-system trivial-build-system)
321 (source i)
322 (arguments
323 `(#:guile ,%bootstrap-guile
324 #:builder (copy-file (assoc-ref %build-inputs "source")
325 %output)))))
326 (d (package-derivation %store p)))
327 (and (build-derivations %store (list d))
328 (let ((p (derivation->output-path d)))
329 (equal? (call-with-input-file p get-bytevector-all)
330 (call-with-input-file i get-bytevector-all))))))
331
592ef6c8
LC
332(test-assert "trivial with system-dependent input"
333 (let* ((p (package (inherit (dummy-package "trivial-system-dependent-input"))
334 (build-system trivial-build-system)
335 (source #f)
336 (arguments
337 `(#:guile ,%bootstrap-guile
338 #:builder
339 (let ((out (assoc-ref %outputs "out"))
340 (bash (assoc-ref %build-inputs "bash")))
341 (zero? (system* bash "-c"
342 (format #f "echo hello > ~a" out))))))
dd6b9a37
LC
343 (inputs `(("bash" ,(search-bootstrap-binary "bash"
344 (%current-system)))))))
592ef6c8
LC
345 (d (package-derivation %store p)))
346 (and (build-derivations %store (list d))
59688fc4 347 (let ((p (pk 'drv d (derivation->output-path d))))
592ef6c8
LC
348 (eq? 'hello (call-with-input-file p read))))))
349
a18eda27
LC
350(test-assert "search paths"
351 (let* ((p (make-prompt-tag "return-search-paths"))
352 (s (build-system
0d5a559f 353 (name 'raw)
a18eda27 354 (description "Raw build system with direct store access")
d3d337d2
LC
355 (lower (lambda* (name #:key source inputs system target
356 #:allow-other-keys)
0d5a559f
LC
357 (bag
358 (name name)
d3d337d2 359 (system system) (target target)
0d5a559f
LC
360 (build-inputs inputs)
361 (build
362 (lambda* (store name inputs
363 #:key outputs system search-paths)
364 search-paths)))))))
a18eda27
LC
365 (x (list (search-path-specification
366 (variable "GUILE_LOAD_PATH")
af070955 367 (files '("share/guile/site/2.0")))
a18eda27
LC
368 (search-path-specification
369 (variable "GUILE_LOAD_COMPILED_PATH")
af070955 370 (files '("share/guile/site/2.0")))))
a18eda27
LC
371 (a (package (inherit (dummy-package "guile"))
372 (build-system s)
373 (native-search-paths x)))
374 (b (package (inherit (dummy-package "guile-foo"))
375 (build-system s)
376 (inputs `(("guile" ,a)))))
377 (c (package (inherit (dummy-package "guile-bar"))
378 (build-system s)
379 (inputs `(("guile" ,a)
380 ("guile-foo" ,b))))))
381 (let-syntax ((collect (syntax-rules ()
382 ((_ body ...)
383 (call-with-prompt p
384 (lambda ()
385 body ...)
386 (lambda (k search-paths)
387 search-paths))))))
388 (and (null? (collect (package-derivation %store a)))
389 (equal? x (collect (package-derivation %store b)))
390 (equal? x (collect (package-derivation %store c)))))))
391
9c1edabd 392(test-assert "package-cross-derivation"
59688fc4
LC
393 (let ((drv (package-cross-derivation %store (dummy-package "p")
394 "mips64el-linux-gnu")))
395 (and (derivation? drv)
396 (file-exists? (derivation-file-name drv)))))
9c1edabd 397
5dce8218
LC
398(test-assert "package-cross-derivation, trivial-build-system"
399 (let ((p (package (inherit (dummy-package "p"))
400 (build-system trivial-build-system)
401 (arguments '(#:builder (exit 1))))))
59688fc4
LC
402 (let ((drv (package-cross-derivation %store p "mips64el-linux-gnu")))
403 (derivation? drv))))
5dce8218 404
9b222abe
LC
405(test-assert "package-cross-derivation, no cross builder"
406 (let* ((b (build-system (inherit trivial-build-system)
0d5a559f 407 (lower (const #f))))
9b222abe
LC
408 (p (package (inherit (dummy-package "p"))
409 (build-system b))))
410 (guard (c ((package-cross-build-system-error? c)
411 (eq? (package-error-package c) p)))
412 (package-cross-derivation %store p "mips64el-linux-gnu")
413 #f)))
414
05962f29
LC
415(test-equal "package-derivation, direct graft"
416 (package-derivation %store gnu-make)
417 (let ((p (package (inherit coreutils)
418 (replacement gnu-make))))
419 (package-derivation %store p)))
420
421(test-equal "package-cross-derivation, direct graft"
422 (package-cross-derivation %store gnu-make "mips64el-linux-gnu")
423 (let ((p (package (inherit coreutils)
424 (replacement gnu-make))))
425 (package-cross-derivation %store p "mips64el-linux-gnu")))
426
427(test-assert "package-grafts, indirect grafts"
428 (let* ((new (dummy-package "dep"
429 (arguments '(#:implicit-inputs? #f))))
430 (dep (package (inherit new) (version "0.0")))
431 (dep* (package (inherit dep) (replacement new)))
432 (dummy (dummy-package "dummy"
433 (arguments '(#:implicit-inputs? #f))
434 (inputs `(("dep" ,dep*))))))
435 (equal? (package-grafts %store dummy)
436 (list (graft
437 (origin (package-derivation %store dep))
438 (replacement (package-derivation %store new)))))))
439
440(test-assert "package-grafts, indirect grafts, cross"
441 (let* ((new (dummy-package "dep"
442 (arguments '(#:implicit-inputs? #f))))
443 (dep (package (inherit new) (version "0.0")))
444 (dep* (package (inherit dep) (replacement new)))
445 (dummy (dummy-package "dummy"
446 (arguments '(#:implicit-inputs? #f))
447 (inputs `(("dep" ,dep*)))))
448 (target "mips64el-linux-gnu"))
449 (equal? (package-grafts %store dummy #:target target)
450 (list (graft
451 (origin (package-cross-derivation %store dep target))
452 (replacement
453 (package-cross-derivation %store new target)))))))
454
455(test-assert "package-grafts, indirect grafts, propagated inputs"
456 (let* ((new (dummy-package "dep"
457 (arguments '(#:implicit-inputs? #f))))
458 (dep (package (inherit new) (version "0.0")))
459 (dep* (package (inherit dep) (replacement new)))
460 (prop (dummy-package "propagated"
461 (propagated-inputs `(("dep" ,dep*)))
462 (arguments '(#:implicit-inputs? #f))))
463 (dummy (dummy-package "dummy"
464 (arguments '(#:implicit-inputs? #f))
465 (inputs `(("prop" ,prop))))))
466 (equal? (package-grafts %store dummy)
467 (list (graft
468 (origin (package-derivation %store dep))
469 (replacement (package-derivation %store new)))))))
470
471(test-assert "package-derivation, indirect grafts"
472 (let* ((new (dummy-package "dep"
473 (arguments '(#:implicit-inputs? #f))))
474 (dep (package (inherit new) (version "0.0")))
475 (dep* (package (inherit dep) (replacement new)))
476 (dummy (dummy-package "dummy"
477 (arguments '(#:implicit-inputs? #f))
478 (inputs `(("dep" ,dep*)))))
479 (guile (package-derivation %store (canonical-package guile-2.0)
480 #:graft? #f)))
481 (equal? (package-derivation %store dummy)
482 (graft-derivation %store "dummy-0"
483 (package-derivation %store dummy #:graft? #f)
484 (package-grafts %store dummy)
485
486 ;; Use the same Guile as 'package-derivation'.
487 #:guile guile))))
488
d3d337d2
LC
489(test-equal "package->bag"
490 `("foo86-hurd" #f (,(package-source gnu-make))
491 (,(canonical-package glibc)) (,(canonical-package coreutils)))
492 (let ((bag (package->bag gnu-make "foo86-hurd")))
493 (list (bag-system bag) (bag-target bag)
494 (assoc-ref (bag-build-inputs bag) "source")
495 (assoc-ref (bag-build-inputs bag) "libc")
496 (assoc-ref (bag-build-inputs bag) "coreutils"))))
497
498(test-equal "package->bag, cross-compilation"
499 `(,(%current-system) "foo86-hurd"
500 (,(package-source gnu-make))
501 (,(canonical-package glibc)) (,(canonical-package coreutils)))
502 (let ((bag (package->bag gnu-make (%current-system) "foo86-hurd")))
503 (list (bag-system bag) (bag-target bag)
504 (assoc-ref (bag-build-inputs bag) "source")
505 (assoc-ref (bag-build-inputs bag) "libc")
506 (assoc-ref (bag-build-inputs bag) "coreutils"))))
507
50373bab
LC
508(test-assert "package->bag, propagated inputs"
509 (let* ((dep (dummy-package "dep"))
510 (prop (dummy-package "prop"
511 (propagated-inputs `(("dep" ,dep)))))
512 (dummy (dummy-package "dummy"
513 (inputs `(("prop" ,prop)))))
514 (inputs (bag-transitive-inputs (package->bag dummy #:graft? #f))))
515 (match (assoc "prop/dep" inputs)
516 (("prop/dep" package)
517 (eq? package dep)))))
518
d3d337d2 519(test-assert "bag->derivation"
05962f29
LC
520 (parameterize ((%graft? #f))
521 (let ((bag (package->bag gnu-make))
522 (drv (package-derivation %store gnu-make)))
523 (parameterize ((%current-system "foox86-hurd")) ;should have no effect
524 (equal? drv (bag->derivation %store bag))))))
d3d337d2
LC
525
526(test-assert "bag->derivation, cross-compilation"
05962f29
LC
527 (parameterize ((%graft? #f))
528 (let* ((target "mips64el-linux-gnu")
529 (bag (package->bag gnu-make (%current-system) target))
530 (drv (package-cross-derivation %store gnu-make target)))
531 (parameterize ((%current-system "foox86-hurd") ;should have no effect
532 (%current-target-system "foo64-linux-gnu"))
533 (equal? drv (bag->derivation %store bag))))))
d3d337d2 534
ad1ebab3
LC
535(unless (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV))
536 (test-skip 1))
9e782349
LC
537(test-assert "GNU Make, bootstrap"
538 ;; GNU Make is the first program built during bootstrap; we choose it
539 ;; here so that the test doesn't last for too long.
bdb36958 540 (let ((gnu-make (@@ (gnu packages commencement) gnu-make-boot0)))
9e782349
LC
541 (and (package? gnu-make)
542 (or (location? (package-location gnu-make))
543 (not (package-location gnu-make)))
544 (let* ((drv (package-derivation %store gnu-make))
59688fc4 545 (out (derivation->output-path drv)))
14da91e2 546 (and (build-derivations %store (list drv))
9e782349 547 (file-exists? (string-append out "/bin/make")))))))
e3ce5d70 548
ba326ce4
LC
549(test-eq "fold-packages" hello
550 (fold-packages (lambda (p r)
551 (if (string=? (package-name p) "hello")
552 p
553 r))
554 #f))
555
6b1891b0
LC
556(test-assert "find-packages-by-name"
557 (match (find-packages-by-name "hello")
558 (((? (cut eq? hello <>))) #t)
559 (wrong (pk 'find-packages-by-name wrong #f))))
560
561(test-assert "find-packages-by-name with version"
562 (match (find-packages-by-name "hello" (package-version hello))
563 (((? (cut eq? hello <>))) #t)
564 (wrong (pk 'find-packages-by-name wrong #f))))
565
cf81a236
LC
566(test-assert "--search-paths with pattern"
567 ;; Make sure 'guix package --search-paths' correctly reports environment
568 ;; variables when file patterns are used (in particular, it must follow
569 ;; symlinks when looking for 'catalog.xml'.) To do that, we rely on the
570 ;; libxml2 package specification, which contains such a definition.
571 (let* ((p1 (package
572 (name "foo") (version "0") (source #f)
573 (build-system trivial-build-system)
574 (arguments
575 `(#:guile ,%bootstrap-guile
576 #:modules ((guix build utils))
577 #:builder (begin
578 (use-modules (guix build utils))
579 (let ((out (assoc-ref %outputs "out")))
580 (mkdir-p (string-append out "/xml/bar/baz"))
581 (call-with-output-file
582 (string-append out "/xml/bar/baz/catalog.xml")
583 (lambda (port)
584 (display "xml? wat?!" port)))))))
585 (synopsis #f) (description #f)
586 (home-page #f) (license #f)))
587 (p2 (package
588 ;; Provide a fake libxml2 to avoid building the real one. This
589 ;; is OK because 'guix package' gets search path specifications
590 ;; from the same-named package found in the distro.
591 (name "libxml2") (version "0.0.0") (source #f)
592 (build-system trivial-build-system)
593 (arguments
594 `(#:guile ,%bootstrap-guile
595 #:builder (mkdir (assoc-ref %outputs "out"))))
596 (native-search-paths (package-native-search-paths libxml2))
597 (synopsis #f) (description #f)
598 (home-page #f) (license #f)))
599 (prof (run-with-store %store
600 (profile-derivation
601 (manifest (map package->manifest-entry
602 (list p1 p2)))
603 #:info-dir? #f)
604 #:guile-for-build (%guile-for-build))))
605 (build-derivations %store (list prof))
606 (string-match (format #f "^export XML_CATALOG_FILES=\"~a/xml/+bar/baz/catalog\\.xml\"\n"
607 (derivation->output-path prof))
608 (with-output-to-string
609 (lambda ()
610 (guix-package "-p" (derivation->output-path prof)
611 "--search-paths"))))))
612
e3ce5d70
LC
613(test-end "packages")
614
615\f
616(exit (= (test-runner-fail-count (test-runner-current)) 0))
617
618;;; Local Variables:
a3d73f59 619;;; eval: (put 'dummy-package 'scheme-indent-function 1)
e3ce5d70 620;;; End: