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