Commit | Line | Data |
---|---|---|
233e7676 | 1 | ;;; GNU Guix --- Functional package management for GNU |
73744725 | 2 | ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org> |
cfcead2e MC |
3 | ;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> |
4 | ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com> | |
e3ce5d70 | 5 | ;;; |
233e7676 | 6 | ;;; This file is part of GNU Guix. |
e3ce5d70 | 7 | ;;; |
233e7676 | 8 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
e3ce5d70 LC |
9 | ;;; under the terms of the GNU General Public License as published by |
10 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
11 | ;;; your option) any later version. | |
12 | ;;; | |
233e7676 | 13 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
e3ce5d70 LC |
14 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | ;;; GNU General Public License for more details. | |
17 | ;;; | |
18 | ;;; You should have received a copy of the GNU General Public License | |
233e7676 | 19 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
e3ce5d70 | 20 | |
cfcead2e | 21 | (define-module (tests packages) |
c1bc358f | 22 | #:use-module (guix tests) |
e3ce5d70 | 23 | #:use-module (guix store) |
cf81a236 | 24 | #:use-module (guix monads) |
fcadd9ff | 25 | #:use-module (guix grafts) |
cfcead2e | 26 | #:use-module (guix gexp) |
a5e2fc73 | 27 | #:use-module (guix utils) |
cfcead2e | 28 | #:use-module ((guix build utils) #:select (tarball?)) |
a5e2fc73 | 29 | #:use-module ((guix diagnostics) |
2e1bafb0 LC |
30 | ;; Rename the 'location' binding to allow proper syntax |
31 | ;; matching when setting the 'location' field of a package. | |
32 | #:renamer (lambda (name) | |
33 | (cond ((eq? name 'location) 'make-location) | |
34 | (else name)))) | |
197c07a8 | 35 | #:use-module ((gcrypt hash) #:prefix gcrypt:) |
e3ce5d70 | 36 | #:use-module (guix derivations) |
cfcead2e | 37 | #:use-module (guix download) |
e3ce5d70 | 38 | #:use-module (guix packages) |
7adf9b84 | 39 | #:use-module (guix grafts) |
aa8e0515 | 40 | #:use-module (guix search-paths) |
a18eda27 | 41 | #:use-module (guix build-system) |
be13fbfa | 42 | #:use-module (guix build-system trivial) |
a3d73f59 | 43 | #:use-module (guix build-system gnu) |
2bf6f962 | 44 | #:use-module (guix build-system python) |
0db65c16 | 45 | #:use-module (guix memoization) |
cf81a236 LC |
46 | #:use-module (guix profiles) |
47 | #:use-module (guix scripts package) | |
73744725 | 48 | #:use-module (guix sets) |
59a43334 | 49 | #:use-module (gnu packages) |
1ffa7090 | 50 | #:use-module (gnu packages base) |
05962f29 | 51 | #:use-module (gnu packages guile) |
1ffa7090 | 52 | #:use-module (gnu packages bootstrap) |
2bf6f962 | 53 | #:use-module (gnu packages python) |
fcd75bdb | 54 | #:use-module (gnu packages version-control) |
cf81a236 | 55 | #:use-module (gnu packages xml) |
05962f29 | 56 | #:use-module (srfi srfi-1) |
cfcead2e | 57 | #:use-module (srfi srfi-11) |
6b1891b0 | 58 | #:use-module (srfi srfi-26) |
9b222abe | 59 | #:use-module (srfi srfi-34) |
dbab5150 | 60 | #:use-module (srfi srfi-35) |
6b1891b0 | 61 | #:use-module (srfi srfi-64) |
73744725 | 62 | #:use-module (srfi srfi-71) |
ce0be567 | 63 | #:use-module (rnrs bytevectors) |
860a6f1a | 64 | #:use-module (rnrs io ports) |
5239f3d9 | 65 | #:use-module (ice-9 vlist) |
2e1bafb0 | 66 | #:use-module (ice-9 regex) |
6b1891b0 | 67 | #:use-module (ice-9 match)) |
e3ce5d70 LC |
68 | |
69 | ;; Test the high-level packaging layer. | |
70 | ||
71 | (define %store | |
c1bc358f | 72 | (open-connection-for-tests)) |
e3ce5d70 | 73 | |
b4c42a4b LC |
74 | ;; Globally disable grafting to avoid rebuilding the world ('graft-derivation' |
75 | ;; can trigger builds early.) | |
76 | (%graft? #f) | |
77 | ||
05962f29 LC |
78 | \f |
79 | (test-begin "packages") | |
80 | ||
2e1bafb0 | 81 | (test-assert "printer with location" |
74e667d1 | 82 | (string-match "^#<package foo@0 foo.scm:42 [[:xdigit:]]+>$" |
2e1bafb0 LC |
83 | (with-output-to-string |
84 | (lambda () | |
85 | (write | |
86 | (dummy-package "foo" | |
87 | (location (make-location "foo.scm" 42 7)))))))) | |
88 | ||
89 | (test-assert "printer without location" | |
74e667d1 | 90 | (string-match "^#<package foo@0 [[:xdigit:]]+>$" |
2e1bafb0 LC |
91 | (with-output-to-string |
92 | (lambda () | |
93 | (write | |
94 | (dummy-package "foo" (location #f))))))) | |
95 | ||
6980511b LC |
96 | (test-assert "hidden-package" |
97 | (and (hidden-package? (hidden-package (dummy-package "foo"))) | |
98 | (not (hidden-package? (dummy-package "foo"))))) | |
99 | ||
01afdab8 LC |
100 | (test-assert "package-superseded" |
101 | (let* ((new (dummy-package "bar")) | |
102 | (old (deprecated-package "foo" new))) | |
103 | (and (eq? (package-superseded old) new) | |
104 | (mock ((gnu packages) find-best-packages-by-name (const (list old))) | |
105 | (specification->package "foo") | |
106 | (and (eq? new (specification->package "foo")) | |
107 | (eq? new (specification->package+output "foo"))))))) | |
108 | ||
5239f3d9 LC |
109 | (test-assert "transaction-upgrade-entry, zero upgrades" |
110 | (let* ((old (dummy-package "foo" (version "1"))) | |
465a0d65 LC |
111 | (tx (mock ((gnu packages) find-best-packages-by-name |
112 | (const '())) | |
84c5da08 LC |
113 | (transaction-upgrade-entry |
114 | #f ;no store access needed | |
5239f3d9 LC |
115 | (manifest-entry |
116 | (inherit (package->manifest-entry old)) | |
117 | (item (string-append (%store-prefix) "/" | |
118 | (make-string 32 #\e) "-foo-1"))) | |
119 | (manifest-transaction))))) | |
120 | (manifest-transaction-null? tx))) | |
121 | ||
b9c79cae LC |
122 | (test-assert "transaction-upgrade-entry, zero upgrades, equivalent package" |
123 | (let* ((old (dummy-package "foo" (version "1"))) | |
124 | (drv (package-derivation %store old)) | |
125 | (tx (mock ((gnu packages) find-best-packages-by-name | |
126 | (const (list old))) | |
127 | (transaction-upgrade-entry | |
128 | %store | |
129 | (manifest-entry | |
130 | (inherit (package->manifest-entry old)) | |
131 | (item (derivation->output-path drv))) | |
132 | (manifest-transaction))))) | |
133 | (manifest-transaction-null? tx))) | |
134 | ||
a357849f LC |
135 | (test-assert "transaction-upgrade-entry, zero upgrades, propagated inputs" |
136 | ;; Properly detect equivalent packages even when they have propagated | |
137 | ;; inputs. See <https://bugs.gnu.org/35872>. | |
138 | (let* ((dep (dummy-package "dep" (version "2"))) | |
139 | (old (dummy-package "foo" (version "1") | |
140 | (propagated-inputs `(("dep" ,dep))))) | |
141 | (drv (package-derivation %store old)) | |
142 | (tx (mock ((gnu packages) find-best-packages-by-name | |
143 | (const (list old))) | |
144 | (transaction-upgrade-entry | |
145 | %store | |
146 | (manifest-entry | |
147 | (inherit (package->manifest-entry old)) | |
148 | (item (derivation->output-path drv)) | |
149 | (dependencies | |
150 | (list (manifest-entry | |
151 | (inherit (package->manifest-entry dep)) | |
152 | (item (derivation->output-path | |
153 | (package-derivation %store dep))))))) | |
154 | (manifest-transaction))))) | |
155 | (manifest-transaction-null? tx))) | |
156 | ||
5239f3d9 LC |
157 | (test-assert "transaction-upgrade-entry, one upgrade" |
158 | (let* ((old (dummy-package "foo" (version "1"))) | |
159 | (new (dummy-package "foo" (version "2"))) | |
465a0d65 LC |
160 | (tx (mock ((gnu packages) find-best-packages-by-name |
161 | (const (list new))) | |
84c5da08 LC |
162 | (transaction-upgrade-entry |
163 | #f ;no store access needed | |
5239f3d9 LC |
164 | (manifest-entry |
165 | (inherit (package->manifest-entry old)) | |
166 | (item (string-append (%store-prefix) "/" | |
167 | (make-string 32 #\e) "-foo-1"))) | |
168 | (manifest-transaction))))) | |
169 | (and (match (manifest-transaction-install tx) | |
170 | ((($ <manifest-entry> "foo" "2" "out" item)) | |
171 | (eq? item new))) | |
172 | (null? (manifest-transaction-remove tx))))) | |
173 | ||
01afdab8 LC |
174 | (test-assert "transaction-upgrade-entry, superseded package" |
175 | (let* ((old (dummy-package "foo" (version "1"))) | |
176 | (new (dummy-package "bar" (version "2"))) | |
177 | (dep (deprecated-package "foo" new)) | |
465a0d65 LC |
178 | (tx (mock ((gnu packages) find-best-packages-by-name |
179 | (const (list dep))) | |
84c5da08 LC |
180 | (transaction-upgrade-entry |
181 | #f ;no store access needed | |
01afdab8 LC |
182 | (manifest-entry |
183 | (inherit (package->manifest-entry old)) | |
184 | (item (string-append (%store-prefix) "/" | |
185 | (make-string 32 #\e) "-foo-1"))) | |
186 | (manifest-transaction))))) | |
187 | (and (match (manifest-transaction-install tx) | |
188 | ((($ <manifest-entry> "bar" "2" "out" item)) | |
189 | (eq? item new))) | |
190 | (match (manifest-transaction-remove tx) | |
191 | (((? manifest-pattern? pattern)) | |
192 | (and (string=? (manifest-pattern-name pattern) "foo") | |
193 | (string=? (manifest-pattern-version pattern) "1") | |
194 | (string=? (manifest-pattern-output pattern) "out"))))))) | |
195 | ||
8e1907a7 LC |
196 | (test-equal "transaction-upgrade-entry, transformation options preserved" |
197 | (derivation-file-name (package-derivation %store grep)) | |
198 | ||
199 | (let* ((old (dummy-package "emacs" (version "1"))) | |
200 | (props '((transformations . ((with-input . "emacs=grep"))))) | |
201 | (tx (transaction-upgrade-entry | |
202 | %store | |
203 | (manifest-entry | |
204 | (inherit (package->manifest-entry old)) | |
205 | (properties props) | |
206 | (item (string-append (%store-prefix) "/" | |
207 | (make-string 32 #\e) "-foo-1"))) | |
208 | (manifest-transaction)))) | |
209 | (match (manifest-transaction-install tx) | |
210 | (((? manifest-entry? entry)) | |
211 | (and (string=? (manifest-entry-version entry) | |
212 | (package-version grep)) | |
213 | (string=? (manifest-entry-name entry) | |
214 | (package-name grep)) | |
215 | (equal? (manifest-entry-properties entry) props) | |
216 | (derivation-file-name | |
217 | (package-derivation %store (manifest-entry-item entry)))))))) | |
218 | ||
a187cc56 LC |
219 | (test-assert "transaction-upgrade-entry, grafts" |
220 | ;; Ensure that, when grafts are enabled, 'transaction-upgrade-entry' doesn't | |
221 | ;; try to build stuff. | |
222 | (with-build-handler (const 'failed!) | |
223 | (parameterize ((%graft? #t)) | |
224 | (let* ((old (dummy-package "foo" (version "1"))) | |
225 | (bar (dummy-package "bar" (version "0") | |
226 | (replacement old))) | |
227 | (new (dummy-package "foo" (version "1") | |
228 | (inputs `(("bar" ,bar))))) | |
229 | (tx (mock ((gnu packages) find-best-packages-by-name | |
230 | (const (list new))) | |
231 | (transaction-upgrade-entry | |
232 | %store | |
233 | (manifest-entry | |
234 | (inherit (package->manifest-entry old)) | |
235 | (item (string-append (%store-prefix) "/" | |
236 | (make-string 32 #\e) "-foo-1"))) | |
237 | (manifest-transaction))))) | |
238 | (and (match (manifest-transaction-install tx) | |
239 | ((($ <manifest-entry> "foo" "1" "out" item)) | |
240 | (eq? item new))) | |
241 | (null? (manifest-transaction-remove tx))))))) | |
242 | ||
d66c7096 LC |
243 | (test-assert "package-field-location" |
244 | (let () | |
245 | (define (goto port line column) | |
246 | (unless (and (= (port-column port) (- column 1)) | |
247 | (= (port-line port) (- line 1))) | |
248 | (unless (eof-object? (get-char port)) | |
249 | (goto port line column)))) | |
250 | ||
251 | (define read-at | |
252 | (match-lambda | |
253 | (($ <location> file line column) | |
254 | (call-with-input-file (search-path %load-path file) | |
255 | (lambda (port) | |
256 | (goto port line column) | |
257 | (read port)))))) | |
258 | ||
ee48b283 LC |
259 | ;; Until Guile 2.0.6 included, source properties were added only to pairs. |
260 | ;; Thus, check against both VALUE and (FIELD VALUE). | |
261 | (and (member (read-at (package-field-location %bootstrap-guile 'name)) | |
262 | (let ((name (package-name %bootstrap-guile))) | |
263 | (list name `(name ,name)))) | |
264 | (member (read-at (package-field-location %bootstrap-guile 'version)) | |
265 | (let ((version (package-version %bootstrap-guile))) | |
266 | (list version `(version ,version)))) | |
f903dc05 | 267 | (not (package-field-location %bootstrap-guile 'does-not-exist))))) |
d66c7096 | 268 | |
0b8749b7 LC |
269 | ;; Make sure we don't change the file name to an absolute file name. |
270 | (test-equal "package-field-location, relative file name" | |
271 | (location-file (package-location %bootstrap-guile)) | |
272 | (with-fluids ((%file-port-name-canonicalization 'absolute)) | |
273 | (location-file (package-field-location %bootstrap-guile 'version)))) | |
274 | ||
a3d73f59 LC |
275 | (test-assert "package-transitive-inputs" |
276 | (let* ((a (dummy-package "a")) | |
277 | (b (dummy-package "b" | |
278 | (propagated-inputs `(("a" ,a))))) | |
279 | (c (dummy-package "c" | |
280 | (inputs `(("a" ,a))))) | |
281 | (d (dummy-package "d" | |
282 | (propagated-inputs `(("x" "something.drv"))))) | |
283 | (e (dummy-package "e" | |
284 | (inputs `(("b" ,b) ("c" ,c) ("d" ,d)))))) | |
285 | (and (null? (package-transitive-inputs a)) | |
286 | (equal? `(("a" ,a)) (package-transitive-inputs b)) | |
287 | (equal? `(("a" ,a)) (package-transitive-inputs c)) | |
288 | (equal? (package-propagated-inputs d) | |
289 | (package-transitive-inputs d)) | |
161094c8 LC |
290 | (equal? `(("b" ,b) ("c" ,c) ("d" ,d) |
291 | ("a" ,a) ("x" "something.drv")) | |
a3d73f59 LC |
292 | (pk 'x (package-transitive-inputs e)))))) |
293 | ||
161094c8 LC |
294 | (test-assert "package-transitive-inputs, no duplicates" |
295 | (let* ((a (dummy-package "a")) | |
296 | (b (dummy-package "b" | |
297 | (inputs `(("a+" ,a))) | |
298 | (native-inputs `(("a*" ,a))) | |
299 | (propagated-inputs `(("a" ,a))))) | |
300 | (c (dummy-package "c" | |
301 | (propagated-inputs `(("b" ,b))))) | |
302 | (d (dummy-package "d" | |
303 | (inputs `(("a" ,a) ("c" ,c))))) | |
304 | (e (dummy-package "e" | |
305 | (inputs `(("b" ,b) ("c" ,c)))))) | |
306 | (and (null? (package-transitive-inputs a)) | |
307 | (equal? `(("a*" ,a) ("a+" ,a) ("a" ,a)) ;here duplicates are kept | |
308 | (package-transitive-inputs b)) | |
309 | (equal? `(("b" ,b) ("a" ,a)) | |
310 | (package-transitive-inputs c)) | |
311 | (equal? `(("a" ,a) ("c" ,c) ("b" ,b)) ;duplicate A removed | |
312 | (package-transitive-inputs d)) | |
313 | (equal? `(("b" ,b) ("c" ,c) ("a" ,a)) | |
314 | (package-transitive-inputs e))))) ;ditto | |
315 | ||
7c3c0374 | 316 | (test-equal "package-transitive-supported-systems" |
c37a74bd LC |
317 | '(("x" "y" "z") ;a |
318 | ("x" "y") ;b | |
319 | ("y") ;c | |
320 | ("y") ;d | |
321 | ("y")) ;e | |
9bf3ced0 LC |
322 | ;; Use TRIVIAL-BUILD-SYSTEM because it doesn't add implicit inputs and thus |
323 | ;; doesn't restrict the set of supported systems. | |
324 | (let* ((a (dummy-package "a" | |
325 | (build-system trivial-build-system) | |
326 | (supported-systems '("x" "y" "z")))) | |
327 | (b (dummy-package "b" | |
328 | (build-system trivial-build-system) | |
329 | (supported-systems '("x" "y")) | |
330 | (inputs `(("a" ,a))))) | |
331 | (c (dummy-package "c" | |
332 | (build-system trivial-build-system) | |
333 | (supported-systems '("y" "z")) | |
334 | (inputs `(("b" ,b))))) | |
335 | (d (dummy-package "d" | |
336 | (build-system trivial-build-system) | |
337 | (supported-systems '("x" "y" "z")) | |
338 | (inputs `(("b" ,b) ("c" ,c))))) | |
339 | (e (dummy-package "e" | |
340 | (build-system trivial-build-system) | |
341 | (supported-systems '("x" "y" "z")) | |
342 | (inputs `(("d" ,d)))))) | |
7c3c0374 LC |
343 | (list (package-transitive-supported-systems a) |
344 | (package-transitive-supported-systems b) | |
c37a74bd LC |
345 | (package-transitive-supported-systems c) |
346 | (package-transitive-supported-systems d) | |
347 | (package-transitive-supported-systems e)))) | |
7c3c0374 | 348 | |
3e223a22 LC |
349 | (test-assert "package-closure" |
350 | (let-syntax ((dummy-package/no-implicit | |
351 | (syntax-rules () | |
352 | ((_ name rest ...) | |
353 | (package | |
354 | (inherit (dummy-package name rest ...)) | |
355 | (build-system trivial-build-system)))))) | |
356 | (let* ((a (dummy-package/no-implicit "a")) | |
357 | (b (dummy-package/no-implicit "b" | |
358 | (propagated-inputs `(("a" ,a))))) | |
359 | (c (dummy-package/no-implicit "c" | |
360 | (inputs `(("a" ,a))))) | |
361 | (d (dummy-package/no-implicit "d" | |
362 | (native-inputs `(("b" ,b))))) | |
363 | (e (dummy-package/no-implicit "e" | |
364 | (inputs `(("c" ,c) ("d" ,d)))))) | |
365 | (lset= eq? | |
366 | (list a b c d e) | |
367 | (package-closure (list e)) | |
368 | (package-closure (list e d)) | |
369 | (package-closure (list e c b)))))) | |
370 | ||
3b4d0103 EB |
371 | (test-equal "origin-actual-file-name" |
372 | "foo-1.tar.gz" | |
373 | (let ((o (dummy-origin (uri "http://www.example.com/foo-1.tar.gz")))) | |
374 | (origin-actual-file-name o))) | |
375 | ||
376 | (test-equal "origin-actual-file-name, file-name" | |
377 | "foo-1.tar.gz" | |
378 | (let ((o (dummy-origin | |
379 | (uri "http://www.example.com/tarball") | |
380 | (file-name "foo-1.tar.gz")))) | |
381 | (origin-actual-file-name o))) | |
382 | ||
f77bcbc3 EB |
383 | (let* ((o (dummy-origin)) |
384 | (u (dummy-origin)) | |
385 | (i (dummy-origin)) | |
386 | (a (dummy-package "a")) | |
387 | (b (dummy-package "b" | |
388 | (inputs `(("a" ,a) ("i" ,i))))) | |
389 | (c (package (inherit b) (source o))) | |
390 | (d (dummy-package "d" | |
391 | (build-system trivial-build-system) | |
392 | (source u) (inputs `(("c" ,c)))))) | |
393 | (test-assert "package-direct-sources, no source" | |
394 | (null? (package-direct-sources a))) | |
395 | (test-equal "package-direct-sources, #f source" | |
396 | (list i) | |
397 | (package-direct-sources b)) | |
398 | (test-equal "package-direct-sources, not input source" | |
399 | (list u) | |
400 | (package-direct-sources d)) | |
401 | (test-assert "package-direct-sources" | |
402 | (let ((s (package-direct-sources c))) | |
403 | (and (= (length (pk 's-sources s)) 2) | |
404 | (member o s) | |
405 | (member i s)))) | |
406 | (test-assert "package-transitive-sources" | |
407 | (let ((s (package-transitive-sources d))) | |
408 | (and (= (length (pk 'd-sources s)) 3) | |
409 | (member o s) | |
410 | (member i s) | |
411 | (member u s))))) | |
412 | ||
a6d0b306 EB |
413 | (test-assert "transitive-input-references" |
414 | (let* ((a (dummy-package "a")) | |
415 | (b (dummy-package "b")) | |
416 | (c (dummy-package "c" | |
417 | (inputs `(("a" ,a))) | |
418 | (propagated-inputs `(("boo" ,b))))) | |
419 | (d (dummy-package "d" | |
420 | (inputs `(("c*" ,c))))) | |
421 | (keys (map (match-lambda | |
422 | (('assoc-ref 'l key) | |
423 | key)) | |
424 | (pk 'refs (transitive-input-references | |
425 | 'l (package-inputs d)))))) | |
426 | (and (= (length keys) 2) | |
427 | (member "c*" keys) | |
428 | (member "boo" keys)))) | |
429 | ||
9bf3ced0 LC |
430 | (test-equal "package-transitive-supported-systems, implicit inputs" |
431 | %supported-systems | |
432 | ||
0db65c16 JN |
433 | ;; Here GNU-BUILD-SYSTEM adds implicit inputs that build only on |
434 | ;; %SUPPORTED-SYSTEMS. Thus the others must be ignored. | |
435 | (let ((p (dummy-package "foo" | |
436 | (build-system gnu-build-system) | |
437 | (supported-systems | |
438 | `("does-not-exist" "foobar" ,@%supported-systems))))) | |
0db65c16 JN |
439 | (parameterize ((%current-system "armhf-linux")) ; a traditionally-bootstrapped architecture |
440 | (package-transitive-supported-systems p)))) | |
441 | ||
442 | (test-equal "package-transitive-supported-systems: reduced binary seed, implicit inputs" | |
443 | '("x86_64-linux" "i686-linux") | |
444 | ||
9bf3ced0 LC |
445 | ;; Here GNU-BUILD-SYSTEM adds implicit inputs that build only on |
446 | ;; %SUPPORTED-SYSTEMS. Thus the others must be ignored. | |
447 | (let ((p (dummy-package "foo" | |
448 | (build-system gnu-build-system) | |
449 | (supported-systems | |
450 | `("does-not-exist" "foobar" ,@%supported-systems))))) | |
0db65c16 JN |
451 | (parameterize ((%current-system "x86_64-linux")) |
452 | (package-transitive-supported-systems p)))) | |
9bf3ced0 | 453 | |
bbceb0ef | 454 | (test-assert "supported-package?" |
bc60349b LC |
455 | (let* ((d (dummy-package "dep" |
456 | (build-system trivial-build-system) | |
457 | (supported-systems '("x86_64-linux")))) | |
458 | (p (dummy-package "foo" | |
459 | (build-system gnu-build-system) | |
460 | (inputs `(("d" ,d))) | |
461 | (supported-systems '("x86_64-linux" "armhf-linux"))))) | |
462 | (and (supported-package? p "x86_64-linux") | |
463 | (not (supported-package? p "i686-linux")) | |
464 | (not (supported-package? p "armhf-linux"))))) | |
465 | ||
466 | (test-assert "supported-package? vs. system-dependent graph" | |
467 | ;; The inputs of a package can depend on (%current-system). Thus, | |
468 | ;; 'supported-package?' must make sure that it binds (%current-system) | |
469 | ;; appropriately before traversing the dependency graph. In the example | |
470 | ;; below, 'supported-package?' must thus return true for both systems. | |
471 | (let* ((p0a (dummy-package "foo-arm" | |
472 | (build-system trivial-build-system) | |
473 | (supported-systems '("armhf-linux")))) | |
474 | (p0b (dummy-package "foo-x86_64" | |
475 | (build-system trivial-build-system) | |
476 | (supported-systems '("x86_64-linux")))) | |
477 | (p (dummy-package "bar" | |
478 | (build-system trivial-build-system) | |
479 | (inputs | |
480 | (if (string=? (%current-system) "armhf-linux") | |
481 | `(("foo" ,p0a)) | |
482 | `(("foo" ,p0b))))))) | |
bbceb0ef | 483 | (and (supported-package? p "x86_64-linux") |
bc60349b | 484 | (supported-package? p "armhf-linux")))) |
bbceb0ef | 485 | |
7357138b LC |
486 | (test-skip (if (not %store) 8 0)) |
487 | ||
488 | (test-assert "package-source-derivation, file" | |
489 | (let* ((file (search-path %load-path "guix.scm")) | |
490 | (package (package (inherit (dummy-package "p")) | |
491 | (source file))) | |
492 | (source (package-source-derivation %store | |
493 | (package-source package)))) | |
494 | (and (store-path? source) | |
495 | (valid-path? %store source) | |
496 | (equal? (call-with-input-file source get-bytevector-all) | |
497 | (call-with-input-file file get-bytevector-all))))) | |
498 | ||
499 | (test-assert "package-source-derivation, store path" | |
500 | (let* ((file (add-to-store %store "guix.scm" #t "sha256" | |
501 | (search-path %load-path "guix.scm"))) | |
502 | (package (package (inherit (dummy-package "p")) | |
503 | (source file))) | |
504 | (source (package-source-derivation %store | |
505 | (package-source package)))) | |
506 | (string=? file source))) | |
e509d152 | 507 | |
f80594cc LC |
508 | (test-assert "package-source-derivation, indirect store path" |
509 | (let* ((dir (add-to-store %store "guix-build" #t "sha256" | |
510 | (dirname (search-path %load-path | |
511 | "guix/build/utils.scm")))) | |
512 | (package (package (inherit (dummy-package "p")) | |
513 | (source (string-append dir "/utils.scm")))) | |
514 | (source (package-source-derivation %store | |
515 | (package-source package)))) | |
516 | (and (direct-store-path? source) | |
517 | (string-suffix? "utils.scm" source)))) | |
518 | ||
da675305 LC |
519 | (test-assert "package-source-derivation, local-file" |
520 | (let* ((file (local-file "../guix/base32.scm")) | |
521 | (package (package (inherit (dummy-package "p")) | |
522 | (source file))) | |
523 | (source (package-source-derivation %store | |
524 | (package-source package)))) | |
525 | (and (store-path? source) | |
526 | (string-suffix? "base32.scm" source) | |
527 | (valid-path? %store source) | |
528 | (equal? (call-with-input-file source get-bytevector-all) | |
529 | (call-with-input-file | |
530 | (search-path %load-path "guix/base32.scm") | |
531 | get-bytevector-all))))) | |
532 | ||
ce0be567 LC |
533 | (test-equal "package-source-derivation, origin, sha512" |
534 | "hello" | |
535 | (let* ((bash (search-bootstrap-binary "bash" (%current-system))) | |
536 | (builder (add-text-to-store %store "my-fixed-builder.sh" | |
537 | "echo -n hello > $out" '())) | |
538 | (method (lambda* (url hash-algo hash #:optional name | |
539 | #:rest rest) | |
540 | (and (eq? hash-algo 'sha512) | |
541 | (raw-derivation name bash (list builder) | |
542 | #:sources (list builder) | |
543 | #:hash hash | |
544 | #:hash-algo hash-algo)))) | |
545 | (source (origin | |
546 | (method method) | |
547 | (uri "unused://") | |
548 | (file-name "origin-sha512") | |
549 | (hash (content-hash | |
197c07a8 LC |
550 | (gcrypt:bytevector-hash (string->utf8 "hello") |
551 | (gcrypt:lookup-hash-algorithm | |
552 | 'sha512)) | |
ce0be567 LC |
553 | sha512)))) |
554 | (drv (package-source-derivation %store source)) | |
555 | (output (derivation->output-path drv))) | |
556 | (build-derivations %store (list drv)) | |
557 | (call-with-input-file output get-string-all))) | |
558 | ||
0505eda9 LC |
559 | (test-equal "package-source-derivation, origin, sha3-512" |
560 | "hello, sha3" | |
561 | (let* ((bash (search-bootstrap-binary "bash" (%current-system))) | |
562 | (builder (add-text-to-store %store "my-fixed-builder.sh" | |
563 | "echo -n hello, sha3 > $out" '())) | |
564 | (method (lambda* (url hash-algo hash #:optional name | |
565 | #:rest rest) | |
566 | (and (eq? hash-algo 'sha3-512) | |
567 | (raw-derivation name bash (list builder) | |
568 | #:sources (list builder) | |
569 | #:hash hash | |
570 | #:hash-algo hash-algo)))) | |
571 | (source (origin | |
572 | (method method) | |
573 | (uri "unused://") | |
574 | (file-name "origin-sha3") | |
575 | (hash (content-hash | |
576 | (gcrypt:bytevector-hash (string->utf8 "hello, sha3") | |
577 | (gcrypt:lookup-hash-algorithm | |
578 | 'sha3-512)) | |
579 | sha3-512)))) | |
580 | (drv (package-source-derivation %store source)) | |
581 | (output (derivation->output-path drv))) | |
582 | (build-derivations %store (list drv)) | |
583 | (call-with-input-file output get-string-all))) | |
584 | ||
cfcead2e MC |
585 | \f |
586 | ;;; | |
587 | ;;; Source derivation with snippets. | |
588 | ;;; | |
589 | ||
12d720fd | 590 | (unless (network-reachable?) (test-skip 1)) |
f9cc8971 LC |
591 | (test-equal "package-source-derivation, snippet" |
592 | "OK" | |
f8ec8d96 | 593 | (let* ((source (bootstrap-origin |
f9cc8971 | 594 | (origin |
f8ec8d96 | 595 | (inherit (bootstrap-guile-origin (%current-system))) |
f9cc8971 LC |
596 | (patch-inputs |
597 | `(("tar" ,%bootstrap-coreutils&co) | |
598 | ("xz" ,%bootstrap-coreutils&co) | |
599 | ("patch" ,%bootstrap-coreutils&co))) | |
7db9608d | 600 | (patch-guile %bootstrap-guile) |
f9cc8971 | 601 | (modules '((guix build utils))) |
f9cc8971 LC |
602 | (snippet '(begin |
603 | ;; We end up in 'bin', because it's the first | |
604 | ;; directory, alphabetically. Not a very good | |
605 | ;; example but hey. | |
606 | (chmod "." #o777) | |
607 | (symlink "guile" "guile-rocks") | |
608 | (copy-recursively "../share/guile/2.0/scripts" | |
d6445dff LC |
609 | "scripts") |
610 | ||
611 | ;; Make sure '.file_list' can be created. | |
612 | (chmod ".." #o777)))))) | |
f9cc8971 LC |
613 | (package (package (inherit (dummy-package "with-snippet")) |
614 | (source source) | |
615 | (build-system trivial-build-system) | |
616 | (inputs | |
617 | `(("tar" ,(search-bootstrap-binary "tar" | |
618 | (%current-system))) | |
619 | ("xz" ,(search-bootstrap-binary "xz" | |
620 | (%current-system))))) | |
621 | (arguments | |
622 | `(#:guile ,%bootstrap-guile | |
1e868858 | 623 | #:modules ((guix build utils)) |
f9cc8971 | 624 | #:builder |
1e868858 MW |
625 | (begin |
626 | (use-modules (guix build utils)) | |
627 | (let ((tar (assoc-ref %build-inputs "tar")) | |
628 | (xz (assoc-ref %build-inputs "xz")) | |
629 | (source (assoc-ref %build-inputs "source"))) | |
630 | (invoke tar "xvf" source | |
631 | "--use-compress-program" xz) | |
632 | (unless (and (string=? "guile" (readlink "bin/guile-rocks")) | |
633 | (file-exists? "bin/scripts/compile.scm")) | |
634 | (error "the snippet apparently failed")) | |
635 | (let ((out (assoc-ref %outputs "out"))) | |
636 | (call-with-output-file out | |
637 | (lambda (p) | |
638 | (display "OK" p)))) | |
639 | #t)))))) | |
f9cc8971 LC |
640 | (drv (package-derivation %store package)) |
641 | (out (derivation->output-path drv))) | |
642 | (and (build-derivations %store (list (pk 'snippet-drv drv))) | |
643 | (call-with-input-file out get-string-all)))) | |
644 | ||
cfcead2e MC |
645 | ;; Note: lzip is not part of bootstrap-coreutils&co, so is not included to |
646 | ;; avoid having to rebuild the world. | |
647 | (define compressors '(("gzip" . "gz") | |
648 | ("xz" . "xz") | |
649 | ("bzip2" . "bz2") | |
650 | (#f . #f))) | |
651 | ||
652 | (for-each | |
653 | (match-lambda | |
654 | ((comp . ext) | |
655 | (unless (network-reachable?) (test-skip 1)) | |
656 | (test-equal (string-append "origin->derivation, single file with snippet " | |
657 | "(compression: " (if comp comp "None") ")") | |
658 | "2 + 2 = 4" | |
659 | (let*-values | |
660 | (((name) "maths") | |
661 | ((compressed-name) (if comp | |
662 | (string-append name "." ext) | |
663 | name)) | |
664 | ((file hash) (test-file %store compressed-name "2 + 2 = 5")) | |
665 | ;; Create an origin using the above computed file and its hash. | |
666 | ((source) (origin | |
667 | (method url-fetch) | |
668 | (uri (string-append "file://" file)) | |
669 | (file-name compressed-name) | |
670 | (patch-inputs `(("tar" ,%bootstrap-coreutils&co) | |
671 | ("xz" ,%bootstrap-coreutils&co) | |
672 | ("bzip2" ,%bootstrap-coreutils&co) | |
673 | ("gzip" ,%bootstrap-coreutils&co))) | |
674 | (patch-guile %bootstrap-guile) | |
675 | (modules '((guix build utils))) | |
676 | (snippet `(substitute* ,name | |
677 | (("5") "4"))) | |
678 | (hash (content-hash hash)))) | |
679 | ;; Build origin. | |
680 | ((drv) (run-with-store %store (origin->derivation source))) | |
681 | ((out) (derivation->output-path drv))) | |
682 | ;; Decompress the resulting tar.xz and return its content. | |
683 | (and (build-derivations %store (list drv)) | |
684 | (if (tarball? out) | |
685 | (let* ((bin #~(string-append #+%bootstrap-coreutils&co | |
686 | "/bin")) | |
687 | (f (computed-file | |
688 | name | |
689 | (with-imported-modules '((guix build utils)) | |
690 | #~(begin | |
691 | (use-modules (guix build utils)) | |
692 | (setenv "PATH" #+bin) | |
693 | (invoke "tar" "xvf" #+out) | |
694 | (copy-file #+name #$output))))) | |
695 | (drv (run-with-store %store (lower-object f))) | |
696 | (_ (build-derivations %store (list drv)))) | |
697 | (call-with-input-file (derivation->output-path drv) | |
698 | get-string-all)) | |
699 | (call-with-input-file out get-string-all))))))) | |
700 | compressors) | |
701 | ||
59688fc4 LC |
702 | (test-assert "return value" |
703 | (let ((drv (package-derivation %store (dummy-package "p")))) | |
704 | (and (derivation? drv) | |
705 | (file-exists? (derivation-file-name drv))))) | |
be13fbfa | 706 | |
6b466336 LC |
707 | (test-assert "package-derivation, inputs deduplicated" |
708 | (let* ((dep (dummy-package "dep")) | |
709 | (p0 (dummy-package "p" (inputs `(("dep" ,dep))))) | |
710 | (p1 (package (inherit p0) | |
711 | (inputs `(("dep" ,(package (inherit dep))) | |
712 | ,@(package-inputs p0)))))) | |
713 | ;; Here P1 ends up with two non-eq? copies of DEP, under the same label. | |
714 | ;; They should be deduplicated so that P0 and P1 lead to the same | |
715 | ;; derivation rather than P1 ending up with duplicate entries in its | |
716 | ;; '%build-inputs' variable. | |
717 | (string=? (derivation-file-name (package-derivation %store p0)) | |
718 | (derivation-file-name (package-derivation %store p1))))) | |
719 | ||
98c075c2 LC |
720 | (test-assert "package-derivation, different system" |
721 | ;; Make sure the 'system' argument of 'package-derivation' is respected. | |
722 | (let* ((system (if (string=? (%current-system) "x86_64-linux") | |
723 | "aarch64-linux" | |
724 | "x86_64-linux")) | |
725 | (drv (package-derivation %store (dummy-package "p") | |
726 | system #:graft? #f))) | |
727 | (define right-system? | |
728 | (mlambdaq (drv) | |
729 | (and (string=? (derivation-system drv) system) | |
730 | (every (compose right-system? derivation-input-derivation) | |
731 | (derivation-inputs drv))))) | |
732 | ||
733 | (right-system? drv))) | |
734 | ||
d510ab46 LC |
735 | (test-assert "package-output" |
736 | (let* ((package (dummy-package "p")) | |
59688fc4 LC |
737 | (drv (package-derivation %store package))) |
738 | (and (derivation? drv) | |
739 | (string=? (derivation->output-path drv) | |
d510ab46 LC |
740 | (package-output %store package "out"))))) |
741 | ||
d51bfe24 LC |
742 | (test-equal "patch not found yields a run-time error" |
743 | '("~a: patch not found\n" "does-not-exist.patch") | |
744 | (guard (c ((formatted-message? c) | |
745 | (cons (formatted-message-string c) | |
746 | (formatted-message-arguments c)))) | |
dbab5150 LC |
747 | (let ((p (package |
748 | (inherit (dummy-package "p")) | |
749 | (source (origin | |
750 | (method (const #f)) | |
751 | (uri "http://whatever") | |
752 | (patches | |
753 | (list (search-patch "does-not-exist.patch"))) | |
754 | (sha256 | |
755 | (base32 | |
756 | "0amn0bbwqvsvvsh6drfwz20ydc2czk374lzw5kksbh6bf78k4ks4"))))))) | |
757 | (package-derivation %store p) | |
758 | #f))) | |
759 | ||
76c48619 LC |
760 | (let ((dummy (dummy-package "foo" (inputs `(("x" ,(current-module))))))) |
761 | (test-equal "&package-input-error" | |
e7477dd5 | 762 | (list dummy `("x" ,(current-module))) |
76c48619 LC |
763 | (guard (c ((package-input-error? c) |
764 | (list (package-error-package c) | |
765 | (package-error-invalid-input c)))) | |
766 | (package-derivation %store dummy)))) | |
767 | ||
f304c9c2 LC |
768 | (test-assert "reference to non-existent output" |
769 | ;; See <http://bugs.gnu.org/19630>. | |
862abf8f LC |
770 | (parameterize ((%graft? #f)) |
771 | (let* ((dep (dummy-package "dep")) | |
772 | (p (dummy-package "p" | |
773 | (inputs `(("dep" ,dep "non-existent")))))) | |
774 | (guard (c ((derivation-missing-output-error? c) | |
775 | (and (string=? (derivation-missing-output c) "non-existent") | |
776 | (equal? (package-derivation %store dep) | |
777 | (derivation-error-derivation c))))) | |
778 | (package-derivation %store p))))) | |
f304c9c2 | 779 | |
be13fbfa LC |
780 | (test-assert "trivial" |
781 | (let* ((p (package (inherit (dummy-package "trivial")) | |
782 | (build-system trivial-build-system) | |
783 | (source #f) | |
784 | (arguments | |
14da91e2 LC |
785 | `(#:guile ,%bootstrap-guile |
786 | #:builder | |
be13fbfa LC |
787 | (begin |
788 | (mkdir %output) | |
789 | (call-with-output-file (string-append %output "/test") | |
790 | (lambda (p) | |
1e868858 MW |
791 | (display '(hello guix) p))) |
792 | #t))))) | |
be13fbfa LC |
793 | (d (package-derivation %store p))) |
794 | (and (build-derivations %store (list d)) | |
59688fc4 | 795 | (let ((p (pk 'drv d (derivation->output-path d)))) |
be13fbfa LC |
796 | (equal? '(hello guix) |
797 | (call-with-input-file (string-append p "/test") read)))))) | |
e3ce5d70 | 798 | |
860a6f1a LC |
799 | (test-assert "trivial with local file as input" |
800 | (let* ((i (search-path %load-path "ice-9/boot-9.scm")) | |
801 | (p (package (inherit (dummy-package "trivial-with-input-file")) | |
802 | (build-system trivial-build-system) | |
803 | (source #f) | |
804 | (arguments | |
805 | `(#:guile ,%bootstrap-guile | |
1e868858 MW |
806 | #:builder (begin |
807 | (copy-file (assoc-ref %build-inputs "input") | |
808 | %output) | |
809 | #t))) | |
860a6f1a LC |
810 | (inputs `(("input" ,i))))) |
811 | (d (package-derivation %store p))) | |
812 | (and (build-derivations %store (list d)) | |
59688fc4 | 813 | (let ((p (pk 'drv d (derivation->output-path d)))) |
860a6f1a LC |
814 | (equal? (call-with-input-file p get-bytevector-all) |
815 | (call-with-input-file i get-bytevector-all)))))) | |
816 | ||
03761a44 LC |
817 | (test-assert "trivial with source" |
818 | (let* ((i (search-path %load-path "ice-9/boot-9.scm")) | |
819 | (p (package (inherit (dummy-package "trivial-with-source")) | |
820 | (build-system trivial-build-system) | |
821 | (source i) | |
822 | (arguments | |
823 | `(#:guile ,%bootstrap-guile | |
1e868858 MW |
824 | #:builder (begin |
825 | (copy-file (assoc-ref %build-inputs "source") | |
826 | %output) | |
827 | #t))))) | |
03761a44 LC |
828 | (d (package-derivation %store p))) |
829 | (and (build-derivations %store (list d)) | |
830 | (let ((p (derivation->output-path d))) | |
831 | (equal? (call-with-input-file p get-bytevector-all) | |
832 | (call-with-input-file i get-bytevector-all)))))) | |
833 | ||
592ef6c8 LC |
834 | (test-assert "trivial with system-dependent input" |
835 | (let* ((p (package (inherit (dummy-package "trivial-system-dependent-input")) | |
836 | (build-system trivial-build-system) | |
837 | (source #f) | |
838 | (arguments | |
839 | `(#:guile ,%bootstrap-guile | |
1e868858 | 840 | #:modules ((guix build utils)) |
592ef6c8 | 841 | #:builder |
1e868858 MW |
842 | (begin |
843 | (use-modules (guix build utils)) | |
844 | (let ((out (assoc-ref %outputs "out")) | |
845 | (bash (assoc-ref %build-inputs "bash"))) | |
846 | (invoke bash "-c" | |
847 | (format #f "echo hello > ~a" out)))))) | |
dd6b9a37 LC |
848 | (inputs `(("bash" ,(search-bootstrap-binary "bash" |
849 | (%current-system))))))) | |
592ef6c8 LC |
850 | (d (package-derivation %store p))) |
851 | (and (build-derivations %store (list d)) | |
59688fc4 | 852 | (let ((p (pk 'drv d (derivation->output-path d)))) |
592ef6c8 LC |
853 | (eq? 'hello (call-with-input-file p read)))))) |
854 | ||
29760251 LC |
855 | (test-assert "trivial with #:allowed-references" |
856 | (let* ((p (package | |
857 | (inherit (dummy-package "trivial")) | |
858 | (build-system trivial-build-system) | |
859 | (arguments | |
860 | `(#:guile ,%bootstrap-guile | |
861 | #:allowed-references (,%bootstrap-guile) | |
862 | #:builder | |
863 | (begin | |
864 | (mkdir %output) | |
865 | ;; The reference to itself isn't allowed so building it | |
866 | ;; should fail. | |
1e868858 MW |
867 | (symlink %output (string-append %output "/self")) |
868 | #t))))) | |
29760251 | 869 | (d (package-derivation %store p))) |
f9e8a123 | 870 | (guard (c ((store-protocol-error? c) #t)) |
29760251 LC |
871 | (build-derivations %store (list d)) |
872 | #f))) | |
873 | ||
a18eda27 LC |
874 | (test-assert "search paths" |
875 | (let* ((p (make-prompt-tag "return-search-paths")) | |
89b0c239 | 876 | (t (make-parameter "guile-0")) |
a18eda27 | 877 | (s (build-system |
89b0c239 LC |
878 | (name 'raw) |
879 | (description "Raw build system with direct store access") | |
880 | (lower (lambda* (name #:key source inputs system target | |
881 | #:allow-other-keys) | |
882 | (bag | |
883 | (name name) | |
884 | (system system) (target target) | |
885 | (build-inputs inputs) | |
886 | (build | |
887 | (lambda* (name inputs | |
888 | #:key outputs system search-paths) | |
889 | (if (string=? name (t)) | |
890 | (abort-to-prompt p search-paths) | |
891 | (gexp->derivation name | |
892 | #~(mkdir #$output)))))))))) | |
a18eda27 LC |
893 | (x (list (search-path-specification |
894 | (variable "GUILE_LOAD_PATH") | |
af070955 | 895 | (files '("share/guile/site/2.0"))) |
a18eda27 LC |
896 | (search-path-specification |
897 | (variable "GUILE_LOAD_COMPILED_PATH") | |
af070955 | 898 | (files '("share/guile/site/2.0"))))) |
a18eda27 LC |
899 | (a (package (inherit (dummy-package "guile")) |
900 | (build-system s) | |
901 | (native-search-paths x))) | |
902 | (b (package (inherit (dummy-package "guile-foo")) | |
903 | (build-system s) | |
904 | (inputs `(("guile" ,a))))) | |
905 | (c (package (inherit (dummy-package "guile-bar")) | |
906 | (build-system s) | |
907 | (inputs `(("guile" ,a) | |
908 | ("guile-foo" ,b)))))) | |
909 | (let-syntax ((collect (syntax-rules () | |
910 | ((_ body ...) | |
911 | (call-with-prompt p | |
912 | (lambda () | |
913 | body ...) | |
914 | (lambda (k search-paths) | |
915 | search-paths)))))) | |
916 | (and (null? (collect (package-derivation %store a))) | |
89b0c239 LC |
917 | (parameterize ((t "guile-foo-0")) |
918 | (equal? x (collect (package-derivation %store b)))) | |
919 | (parameterize ((t "guile-bar-0")) | |
920 | (equal? x (collect (package-derivation %store c)))))))) | |
a18eda27 | 921 | |
aa8e0515 LC |
922 | (test-assert "package-transitive-native-search-paths" |
923 | (let* ((sp (lambda (name) | |
924 | (list (search-path-specification | |
925 | (variable name) | |
926 | (files '("foo/bar")))))) | |
927 | (p0 (dummy-package "p0" (native-search-paths (sp "PATH0")))) | |
928 | (p1 (dummy-package "p1" (native-search-paths (sp "PATH1")))) | |
929 | (p2 (dummy-package "p2" | |
930 | (native-search-paths (sp "PATH2")) | |
931 | (inputs `(("p0" ,p0))) | |
932 | (propagated-inputs `(("p1" ,p1))))) | |
933 | (p3 (dummy-package "p3" | |
934 | (native-search-paths (sp "PATH3")) | |
935 | (native-inputs `(("p0" ,p0))) | |
936 | (propagated-inputs `(("p2" ,p2)))))) | |
937 | (lset= string=? | |
938 | '("PATH1" "PATH2" "PATH3") | |
939 | (map search-path-specification-variable | |
940 | (package-transitive-native-search-paths p3))))) | |
941 | ||
9c1edabd | 942 | (test-assert "package-cross-derivation" |
59688fc4 LC |
943 | (let ((drv (package-cross-derivation %store (dummy-package "p") |
944 | "mips64el-linux-gnu"))) | |
945 | (and (derivation? drv) | |
946 | (file-exists? (derivation-file-name drv))))) | |
9c1edabd | 947 | |
5dce8218 LC |
948 | (test-assert "package-cross-derivation, trivial-build-system" |
949 | (let ((p (package (inherit (dummy-package "p")) | |
950 | (build-system trivial-build-system) | |
951 | (arguments '(#:builder (exit 1)))))) | |
59688fc4 LC |
952 | (let ((drv (package-cross-derivation %store p "mips64el-linux-gnu"))) |
953 | (derivation? drv)))) | |
5dce8218 | 954 | |
9b222abe LC |
955 | (test-assert "package-cross-derivation, no cross builder" |
956 | (let* ((b (build-system (inherit trivial-build-system) | |
0d5a559f | 957 | (lower (const #f)))) |
9b222abe LC |
958 | (p (package (inherit (dummy-package "p")) |
959 | (build-system b)))) | |
960 | (guard (c ((package-cross-build-system-error? c) | |
961 | (eq? (package-error-package c) p))) | |
962 | (package-cross-derivation %store p "mips64el-linux-gnu") | |
963 | #f))) | |
964 | ||
b4c42a4b LC |
965 | ;; XXX: The next two tests can trigger builds when the distro defines |
966 | ;; replacements on core packages, so they're disable for lack of a better | |
967 | ;; solution. | |
968 | ||
969 | ;; (test-equal "package-derivation, direct graft" | |
970 | ;; (package-derivation %store gnu-make #:graft? #f) | |
971 | ;; (let ((p (package (inherit coreutils) | |
972 | ;; (replacement gnu-make)))) | |
973 | ;; (package-derivation %store p #:graft? #t))) | |
05962f29 | 974 | |
b4c42a4b LC |
975 | ;; (test-equal "package-cross-derivation, direct graft" |
976 | ;; (package-cross-derivation %store gnu-make "mips64el-linux-gnu" | |
977 | ;; #:graft? #f) | |
978 | ;; (let ((p (package (inherit coreutils) | |
979 | ;; (replacement gnu-make)))) | |
980 | ;; (package-cross-derivation %store p "mips64el-linux-gnu" | |
981 | ;; #:graft? #t))) | |
05962f29 LC |
982 | |
983 | (test-assert "package-grafts, indirect grafts" | |
984 | (let* ((new (dummy-package "dep" | |
985 | (arguments '(#:implicit-inputs? #f)))) | |
986 | (dep (package (inherit new) (version "0.0"))) | |
987 | (dep* (package (inherit dep) (replacement new))) | |
988 | (dummy (dummy-package "dummy" | |
989 | (arguments '(#:implicit-inputs? #f)) | |
990 | (inputs `(("dep" ,dep*)))))) | |
991 | (equal? (package-grafts %store dummy) | |
992 | (list (graft | |
993 | (origin (package-derivation %store dep)) | |
994 | (replacement (package-derivation %store new))))))) | |
995 | ||
d0025d01 LC |
996 | ;; XXX: This test would require building the cross toolchain just to see if it |
997 | ;; needs grafting, which is obviously too expensive, and thus disabled. | |
998 | ;; | |
999 | ;; (test-assert "package-grafts, indirect grafts, cross" | |
1000 | ;; (let* ((new (dummy-package "dep" | |
1001 | ;; (arguments '(#:implicit-inputs? #f)))) | |
1002 | ;; (dep (package (inherit new) (version "0.0"))) | |
1003 | ;; (dep* (package (inherit dep) (replacement new))) | |
1004 | ;; (dummy (dummy-package "dummy" | |
1005 | ;; (arguments '(#:implicit-inputs? #f)) | |
1006 | ;; (inputs `(("dep" ,dep*))))) | |
1007 | ;; (target "mips64el-linux-gnu")) | |
1008 | ;; ;; XXX: There might be additional grafts, for instance if the distro | |
1009 | ;; ;; defines replacements for core packages like Perl. | |
1010 | ;; (member (graft | |
1011 | ;; (origin (package-cross-derivation %store dep target)) | |
1012 | ;; (replacement | |
1013 | ;; (package-cross-derivation %store new target))) | |
1014 | ;; (package-grafts %store dummy #:target target)))) | |
05962f29 LC |
1015 | |
1016 | (test-assert "package-grafts, indirect grafts, propagated inputs" | |
1017 | (let* ((new (dummy-package "dep" | |
1018 | (arguments '(#:implicit-inputs? #f)))) | |
1019 | (dep (package (inherit new) (version "0.0"))) | |
1020 | (dep* (package (inherit dep) (replacement new))) | |
1021 | (prop (dummy-package "propagated" | |
1022 | (propagated-inputs `(("dep" ,dep*))) | |
1023 | (arguments '(#:implicit-inputs? #f)))) | |
1024 | (dummy (dummy-package "dummy" | |
1025 | (arguments '(#:implicit-inputs? #f)) | |
1026 | (inputs `(("prop" ,prop)))))) | |
1027 | (equal? (package-grafts %store dummy) | |
1028 | (list (graft | |
1029 | (origin (package-derivation %store dep)) | |
1030 | (replacement (package-derivation %store new))))))) | |
1031 | ||
fcadd9ff LC |
1032 | (test-assert "package-grafts, same replacement twice" |
1033 | (let* ((new (dummy-package "dep" | |
1034 | (version "1") | |
1035 | (arguments '(#:implicit-inputs? #f)))) | |
1036 | (dep (package (inherit new) (version "0") (replacement new))) | |
1037 | (p1 (dummy-package "intermediate1" | |
1038 | (arguments '(#:implicit-inputs? #f)) | |
1039 | (inputs `(("dep" ,dep))))) | |
1040 | (p2 (dummy-package "intermediate2" | |
1041 | (arguments '(#:implicit-inputs? #f)) | |
1042 | ;; Here we copy DEP to have an equivalent package that is not | |
1043 | ;; 'eq?' to DEP. This is similar to what happens with | |
1044 | ;; 'package-with-explicit-inputs' & co. | |
1045 | (inputs `(("dep" ,(package (inherit dep))))))) | |
1046 | (p3 (dummy-package "final" | |
1047 | (arguments '(#:implicit-inputs? #f)) | |
1048 | (inputs `(("p1" ,p1) ("p2" ,p2)))))) | |
1049 | (equal? (package-grafts %store p3) | |
1050 | (list (graft | |
1051 | (origin (package-derivation %store | |
1052 | (package (inherit dep) | |
1053 | (replacement #f)))) | |
1054 | (replacement (package-derivation %store new))))))) | |
1055 | ||
03a70e4c LC |
1056 | (test-assert "package-grafts, dependency on several outputs" |
1057 | ;; Make sure we get one graft per output; see <https://bugs.gnu.org/41796>. | |
1058 | (letrec* ((p0 (dummy-package "p0" | |
1059 | (version "1.0") | |
1060 | (replacement p0*) | |
1061 | (arguments '(#:implicit-inputs? #f)) | |
1062 | (outputs '("out" "lib")))) | |
1063 | (p0* (package (inherit p0) (version "1.1"))) | |
1064 | (p1 (dummy-package "p1" | |
1065 | (arguments '(#:implicit-inputs? #f)) | |
1066 | (inputs `(("p0" ,p0) | |
1067 | ("p0:lib" ,p0 "lib")))))) | |
1068 | (lset= equal? (pk (package-grafts %store p1)) | |
1069 | (list (graft | |
1070 | (origin (package-derivation %store p0)) | |
1071 | (origin-output "out") | |
1072 | (replacement (package-derivation %store p0*)) | |
1073 | (replacement-output "out")) | |
1074 | (graft | |
1075 | (origin (package-derivation %store p0)) | |
1076 | (origin-output "lib") | |
1077 | (replacement (package-derivation %store p0*)) | |
1078 | (replacement-output "lib")))))) | |
1079 | ||
d0025d01 LC |
1080 | (test-assert "replacement also grafted" |
1081 | ;; We build a DAG as below, where dotted arrows represent replacements and | |
1082 | ;; solid arrows represent dependencies: | |
1083 | ;; | |
1084 | ;; P1 ·············> P1R | |
1085 | ;; |\__________________. | |
1086 | ;; v v | |
1087 | ;; P2 ·············> P2R | |
1088 | ;; | | |
1089 | ;; v | |
1090 | ;; P3 | |
1091 | ;; | |
1092 | ;; We want to make sure that: | |
1093 | ;; grafts(P3) = (P1,P1R) + (P2, grafted(P2R, (P1,P1R))) | |
1094 | ;; where: | |
1095 | ;; (A,B) is a graft to replace A by B | |
1096 | ;; grafted(DRV,G) denoted DRV with graft G applied | |
1097 | (let* ((p1r (dummy-package "P1" | |
1098 | (build-system trivial-build-system) | |
1099 | (arguments | |
1100 | `(#:guile ,%bootstrap-guile | |
1101 | #:builder (let ((out (assoc-ref %outputs "out"))) | |
1102 | (mkdir out) | |
1103 | (call-with-output-file | |
1104 | (string-append out "/replacement") | |
1105 | (const #t))))))) | |
1106 | (p1 (package | |
1107 | (inherit p1r) (name "p1") (replacement p1r) | |
1108 | (arguments | |
1109 | `(#:guile ,%bootstrap-guile | |
1e868858 MW |
1110 | #:builder (begin |
1111 | (mkdir (assoc-ref %outputs "out")) | |
1112 | #t))))) | |
d0025d01 LC |
1113 | (p2r (dummy-package "P2" |
1114 | (build-system trivial-build-system) | |
1115 | (inputs `(("p1" ,p1))) | |
1116 | (arguments | |
1117 | `(#:guile ,%bootstrap-guile | |
1118 | #:builder (let ((out (assoc-ref %outputs "out"))) | |
1119 | (mkdir out) | |
1120 | (chdir out) | |
1121 | (symlink (assoc-ref %build-inputs "p1") "p1") | |
1122 | (call-with-output-file (string-append out "/replacement") | |
1123 | (const #t))))))) | |
1124 | (p2 (package | |
1125 | (inherit p2r) (name "p2") (replacement p2r) | |
1126 | (arguments | |
1127 | `(#:guile ,%bootstrap-guile | |
1128 | #:builder (let ((out (assoc-ref %outputs "out"))) | |
1129 | (mkdir out) | |
1130 | (chdir out) | |
1131 | (symlink (assoc-ref %build-inputs "p1") | |
1e868858 MW |
1132 | "p1") |
1133 | #t))))) | |
d0025d01 LC |
1134 | (p3 (dummy-package "p3" |
1135 | (build-system trivial-build-system) | |
1136 | (inputs `(("p2" ,p2))) | |
1137 | (arguments | |
1138 | `(#:guile ,%bootstrap-guile | |
1139 | #:builder (let ((out (assoc-ref %outputs "out"))) | |
1140 | (mkdir out) | |
1141 | (chdir out) | |
1142 | (symlink (assoc-ref %build-inputs "p2") | |
1e868858 MW |
1143 | "p2") |
1144 | #t)))))) | |
d0025d01 LC |
1145 | (lset= equal? |
1146 | (package-grafts %store p3) | |
1147 | (list (graft | |
1148 | (origin (package-derivation %store p1 #:graft? #f)) | |
1149 | (replacement (package-derivation %store p1r))) | |
1150 | (graft | |
1151 | (origin (package-derivation %store p2 #:graft? #f)) | |
1152 | (replacement | |
1153 | (package-derivation %store p2r #:graft? #t))))))) | |
1154 | ||
c22a1324 LC |
1155 | ;;; XXX: Nowadays 'graft-derivation' needs to build derivations beforehand to |
1156 | ;;; find out about their run-time dependencies, so this test is no longer | |
1157 | ;;; applicable since it would trigger a full rebuild. | |
1158 | ;; | |
1159 | ;; (test-assert "package-derivation, indirect grafts" | |
1160 | ;; (let* ((new (dummy-package "dep" | |
1161 | ;; (arguments '(#:implicit-inputs? #f)))) | |
1162 | ;; (dep (package (inherit new) (version "0.0"))) | |
1163 | ;; (dep* (package (inherit dep) (replacement new))) | |
1164 | ;; (dummy (dummy-package "dummy" | |
1165 | ;; (arguments '(#:implicit-inputs? #f)) | |
1166 | ;; (inputs `(("dep" ,dep*))))) | |
1167 | ;; (guile (package-derivation %store (canonical-package guile-2.0) | |
1168 | ;; #:graft? #f))) | |
1169 | ;; (equal? (package-derivation %store dummy) | |
1170 | ;; (graft-derivation %store | |
1171 | ;; (package-derivation %store dummy #:graft? #f) | |
1172 | ;; (package-grafts %store dummy) | |
1173 | ||
1174 | ;; ;; Use the same Guile as 'package-derivation'. | |
1175 | ;; #:guile guile)))) | |
05962f29 | 1176 | |
d3d337d2 LC |
1177 | (test-equal "package->bag" |
1178 | `("foo86-hurd" #f (,(package-source gnu-make)) | |
1179 | (,(canonical-package glibc)) (,(canonical-package coreutils))) | |
1180 | (let ((bag (package->bag gnu-make "foo86-hurd"))) | |
1181 | (list (bag-system bag) (bag-target bag) | |
1182 | (assoc-ref (bag-build-inputs bag) "source") | |
1183 | (assoc-ref (bag-build-inputs bag) "libc") | |
1184 | (assoc-ref (bag-build-inputs bag) "coreutils")))) | |
1185 | ||
b49caaa2 LC |
1186 | (test-assert "package->bag, sensitivity to %current-target-system" |
1187 | ;; https://bugs.gnu.org/41713 | |
1188 | (let* ((lower (lambda* (name #:key system target inputs native-inputs | |
1189 | #:allow-other-keys) | |
1190 | (and (not target) | |
1191 | (bag (name name) (system system) (target target) | |
1192 | (build-inputs native-inputs) | |
1193 | (host-inputs inputs) | |
7d873f19 LC |
1194 | (build (lambda* (name inputs |
1195 | #:key system target | |
1196 | #:allow-other-keys) | |
1197 | (gexp->derivation "foo" | |
1198 | #~(mkdir #$output)))))))) | |
b49caaa2 LC |
1199 | (bs (build-system |
1200 | (name 'build-system-without-cross-compilation) | |
1201 | (description "Does not support cross compilation.") | |
1202 | (lower lower))) | |
1203 | (dep (dummy-package "dep" (build-system bs))) | |
1204 | (pkg (dummy-package "example" | |
1205 | (native-inputs `(("dep" ,dep))))) | |
1206 | (do-not-build (lambda (continue store lst . _) lst))) | |
1207 | (equal? (with-build-handler do-not-build | |
1208 | (parameterize ((%current-target-system "powerpc64le-linux-gnu") | |
1209 | (%graft? #t)) | |
1210 | (package-cross-derivation %store pkg | |
1211 | (%current-target-system) | |
1212 | #:graft? #t))) | |
1213 | (with-build-handler do-not-build | |
1214 | (package-cross-derivation %store | |
1215 | (package (inherit pkg)) | |
1216 | "powerpc64le-linux-gnu" | |
1217 | #:graft? #t))))) | |
1218 | ||
d3d337d2 LC |
1219 | (test-equal "package->bag, cross-compilation" |
1220 | `(,(%current-system) "foo86-hurd" | |
1221 | (,(package-source gnu-make)) | |
1222 | (,(canonical-package glibc)) (,(canonical-package coreutils))) | |
1223 | (let ((bag (package->bag gnu-make (%current-system) "foo86-hurd"))) | |
1224 | (list (bag-system bag) (bag-target bag) | |
1225 | (assoc-ref (bag-build-inputs bag) "source") | |
1226 | (assoc-ref (bag-build-inputs bag) "libc") | |
1227 | (assoc-ref (bag-build-inputs bag) "coreutils")))) | |
1228 | ||
50373bab LC |
1229 | (test-assert "package->bag, propagated inputs" |
1230 | (let* ((dep (dummy-package "dep")) | |
1231 | (prop (dummy-package "prop" | |
1232 | (propagated-inputs `(("dep" ,dep))))) | |
1233 | (dummy (dummy-package "dummy" | |
1234 | (inputs `(("prop" ,prop))))) | |
1235 | (inputs (bag-transitive-inputs (package->bag dummy #:graft? #f)))) | |
161094c8 LC |
1236 | (match (assoc "dep" inputs) |
1237 | (("dep" package) | |
50373bab LC |
1238 | (eq? package dep))))) |
1239 | ||
efb10f17 LC |
1240 | (test-assert "package->bag, sensitivity to %current-system" |
1241 | (let* ((dep (dummy-package "dep" | |
1242 | (propagated-inputs (if (string=? (%current-system) | |
1243 | "i586-gnu") | |
1244 | `(("libxml2" ,libxml2)) | |
1245 | '())))) | |
1246 | (pkg (dummy-package "foo" | |
1247 | (native-inputs `(("dep" ,dep))))) | |
1248 | (bag (package->bag pkg (%current-system) "i586-gnu"))) | |
1249 | (equal? (parameterize ((%current-system "x86_64-linux")) | |
1250 | (bag-transitive-inputs bag)) | |
1251 | (parameterize ((%current-system "i586-gnu")) | |
1252 | (bag-transitive-inputs bag))))) | |
1253 | ||
f52fbf70 LC |
1254 | (test-assert "package->bag, sensitivity to %current-target-system" |
1255 | (let* ((dep (dummy-package "dep" | |
1256 | (propagated-inputs (if (%current-target-system) | |
1257 | `(("libxml2" ,libxml2)) | |
1258 | '())))) | |
1259 | (pkg (dummy-package "foo" | |
1260 | (native-inputs `(("dep" ,dep))))) | |
1261 | (bag (package->bag pkg (%current-system) "foo86-hurd"))) | |
1262 | (equal? (parameterize ((%current-target-system "foo64-gnu")) | |
1263 | (bag-transitive-inputs bag)) | |
1264 | (parameterize ((%current-target-system #f)) | |
1265 | (bag-transitive-inputs bag))))) | |
1266 | ||
ba41f87e | 1267 | (test-assertm "bag->derivation" |
05962f29 LC |
1268 | (parameterize ((%graft? #f)) |
1269 | (let ((bag (package->bag gnu-make)) | |
1270 | (drv (package-derivation %store gnu-make))) | |
1271 | (parameterize ((%current-system "foox86-hurd")) ;should have no effect | |
ba41f87e LC |
1272 | (mlet %store-monad ((bag-drv (bag->derivation bag))) |
1273 | (return (equal? drv bag-drv))))))) | |
d3d337d2 LC |
1274 | |
1275 | (test-assert "bag->derivation, cross-compilation" | |
05962f29 LC |
1276 | (parameterize ((%graft? #f)) |
1277 | (let* ((target "mips64el-linux-gnu") | |
1278 | (bag (package->bag gnu-make (%current-system) target)) | |
1279 | (drv (package-cross-derivation %store gnu-make target))) | |
1280 | (parameterize ((%current-system "foox86-hurd") ;should have no effect | |
1281 | (%current-target-system "foo64-linux-gnu")) | |
ba41f87e LC |
1282 | (mlet %store-monad ((bag-drv (bag->derivation bag))) |
1283 | (return (equal? drv bag-drv))))))) | |
d3d337d2 | 1284 | |
b69c5c2c LC |
1285 | (when (or (not (network-reachable?)) (shebang-too-long?)) |
1286 | (test-skip 1)) | |
9e782349 | 1287 | (test-assert "GNU Make, bootstrap" |
03d76577 LC |
1288 | ;; GNU-MAKE-FOR-TESTS can be built cheaply; we choose it here so that the |
1289 | ;; test doesn't last for too long. | |
1290 | (let ((gnu-make gnu-make-for-tests)) | |
9e782349 LC |
1291 | (and (package? gnu-make) |
1292 | (or (location? (package-location gnu-make)) | |
1293 | (not (package-location gnu-make))) | |
1294 | (let* ((drv (package-derivation %store gnu-make)) | |
59688fc4 | 1295 | (out (derivation->output-path drv))) |
14da91e2 | 1296 | (and (build-derivations %store (list drv)) |
9e782349 | 1297 | (file-exists? (string-append out "/bin/make"))))))) |
e3ce5d70 | 1298 | |
f37f2b83 LC |
1299 | (test-equal "package-mapping" |
1300 | 42 | |
1301 | (let* ((dep (dummy-package "chbouib" | |
1302 | (native-inputs `(("x" ,grep))))) | |
1303 | (p0 (dummy-package "example" | |
ff39361c | 1304 | (source 77) |
f37f2b83 LC |
1305 | (inputs `(("foo" ,coreutils) |
1306 | ("bar" ,grep) | |
1307 | ("baz" ,dep))))) | |
1308 | (transform (lambda (p) | |
1309 | (package (inherit p) (source 42)))) | |
1310 | (rewrite (package-mapping transform)) | |
ff39361c LC |
1311 | (p1 (rewrite p0)) |
1312 | (bag0 (package->bag p0)) | |
1313 | (bag1 (package->bag p1))) | |
f37f2b83 LC |
1314 | (and (eq? p1 (rewrite p0)) |
1315 | (eqv? 42 (package-source p1)) | |
ff39361c LC |
1316 | |
1317 | ;; Implicit inputs should be left unchanged (skip "source", "foo", | |
1318 | ;; "bar", and "baz" in this comparison). | |
1319 | (equal? (drop (bag-direct-inputs bag0) 4) | |
1320 | (drop (bag-direct-inputs bag1) 4)) | |
1321 | ||
f37f2b83 LC |
1322 | (match (package-inputs p1) |
1323 | ((("foo" dep1) ("bar" dep2) ("baz" dep3)) | |
1324 | (and (eq? dep1 (rewrite coreutils)) ;memoization | |
1325 | (eq? dep2 (rewrite grep)) | |
1326 | (eq? dep3 (rewrite dep)) | |
1327 | (eqv? 42 | |
1328 | (package-source dep1) (package-source dep2) | |
1329 | (package-source dep3)) | |
1330 | (match (package-native-inputs dep3) | |
1331 | ((("x" dep)) | |
1332 | (and (eq? dep (rewrite grep)) | |
1333 | (package-source dep)))))))))) | |
1334 | ||
ff39361c LC |
1335 | (test-equal "package-mapping, deep" |
1336 | '(42) | |
1337 | (let* ((p0 (dummy-package "example" | |
1338 | (inputs `(("foo" ,coreutils) | |
1339 | ("bar" ,grep))))) | |
1340 | (transform (lambda (p) | |
1341 | (package (inherit p) (source 42)))) | |
1342 | (rewrite (package-mapping transform #:deep? #t)) | |
1343 | (p1 (rewrite p0)) | |
1344 | (bag (package->bag p1))) | |
1345 | (and (eq? p1 (rewrite p0)) | |
1346 | (match (bag-direct-inputs bag) | |
1347 | ((("source" 42) ("foo" dep1) ("bar" dep2) rest ..1) | |
1348 | (and (eq? dep1 (rewrite coreutils)) ;memoization | |
1349 | (eq? dep2 (rewrite grep)) | |
1350 | (= 42 (package-source dep1)) | |
1351 | (= 42 (package-source dep2)) | |
1352 | ||
1353 | ;; Check that implicit inputs of P0 also got rewritten. | |
1354 | (delete-duplicates | |
1355 | (map (match-lambda | |
1356 | ((_ package . _) | |
1357 | (package-source package))) | |
1358 | rest)))))))) | |
1359 | ||
2a75b0b6 LC |
1360 | (test-assert "package-input-rewriting" |
1361 | (let* ((dep (dummy-package "chbouib" | |
1362 | (native-inputs `(("x" ,grep))))) | |
1363 | (p0 (dummy-package "example" | |
1364 | (inputs `(("foo" ,coreutils) | |
1365 | ("bar" ,grep) | |
1366 | ("baz" ,dep))))) | |
1367 | (rewrite (package-input-rewriting `((,coreutils . ,sed) | |
1368 | (,grep . ,findutils)) | |
8819551c LC |
1369 | (cut string-append "r-" <>) |
1370 | #:deep? #f)) | |
2a75b0b6 LC |
1371 | (p1 (rewrite p0)) |
1372 | (p2 (rewrite p0))) | |
1373 | (and (not (eq? p1 p0)) | |
1374 | (eq? p1 p2) ;memoization | |
1375 | (string=? "r-example" (package-name p1)) | |
1376 | (match (package-inputs p1) | |
1377 | ((("foo" dep1) ("bar" dep2) ("baz" dep3)) | |
1378 | (and (eq? dep1 sed) | |
1379 | (eq? dep2 findutils) | |
1380 | (string=? (package-name dep3) "r-chbouib") | |
1381 | (eq? dep3 (rewrite dep)) ;memoization | |
1382 | (match (package-native-inputs dep3) | |
1383 | ((("x" dep)) | |
8819551c LC |
1384 | (eq? dep findutils)))))) |
1385 | ||
1386 | ;; Make sure implicit inputs were left unchanged. | |
1387 | (equal? (drop (bag-direct-inputs (package->bag p1)) 3) | |
1388 | (drop (bag-direct-inputs (package->bag p0)) 3))))) | |
1389 | ||
1390 | (test-eq "package-input-rewriting, deep" | |
1391 | (derivation-file-name (package-derivation %store sed)) | |
1392 | (let* ((p0 (dummy-package "chbouib" | |
1393 | (build-system python-build-system) | |
1394 | (arguments `(#:python ,python)))) | |
1395 | (rewrite (package-input-rewriting `((,python . ,sed)))) | |
1396 | (p1 (rewrite p0))) | |
1397 | (match (bag-direct-inputs (package->bag p1)) | |
1398 | ((("python" python) _ ...) | |
1399 | (derivation-file-name (package-derivation %store python)))))) | |
2a75b0b6 | 1400 | |
f258d886 LC |
1401 | (test-assert "package-input-rewriting/spec" |
1402 | (let* ((dep (dummy-package "chbouib" | |
1403 | (native-inputs `(("x" ,grep))))) | |
1404 | (p0 (dummy-package "example" | |
1405 | (inputs `(("foo" ,coreutils) | |
1406 | ("bar" ,grep) | |
1407 | ("baz" ,dep))))) | |
1408 | (rewrite (package-input-rewriting/spec | |
1409 | `(("coreutils" . ,(const sed)) | |
2bf6f962 LC |
1410 | ("grep" . ,(const findutils))) |
1411 | #:deep? #f)) | |
f258d886 LC |
1412 | (p1 (rewrite p0)) |
1413 | (p2 (rewrite p0))) | |
1414 | (and (not (eq? p1 p0)) | |
1415 | (eq? p1 p2) ;memoization | |
1416 | (string=? "example" (package-name p1)) | |
1417 | (match (package-inputs p1) | |
1418 | ((("foo" dep1) ("bar" dep2) ("baz" dep3)) | |
1419 | (and (string=? (package-full-name dep1) | |
1420 | (package-full-name sed)) | |
1421 | (string=? (package-full-name dep2) | |
1422 | (package-full-name findutils)) | |
1423 | (string=? (package-name dep3) "chbouib") | |
1424 | (eq? dep3 (rewrite dep)) ;memoization | |
1425 | (match (package-native-inputs dep3) | |
1426 | ((("x" dep)) | |
1427 | (string=? (package-full-name dep) | |
2bf6f962 LC |
1428 | (package-full-name findutils))))))) |
1429 | ||
1430 | ;; Make sure implicit inputs were left unchanged. | |
1431 | (equal? (drop (bag-direct-inputs (package->bag p1)) 3) | |
1432 | (drop (bag-direct-inputs (package->bag p0)) 3))))) | |
f258d886 LC |
1433 | |
1434 | (test-assert "package-input-rewriting/spec, partial match" | |
1435 | (let* ((dep (dummy-package "chbouib" | |
1436 | (version "1") | |
1437 | (native-inputs `(("x" ,grep))))) | |
1438 | (p0 (dummy-package "example" | |
1439 | (inputs `(("foo" ,coreutils) | |
1440 | ("bar" ,dep))))) | |
1441 | (rewrite (package-input-rewriting/spec | |
1442 | `(("chbouib@123" . ,(const sed)) ;not matched | |
2bf6f962 LC |
1443 | ("grep" . ,(const findutils))) |
1444 | #:deep? #f)) | |
f258d886 LC |
1445 | (p1 (rewrite p0))) |
1446 | (and (not (eq? p1 p0)) | |
1447 | (string=? "example" (package-name p1)) | |
1448 | (match (package-inputs p1) | |
1449 | ((("foo" dep1) ("bar" dep2)) | |
1450 | (and (string=? (package-full-name dep1) | |
1451 | (package-full-name coreutils)) | |
1452 | (eq? dep2 (rewrite dep)) ;memoization | |
1453 | (match (package-native-inputs dep2) | |
1454 | ((("x" dep)) | |
1455 | (string=? (package-full-name dep) | |
1456 | (package-full-name findutils)))))))))) | |
1457 | ||
2bf6f962 LC |
1458 | (test-assert "package-input-rewriting/spec, deep" |
1459 | (let* ((dep (dummy-package "chbouib")) | |
1460 | (p0 (dummy-package "example" | |
1461 | (build-system gnu-build-system) | |
1462 | (inputs `(("dep" ,dep))))) | |
1463 | (rewrite (package-input-rewriting/spec | |
1464 | `(("tar" . ,(const sed)) | |
1465 | ("gzip" . ,(const findutils))))) | |
1466 | (p1 (rewrite p0)) | |
1467 | (p2 (rewrite p0))) | |
1468 | (and (not (eq? p1 p0)) | |
1469 | (eq? p1 p2) ;memoization | |
1470 | (string=? "example" (package-name p1)) | |
1471 | (match (package-inputs p1) | |
1472 | ((("dep" dep1)) | |
1473 | (and (string=? (package-full-name dep1) | |
1474 | (package-full-name dep)) | |
1475 | (eq? dep1 (rewrite dep))))) ;memoization | |
1476 | ||
1477 | ;; Make sure implicit inputs were replaced. | |
1478 | (match (bag-direct-inputs (package->bag p1)) | |
1479 | ((("dep" dep1) ("tar" tar) ("gzip" gzip) _ ...) | |
1480 | (and (eq? dep1 (rewrite dep)) | |
1481 | (string=? (package-full-name tar) | |
1482 | (package-full-name sed)) | |
1483 | (string=? (package-full-name gzip) | |
1484 | (package-full-name findutils)))))))) | |
1485 | ||
1486 | (test-assert "package-input-rewriting/spec, no duplicates" | |
1487 | ;; Ensure that deep input rewriting does not forget implicit inputs. Doing | |
1488 | ;; so could lead to duplicates in a package's inputs: in the example below, | |
1489 | ;; P0's transitive inputs would contain one rewritten "python" and one | |
1490 | ;; original "python". These two "python" packages are thus not 'eq?' but | |
1491 | ;; they lower to the same derivation. See <https://bugs.gnu.org/42156>, | |
1492 | ;; which can be reproduced by passing #:deep? #f. | |
1493 | (let* ((dep0 (dummy-package "dep0" | |
1494 | (build-system trivial-build-system) | |
1495 | (propagated-inputs `(("python" ,python))))) | |
1496 | (p0 (dummy-package "chbouib" | |
1497 | (build-system python-build-system) | |
1498 | (arguments `(#:python ,python)) | |
1499 | (inputs `(("dep0" ,dep0))))) | |
1500 | (rewrite (package-input-rewriting/spec '() #:deep? #t)) | |
1501 | (p1 (rewrite p0)) | |
1502 | (bag1 (package->bag p1)) | |
1503 | (pythons (filter-map (match-lambda | |
1504 | (("python" python) python) | |
1505 | (_ #f)) | |
1506 | (bag-transitive-inputs bag1)))) | |
1507 | (match (delete-duplicates pythons eq?) | |
1508 | ((p) (eq? p (rewrite python)))))) | |
1509 | ||
b3fc03ee LC |
1510 | (test-equal "package-input-rewriting/spec, graft" |
1511 | (derivation-file-name (package-derivation %store sed)) | |
1512 | ||
1513 | ;; Make sure replacements are rewritten. | |
1514 | (let* ((dep0 (dummy-package "dep" | |
1515 | (version "1") | |
1516 | (build-system trivial-build-system) | |
1517 | (inputs `(("coreutils" ,coreutils))))) | |
1518 | (dep1 (dummy-package "dep" | |
1519 | (version "0") | |
1520 | (build-system trivial-build-system) | |
1521 | (replacement dep0))) | |
1522 | (p0 (dummy-package "p" | |
1523 | (build-system trivial-build-system) | |
1524 | (inputs `(("dep" ,dep1))))) | |
1525 | (rewrite (package-input-rewriting/spec | |
1526 | `(("coreutils" . ,(const sed))))) | |
1527 | (p1 (rewrite p0))) | |
1528 | (match (package-inputs p1) | |
1529 | ((("dep" dep)) | |
1530 | (match (package-inputs (package-replacement dep)) | |
1531 | ((("coreutils" coreutils)) | |
1532 | ;; COREUTILS is not 'eq?' to SED, so the most reliable way to check | |
1533 | ;; for equality is to lower to a derivation. | |
1534 | (derivation-file-name | |
1535 | (package-derivation %store coreutils)))))))) | |
1536 | ||
46135ce4 LC |
1537 | (test-assert "package-with-c-toolchain" |
1538 | (let* ((dep (dummy-package "chbouib" | |
1539 | (build-system gnu-build-system) | |
1540 | (native-inputs `(("x" ,grep))))) | |
1541 | (p0 (dummy-package "thingie" | |
1542 | (build-system gnu-build-system) | |
1543 | (inputs `(("foo" ,grep) | |
1544 | ("bar" ,dep))))) | |
1545 | (tc (dummy-package "my-toolchain")) | |
1546 | (p1 (package-with-c-toolchain p0 `(("toolchain" ,tc))))) | |
1547 | (define toolchain-packages | |
1548 | '("gcc" "binutils" "glibc" "ld-wrapper")) | |
1549 | ||
1550 | (match (bag-build-inputs (package->bag p1)) | |
1551 | ((("foo" foo) ("bar" bar) (_ (= package-name packages) . _) ...) | |
1552 | (and (not (any (cut member <> packages) toolchain-packages)) | |
1553 | (member "my-toolchain" packages) | |
1554 | (eq? foo grep) | |
1555 | (eq? bar dep)))))) | |
1556 | ||
8db4ebb0 LC |
1557 | (test-assert "package-input-rewriting/spec, identity" |
1558 | ;; Make sure that 'package-input-rewriting/spec' doesn't gratuitously | |
1559 | ;; introduce variants. In this case, the LIBFFI propagated input should not | |
1560 | ;; be duplicated when passing GOBJECT through REWRITE. | |
1561 | ;; See <https://issues.guix.gnu.org/43890>. | |
1562 | (let* ((libffi (dummy-package "libffi" | |
1563 | (build-system trivial-build-system))) | |
1564 | (glib (dummy-package "glib" | |
1565 | (build-system trivial-build-system) | |
1566 | (propagated-inputs `(("libffi" ,libffi))))) | |
1567 | (gobject (dummy-package "gobject-introspection" | |
1568 | (build-system trivial-build-system) | |
1569 | (inputs `(("glib" ,glib))) | |
1570 | (propagated-inputs `(("libffi" ,libffi))))) | |
1571 | (rewrite (package-input-rewriting/spec | |
1572 | `(("glib" . ,identity))))) | |
1573 | (and (= (length (package-transitive-inputs gobject)) | |
1574 | (length (package-transitive-inputs (rewrite gobject)))) | |
1575 | (string=? (derivation-file-name | |
1576 | (package-derivation %store (rewrite gobject))) | |
1577 | (derivation-file-name | |
1578 | (package-derivation %store gobject)))))) | |
1579 | ||
1580 | (test-assert "package-input-rewriting, identity" | |
1581 | ;; Similar to the test above, but with 'package-input-rewriting'. | |
1582 | ;; See <https://issues.guix.gnu.org/43890>. | |
1583 | (let* ((libffi (dummy-package "libffi" | |
1584 | (build-system trivial-build-system))) | |
1585 | (glib (dummy-package "glib" | |
1586 | (build-system trivial-build-system) | |
1587 | (propagated-inputs `(("libffi" ,libffi))))) | |
1588 | (gobject (dummy-package "gobject-introspection" | |
1589 | (build-system trivial-build-system) | |
1590 | (inputs `(("glib" ,glib))) | |
1591 | (propagated-inputs `(("libffi" ,libffi))))) | |
1592 | (rewrite (package-input-rewriting `((,glib . ,glib))))) | |
1593 | (and (= (length (package-transitive-inputs gobject)) | |
1594 | (length (package-transitive-inputs (rewrite gobject)))) | |
1595 | (string=? (derivation-file-name | |
1596 | (package-derivation %store (rewrite gobject))) | |
1597 | (derivation-file-name | |
1598 | (package-derivation %store gobject)))))) | |
1599 | ||
c423ae89 LC |
1600 | (test-equal "package-patched-vulnerabilities" |
1601 | '(("CVE-2015-1234") | |
1602 | ("CVE-2016-1234" "CVE-2018-4567") | |
1603 | ()) | |
1604 | (let ((p1 (dummy-package "pi" | |
1605 | (source (dummy-origin | |
1606 | (patches (list "/a/b/pi-CVE-2015-1234.patch")))))) | |
1607 | (p2 (dummy-package "pi" | |
1608 | (source (dummy-origin | |
1609 | (patches (list | |
1610 | "/a/b/pi-CVE-2016-1234-CVE-2018-4567.patch")))))) | |
1611 | (p3 (dummy-package "pi" (source (dummy-origin))))) | |
1612 | (map package-patched-vulnerabilities | |
1613 | (list p1 p2 p3)))) | |
1614 | ||
ba326ce4 LC |
1615 | (test-eq "fold-packages" hello |
1616 | (fold-packages (lambda (p r) | |
1617 | (if (string=? (package-name p) "hello") | |
1618 | p | |
1619 | r)) | |
1620 | #f)) | |
1621 | ||
386b71d1 LC |
1622 | (test-assert "fold-packages, hidden package" |
1623 | ;; There are two public variables providing "guile@2.0" ('guile-final' in | |
b66d6d52 | 1624 | ;; commencement.scm and 'guile-2.0' in guile.scm), but only the latter |
386b71d1 LC |
1625 | ;; should show up. |
1626 | (match (fold-packages (lambda (p r) | |
1627 | (if (and (string=? (package-name p) "guile") | |
1628 | (string-prefix? "2.0" | |
1629 | (package-version p))) | |
1630 | (cons p r) | |
1631 | r)) | |
1632 | '()) | |
1633 | ((one) | |
b66d6d52 | 1634 | (eq? one guile-2.0)))) |
386b71d1 | 1635 | |
0ea939fb LC |
1636 | (test-assert "fold-available-packages with/without cache" |
1637 | (let () | |
1638 | (define no-cache | |
1639 | (fold-available-packages (lambda* (name version result #:rest rest) | |
1640 | (cons (cons* name version rest) | |
1641 | result)) | |
1642 | '())) | |
1643 | ||
1644 | (define from-cache | |
1645 | (call-with-temporary-directory | |
1646 | (lambda (cache) | |
1647 | (generate-package-cache cache) | |
1648 | (mock ((guix describe) current-profile (const cache)) | |
1649 | (mock ((gnu packages) cache-is-authoritative? (const #t)) | |
1650 | (fold-available-packages (lambda* (name version result | |
1651 | #:rest rest) | |
1652 | (cons (cons* name version rest) | |
1653 | result)) | |
1654 | '())))))) | |
1655 | ||
73744725 LC |
1656 | (define (list->set* lst) |
1657 | ;; Return two values: LST represented as a set and the list of | |
1658 | ;; duplicates in LST. | |
1659 | (let loop ((lst lst) | |
1660 | (duplicates '()) | |
1661 | (seen (set))) | |
1662 | (match lst | |
1663 | (() | |
1664 | (values seen duplicates)) | |
1665 | ((head . tail) | |
1666 | (if (set-contains? seen head) | |
1667 | (loop tail (cons head duplicates) seen) | |
1668 | (loop tail duplicates (set-insert head seen))))))) | |
1669 | ||
1670 | ;; Compare FROM-CACHE and NO-CACHE but avoid 'lset=', which exhibits | |
1671 | ;; exponential behavior. | |
1672 | (let ((set1 duplicates1 (list->set* from-cache)) | |
1673 | (set2 duplicates2 (list->set* no-cache))) | |
1674 | (and (null? duplicates1) (null? duplicates2) | |
1675 | (every (cut set-contains? set1 <>) no-cache) | |
1676 | (every (cut set-contains? set2 <>) from-cache))))) | |
0ea939fb | 1677 | |
6b1891b0 LC |
1678 | (test-assert "find-packages-by-name" |
1679 | (match (find-packages-by-name "hello") | |
1680 | (((? (cut eq? hello <>))) #t) | |
1681 | (wrong (pk 'find-packages-by-name wrong #f)))) | |
1682 | ||
1683 | (test-assert "find-packages-by-name with version" | |
1684 | (match (find-packages-by-name "hello" (package-version hello)) | |
1685 | (((? (cut eq? hello <>))) #t) | |
1686 | (wrong (pk 'find-packages-by-name wrong #f)))) | |
1687 | ||
5fbdc9a5 LC |
1688 | (test-equal "find-packages-by-name with cache" |
1689 | (find-packages-by-name "guile") | |
1690 | (call-with-temporary-directory | |
1691 | (lambda (cache) | |
1692 | (generate-package-cache cache) | |
1693 | (mock ((guix describe) current-profile (const cache)) | |
1694 | (mock ((gnu packages) cache-is-authoritative? (const #t)) | |
1695 | (find-packages-by-name "guile")))))) | |
1696 | ||
1697 | (test-equal "find-packages-by-name + version, with cache" | |
1698 | (find-packages-by-name "guile" "2") | |
1699 | (call-with-temporary-directory | |
1700 | (lambda (cache) | |
1701 | (generate-package-cache cache) | |
1702 | (mock ((guix describe) current-profile (const cache)) | |
1703 | (mock ((gnu packages) cache-is-authoritative? (const #t)) | |
1704 | (find-packages-by-name "guile" "2")))))) | |
1705 | ||
cf81a236 LC |
1706 | (test-assert "--search-paths with pattern" |
1707 | ;; Make sure 'guix package --search-paths' correctly reports environment | |
1708 | ;; variables when file patterns are used (in particular, it must follow | |
1709 | ;; symlinks when looking for 'catalog.xml'.) To do that, we rely on the | |
1710 | ;; libxml2 package specification, which contains such a definition. | |
1711 | (let* ((p1 (package | |
1712 | (name "foo") (version "0") (source #f) | |
1713 | (build-system trivial-build-system) | |
1714 | (arguments | |
1715 | `(#:guile ,%bootstrap-guile | |
1716 | #:modules ((guix build utils)) | |
1717 | #:builder (begin | |
1718 | (use-modules (guix build utils)) | |
1719 | (let ((out (assoc-ref %outputs "out"))) | |
1720 | (mkdir-p (string-append out "/xml/bar/baz")) | |
1721 | (call-with-output-file | |
1722 | (string-append out "/xml/bar/baz/catalog.xml") | |
1723 | (lambda (port) | |
1e868858 MW |
1724 | (display "xml? wat?!" port))) |
1725 | #t)))) | |
cf81a236 LC |
1726 | (synopsis #f) (description #f) |
1727 | (home-page #f) (license #f))) | |
1728 | (p2 (package | |
1729 | ;; Provide a fake libxml2 to avoid building the real one. This | |
1730 | ;; is OK because 'guix package' gets search path specifications | |
1731 | ;; from the same-named package found in the distro. | |
1732 | (name "libxml2") (version "0.0.0") (source #f) | |
1733 | (build-system trivial-build-system) | |
1734 | (arguments | |
1735 | `(#:guile ,%bootstrap-guile | |
1e868858 MW |
1736 | #:builder (begin |
1737 | (mkdir (assoc-ref %outputs "out")) | |
1738 | #t))) | |
cf81a236 LC |
1739 | (native-search-paths (package-native-search-paths libxml2)) |
1740 | (synopsis #f) (description #f) | |
1741 | (home-page #f) (license #f))) | |
1742 | (prof (run-with-store %store | |
1743 | (profile-derivation | |
1744 | (manifest (map package->manifest-entry | |
1745 | (list p1 p2))) | |
a6562c7e LC |
1746 | #:hooks '() |
1747 | #:locales? #f) | |
cf81a236 LC |
1748 | #:guile-for-build (%guile-for-build)))) |
1749 | (build-derivations %store (list prof)) | |
1750 | (string-match (format #f "^export XML_CATALOG_FILES=\"~a/xml/+bar/baz/catalog\\.xml\"\n" | |
77559f23 | 1751 | (regexp-quote (derivation->output-path prof))) |
cf81a236 LC |
1752 | (with-output-to-string |
1753 | (lambda () | |
1754 | (guix-package "-p" (derivation->output-path prof) | |
1755 | "--search-paths")))))) | |
1756 | ||
fcd75bdb LC |
1757 | (test-assert "--search-paths with single-item search path" |
1758 | ;; Make sure 'guix package --search-paths' correctly reports environment | |
1759 | ;; variables for things like 'GIT_SSL_CAINFO' that have #f as their | |
1760 | ;; separator, meaning that the first match wins. | |
1761 | (let* ((p1 (dummy-package "foo" | |
1762 | (build-system trivial-build-system) | |
1763 | (arguments | |
1764 | `(#:guile ,%bootstrap-guile | |
1765 | #:modules ((guix build utils)) | |
1766 | #:builder (begin | |
1767 | (use-modules (guix build utils)) | |
1768 | (let ((out (assoc-ref %outputs "out"))) | |
1769 | (mkdir-p (string-append out "/etc/ssl/certs")) | |
1770 | (call-with-output-file | |
1771 | (string-append | |
1772 | out "/etc/ssl/certs/ca-certificates.crt") | |
1773 | (const #t)))))))) | |
1774 | (p2 (package (inherit p1) (name "bar"))) | |
1775 | (p3 (dummy-package "git" | |
1776 | ;; Provide a fake Git to avoid building the real one. | |
1777 | (build-system trivial-build-system) | |
1778 | (arguments | |
1779 | `(#:guile ,%bootstrap-guile | |
1e868858 MW |
1780 | #:builder (begin |
1781 | (mkdir (assoc-ref %outputs "out")) | |
1782 | #t))) | |
fcd75bdb LC |
1783 | (native-search-paths (package-native-search-paths git)))) |
1784 | (prof1 (run-with-store %store | |
1785 | (profile-derivation | |
1786 | (packages->manifest (list p1 p3)) | |
1787 | #:hooks '() | |
1788 | #:locales? #f) | |
1789 | #:guile-for-build (%guile-for-build))) | |
1790 | (prof2 (run-with-store %store | |
1791 | (profile-derivation | |
1792 | (packages->manifest (list p2 p3)) | |
1793 | #:hooks '() | |
1794 | #:locales? #f) | |
1795 | #:guile-for-build (%guile-for-build)))) | |
1796 | (build-derivations %store (list prof1 prof2)) | |
1797 | (string-match (format #f "^export GIT_SSL_CAINFO=\"~a/etc/ssl/certs/ca-certificates.crt" | |
1798 | (regexp-quote (derivation->output-path prof1))) | |
1799 | (with-output-to-string | |
1800 | (lambda () | |
1801 | (guix-package "-p" (derivation->output-path prof1) | |
1802 | "-p" (derivation->output-path prof2) | |
1803 | "--search-paths")))))) | |
1804 | ||
efb107e0 LC |
1805 | (test-equal "specification->package when not found" |
1806 | 'quit | |
1807 | (catch 'quit | |
1808 | (lambda () | |
1809 | ;; This should call 'leave', producing an error message. | |
1810 | (specification->package "this-package-does-not-exist")) | |
1811 | (lambda (key . args) | |
1812 | key))) | |
1813 | ||
066eeae1 LC |
1814 | (test-equal "specification->package+output" |
1815 | `((,coreutils "out") (,coreutils "debug")) | |
1816 | (list (call-with-values (lambda () | |
1817 | (specification->package+output "coreutils")) | |
1818 | list) | |
1819 | (call-with-values (lambda () | |
1820 | (specification->package+output "coreutils:debug")) | |
1821 | list))) | |
1822 | ||
1823 | (test-equal "specification->package+output invalid output" | |
1824 | 'error | |
1825 | (catch 'quit | |
1826 | (lambda () | |
1827 | (specification->package+output "coreutils:does-not-exist")) | |
1828 | (lambda _ | |
1829 | 'error))) | |
1830 | ||
1831 | (test-equal "specification->package+output no default output" | |
1832 | `(,coreutils #f) | |
1833 | (call-with-values | |
1834 | (lambda () | |
1835 | (specification->package+output "coreutils" #f)) | |
1836 | list)) | |
1837 | ||
1838 | (test-equal "specification->package+output invalid output, no default" | |
1839 | 'error | |
1840 | (catch 'quit | |
1841 | (lambda () | |
1842 | (specification->package+output "coreutils:does-not-exist" #f)) | |
1843 | (lambda _ | |
1844 | 'error))) | |
1845 | ||
ee8099f5 LC |
1846 | (test-equal "find-package-locations" |
1847 | (map (lambda (package) | |
1848 | (cons (package-version package) | |
1849 | (package-location package))) | |
1850 | (find-packages-by-name "guile")) | |
1851 | (find-package-locations "guile")) | |
1852 | ||
1853 | (test-equal "find-package-locations with cache" | |
1854 | (map (lambda (package) | |
1855 | (cons (package-version package) | |
1856 | (package-location package))) | |
1857 | (find-packages-by-name "guile")) | |
1858 | (call-with-temporary-directory | |
1859 | (lambda (cache) | |
1860 | (generate-package-cache cache) | |
1861 | (mock ((guix describe) current-profile (const cache)) | |
1862 | (mock ((gnu packages) cache-is-authoritative? (const #t)) | |
1863 | (find-package-locations "guile")))))) | |
1864 | ||
1865 | (test-equal "specification->location" | |
1866 | (package-location (specification->package "guile@2")) | |
1867 | (specification->location "guile@2")) | |
1868 | ||
e3ce5d70 LC |
1869 | (test-end "packages") |
1870 | ||
e3ce5d70 | 1871 | ;;; Local Variables: |
a3d73f59 | 1872 | ;;; eval: (put 'dummy-package 'scheme-indent-function 1) |
3e223a22 | 1873 | ;;; eval: (put 'dummy-package/no-implicit 'scheme-indent-function 1) |
e3ce5d70 | 1874 | ;;; End: |