gexp: Export 'gexp-input' constructor.
[jackhill/guix/guix.git] / tests / gexp.scm
CommitLineData
21b679f6 1;;; GNU Guix --- Functional package management for GNU
462a3fa3 2;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
21b679f6
LC
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (test-gexp)
20 #:use-module (guix store)
21 #:use-module (guix monads)
22 #:use-module (guix gexp)
23 #:use-module (guix derivations)
79c0c8cd 24 #:use-module (guix packages)
c1bc358f 25 #:use-module (guix tests)
21b679f6
LC
26 #:use-module (gnu packages)
27 #:use-module (gnu packages base)
28 #:use-module (gnu packages bootstrap)
29 #:use-module (srfi srfi-1)
c8351d9a 30 #:use-module (srfi srfi-34)
21b679f6
LC
31 #:use-module (srfi srfi-64)
32 #:use-module (rnrs io ports)
33 #:use-module (ice-9 match)
2cf0ea0d 34 #:use-module (ice-9 regex)
21b679f6
LC
35 #:use-module (ice-9 popen))
36
37;; Test the (guix gexp) module.
38
39(define %store
c1bc358f 40 (open-connection-for-tests))
21b679f6
LC
41
42;; For white-box testing.
1f976033
LC
43(define (gexp-inputs x)
44 ((@@ (guix gexp) gexp-inputs) x))
45(define (gexp-native-inputs x)
46 ((@@ (guix gexp) gexp-native-inputs) x))
47(define (gexp-outputs x)
48 ((@@ (guix gexp) gexp-outputs) x))
49(define (gexp->sexp . x)
50 (apply (@@ (guix gexp) gexp->sexp) x))
21b679f6 51
667b2508 52(define* (gexp->sexp* exp #:optional target)
68a61e9f 53 (run-with-store %store (gexp->sexp exp
68a61e9f 54 #:target target)
c1bc358f 55 #:guile-for-build (%guile-for-build)))
21b679f6
LC
56
57(define-syntax-rule (test-assertm name exp)
58 (test-assert name
59 (run-with-store %store exp
c1bc358f 60 #:guile-for-build (%guile-for-build))))
21b679f6
LC
61
62\f
63(test-begin "gexp")
64
65(test-equal "no refs"
66 '(display "hello!")
67 (let ((exp (gexp (display "hello!"))))
68 (and (gexp? exp)
69 (null? (gexp-inputs exp))
70 (gexp->sexp* exp))))
71
72(test-equal "unquote"
73 '(display `(foo ,(+ 2 3)))
74 (let ((exp (gexp (display `(foo ,(+ 2 3))))))
75 (and (gexp? exp)
76 (null? (gexp-inputs exp))
77 (gexp->sexp* exp))))
78
79(test-assert "one input package"
80 (let ((exp (gexp (display (ungexp coreutils)))))
81 (and (gexp? exp)
82 (match (gexp-inputs exp)
83 (((p "out"))
84 (eq? p coreutils)))
85 (equal? `(display ,(derivation->output-path
86 (package-derivation %store coreutils)))
87 (gexp->sexp* exp)))))
88
79c0c8cd
LC
89(test-assert "one input origin"
90 (let ((exp (gexp (display (ungexp (package-source coreutils))))))
91 (and (gexp? exp)
92 (match (gexp-inputs exp)
93 (((o "out"))
94 (eq? o (package-source coreutils))))
95 (equal? `(display ,(derivation->output-path
96 (package-source-derivation
97 %store (package-source coreutils))))
98 (gexp->sexp* exp)))))
99
21b679f6
LC
100(test-assert "same input twice"
101 (let ((exp (gexp (begin
102 (display (ungexp coreutils))
103 (display (ungexp coreutils))))))
104 (and (gexp? exp)
105 (match (gexp-inputs exp)
106 (((p "out"))
107 (eq? p coreutils)))
108 (let ((e `(display ,(derivation->output-path
109 (package-derivation %store coreutils)))))
110 (equal? `(begin ,e ,e) (gexp->sexp* exp))))))
111
112(test-assert "two input packages, one derivation, one file"
113 (let* ((drv (build-expression->derivation
114 %store "foo" 'bar
115 #:guile-for-build (package-derivation %store %bootstrap-guile)))
116 (txt (add-text-to-store %store "foo" "Hello, world!"))
117 (exp (gexp (begin
118 (display (ungexp coreutils))
119 (display (ungexp %bootstrap-guile))
120 (display (ungexp drv))
121 (display (ungexp txt))))))
122 (define (match-input thing)
123 (match-lambda
124 ((drv-or-pkg _ ...)
125 (eq? thing drv-or-pkg))))
126
127 (and (gexp? exp)
128 (= 4 (length (gexp-inputs exp)))
129 (every (lambda (input)
130 (find (match-input input) (gexp-inputs exp)))
131 (list drv coreutils %bootstrap-guile txt))
132 (let ((e0 `(display ,(derivation->output-path
133 (package-derivation %store coreutils))))
134 (e1 `(display ,(derivation->output-path
135 (package-derivation %store %bootstrap-guile))))
136 (e2 `(display ,(derivation->output-path drv)))
137 (e3 `(display ,txt)))
138 (equal? `(begin ,e0 ,e1 ,e2 ,e3) (gexp->sexp* exp))))))
139
667b2508
LC
140(test-assert "ungexp + ungexp-native"
141 (let* ((exp (gexp (list (ungexp-native %bootstrap-guile)
142 (ungexp coreutils)
143 (ungexp-native glibc)
144 (ungexp binutils))))
145 (target "mips64el-linux")
146 (guile (derivation->output-path
147 (package-derivation %store %bootstrap-guile)))
148 (cu (derivation->output-path
149 (package-cross-derivation %store coreutils target)))
150 (libc (derivation->output-path
151 (package-derivation %store glibc)))
152 (bu (derivation->output-path
153 (package-cross-derivation %store binutils target))))
154 (and (lset= equal?
155 `((,%bootstrap-guile "out") (,glibc "out"))
156 (gexp-native-inputs exp))
157 (lset= equal?
158 `((,coreutils "out") (,binutils "out"))
159 (gexp-inputs exp))
160 (equal? `(list ,guile ,cu ,libc ,bu)
161 (gexp->sexp* exp target)))))
162
21b679f6
LC
163(test-assert "input list"
164 (let ((exp (gexp (display
165 '(ungexp (list %bootstrap-guile coreutils)))))
166 (guile (derivation->output-path
167 (package-derivation %store %bootstrap-guile)))
168 (cu (derivation->output-path
169 (package-derivation %store coreutils))))
170 (and (lset= equal?
171 `((,%bootstrap-guile "out") (,coreutils "out"))
172 (gexp-inputs exp))
173 (equal? `(display '(,guile ,cu))
174 (gexp->sexp* exp)))))
175
667b2508
LC
176(test-assert "input list + ungexp-native"
177 (let* ((target "mips64el-linux")
178 (exp (gexp (display
179 (cons '(ungexp-native (list %bootstrap-guile coreutils))
180 '(ungexp (list glibc binutils))))))
181 (guile (derivation->output-path
182 (package-derivation %store %bootstrap-guile)))
183 (cu (derivation->output-path
184 (package-derivation %store coreutils)))
185 (xlibc (derivation->output-path
186 (package-cross-derivation %store glibc target)))
187 (xbu (derivation->output-path
188 (package-cross-derivation %store binutils target))))
189 (and (lset= equal?
190 `((,%bootstrap-guile "out") (,coreutils "out"))
191 (gexp-native-inputs exp))
192 (lset= equal?
193 `((,glibc "out") (,binutils "out"))
194 (gexp-inputs exp))
195 (equal? `(display (cons '(,guile ,cu) '(,xlibc ,xbu)))
196 (gexp->sexp* exp target)))))
197
21b679f6
LC
198(test-assert "input list splicing"
199 (let* ((inputs (list (list glibc "debug") %bootstrap-guile))
200 (outputs (list (derivation->output-path
201 (package-derivation %store glibc)
202 "debug")
203 (derivation->output-path
204 (package-derivation %store %bootstrap-guile))))
205 (exp (gexp (list (ungexp-splicing (cons (+ 2 3) inputs))))))
206 (and (lset= equal?
207 `((,glibc "debug") (,%bootstrap-guile "out"))
208 (gexp-inputs exp))
209 (equal? (gexp->sexp* exp)
210 `(list ,@(cons 5 outputs))))))
211
667b2508
LC
212(test-assert "input list splicing + ungexp-native-splicing"
213 (let* ((inputs (list (list glibc "debug") %bootstrap-guile))
214 (exp (gexp (list (ungexp-native-splicing (cons (+ 2 3) inputs))))))
215 (and (lset= equal?
216 `((,glibc "debug") (,%bootstrap-guile "out"))
217 (gexp-native-inputs exp))
218 (null? (gexp-inputs exp))
219 (equal? (gexp->sexp* exp) ;native
220 (gexp->sexp* exp "mips64el-linux")))))
221
0dbea56b
LC
222(test-assert "input list splicing + gexp-input + ungexp-native-splicing"
223 (let* ((inputs (list (gexp-input glibc "debug") %bootstrap-guile))
224 (exp (gexp (list (ungexp-native-splicing (cons (+ 2 3) inputs))))))
225 (and (lset= equal?
226 `((,glibc "debug") (,%bootstrap-guile "out"))
227 (gexp-native-inputs exp))
228 (null? (gexp-inputs exp))
229 (equal? (gexp->sexp* exp) ;native
230 (gexp->sexp* exp "mips64el-linux")))))
231
4b23c466
LC
232(test-equal "output list"
233 2
234 (let ((exp (gexp (begin (mkdir (ungexp output))
235 (mkdir (ungexp output "bar"))))))
236 (length (gexp-outputs exp)))) ;XXX: <output-ref> is private
237
238(test-assert "output list, combined gexps"
239 (let* ((exp0 (gexp (mkdir (ungexp output))))
240 (exp1 (gexp (mkdir (ungexp output "foo"))))
241 (exp2 (gexp (begin (display "hi!") (ungexp exp0) (ungexp exp1)))))
242 (and (lset= equal?
243 (append (gexp-outputs exp0) (gexp-outputs exp1))
244 (gexp-outputs exp2))
245 (= 2 (length (gexp-outputs exp2))))))
246
7e75a673
LC
247(test-equal "output list, combined gexps, duplicate output"
248 1
249 (let* ((exp0 (gexp (mkdir (ungexp output))))
250 (exp1 (gexp (begin (mkdir (ungexp output)) (ungexp exp0))))
251 (exp2 (gexp (begin (mkdir (ungexp output)) (ungexp exp1)))))
252 (length (gexp-outputs exp2))))
253
f9efe568
LC
254(test-assert "output list + ungexp-splicing list, combined gexps"
255 (let* ((exp0 (gexp (mkdir (ungexp output))))
256 (exp1 (gexp (mkdir (ungexp output "foo"))))
257 (exp2 (gexp (begin (display "hi!")
258 (ungexp-splicing (list exp0 exp1))))))
259 (and (lset= equal?
260 (append (gexp-outputs exp0) (gexp-outputs exp1))
261 (gexp-outputs exp2))
262 (= 2 (length (gexp-outputs exp2))))))
263
21b679f6
LC
264(test-assertm "gexp->file"
265 (mlet* %store-monad ((exp -> (gexp (display (ungexp %bootstrap-guile))))
266 (guile (package-file %bootstrap-guile))
267 (sexp (gexp->sexp exp))
268 (drv (gexp->file "foo" exp))
269 (out -> (derivation->output-path drv))
270 (done (built-derivations (list drv)))
271 (refs ((store-lift references) out)))
272 (return (and (equal? sexp (call-with-input-file out read))
273 (equal? (list guile) refs)))))
274
275(test-assertm "gexp->derivation"
276 (mlet* %store-monad ((file (text-file "foo" "Hello, world!"))
277 (exp -> (gexp
278 (begin
279 (mkdir (ungexp output))
280 (chdir (ungexp output))
281 (symlink
282 (string-append (ungexp %bootstrap-guile)
283 "/bin/guile")
284 "foo")
285 (symlink (ungexp file)
286 (ungexp output "2nd")))))
287 (drv (gexp->derivation "foo" exp))
288 (out -> (derivation->output-path drv))
289 (out2 -> (derivation->output-path drv "2nd"))
290 (done (built-derivations (list drv)))
291 (refs ((store-lift references) out))
292 (refs2 ((store-lift references) out2))
293 (guile (package-file %bootstrap-guile "bin/guile")))
294 (return (and (string=? (readlink (string-append out "/foo")) guile)
295 (string=? (readlink out2) file)
296 (equal? refs (list (dirname (dirname guile))))
297 (equal? refs2 (list file))))))
298
ce45eb4c
LC
299(test-assertm "gexp->derivation vs. grafts"
300 (mlet* %store-monad ((p0 -> (dummy-package "dummy"
301 (arguments
302 '(#:implicit-inputs? #f))))
303 (r -> (package (inherit p0) (name "DuMMY")))
304 (p1 -> (package (inherit p0) (replacement r)))
305 (exp0 -> (gexp (frob (ungexp p0) (ungexp output))))
306 (exp1 -> (gexp (frob (ungexp p1) (ungexp output))))
307 (void (set-guile-for-build %bootstrap-guile))
308 (drv0 (gexp->derivation "t" exp0))
309 (drv1 (gexp->derivation "t" exp1))
310 (drv1* (gexp->derivation "t" exp1 #:graft? #f)))
311 (return (and (not (string=? (derivation->output-path drv0)
312 (derivation->output-path drv1)))
313 (string=? (derivation->output-path drv0)
314 (derivation->output-path drv1*))))))
315
21b679f6
LC
316(test-assertm "gexp->derivation, composed gexps"
317 (mlet* %store-monad ((exp0 -> (gexp (begin
318 (mkdir (ungexp output))
319 (chdir (ungexp output)))))
320 (exp1 -> (gexp (symlink
321 (string-append (ungexp %bootstrap-guile)
322 "/bin/guile")
323 "foo")))
324 (exp -> (gexp (begin (ungexp exp0) (ungexp exp1))))
325 (drv (gexp->derivation "foo" exp))
326 (out -> (derivation->output-path drv))
327 (done (built-derivations (list drv)))
328 (guile (package-file %bootstrap-guile "bin/guile")))
329 (return (string=? (readlink (string-append out "/foo"))
330 guile))))
331
5d098459
LC
332(test-assertm "gexp->derivation, default system"
333 ;; The default system should be the one at '>>=' time, not the one at
334 ;; invocation time. See <http://bugs.gnu.org/18002>.
335 (let ((system (%current-system))
336 (mdrv (parameterize ((%current-system "foobar64-linux"))
337 (gexp->derivation "foo"
338 (gexp
339 (mkdir (ungexp output)))))))
340 (mlet %store-monad ((drv mdrv))
341 (return (string=? system (derivation-system drv))))))
342
68a61e9f
LC
343(test-assertm "gexp->derivation, cross-compilation"
344 (mlet* %store-monad ((target -> "mips64el-linux")
345 (exp -> (gexp (list (ungexp coreutils)
346 (ungexp output))))
347 (xdrv (gexp->derivation "foo" exp
348 #:target target))
349 (refs ((store-lift references)
350 (derivation-file-name xdrv)))
351 (xcu (package->cross-derivation coreutils
352 target))
353 (cu (package->derivation coreutils)))
354 (return (and (member (derivation-file-name xcu) refs)
355 (not (member (derivation-file-name cu) refs))))))
356
667b2508
LC
357(test-assertm "gexp->derivation, ungexp-native"
358 (mlet* %store-monad ((target -> "mips64el-linux")
359 (exp -> (gexp (list (ungexp-native coreutils)
360 (ungexp output))))
361 (xdrv (gexp->derivation "foo" exp
362 #:target target))
363 (drv (gexp->derivation "foo" exp)))
364 (return (string=? (derivation-file-name drv)
365 (derivation-file-name xdrv)))))
366
367(test-assertm "gexp->derivation, ungexp + ungexp-native"
368 (mlet* %store-monad ((target -> "mips64el-linux")
369 (exp -> (gexp (list (ungexp-native coreutils)
370 (ungexp glibc)
371 (ungexp output))))
372 (xdrv (gexp->derivation "foo" exp
373 #:target target))
374 (refs ((store-lift references)
375 (derivation-file-name xdrv)))
376 (xglibc (package->cross-derivation glibc target))
377 (cu (package->derivation coreutils)))
378 (return (and (member (derivation-file-name cu) refs)
379 (member (derivation-file-name xglibc) refs)))))
380
381(test-assertm "gexp->derivation, ungexp-native + composed gexps"
382 (mlet* %store-monad ((target -> "mips64el-linux")
383 (exp0 -> (gexp (list 1 2
384 (ungexp coreutils))))
385 (exp -> (gexp (list 0 (ungexp-native exp0))))
386 (xdrv (gexp->derivation "foo" exp
387 #:target target))
388 (drv (gexp->derivation "foo" exp)))
389 (return (string=? (derivation-file-name drv)
390 (derivation-file-name xdrv)))))
391
6fd1a796
LC
392(test-assertm "gexp->derivation, store copy"
393 (let ((build-one #~(call-with-output-file #$output
394 (lambda (port)
395 (display "This is the one." port))))
396 (build-two (lambda (one)
397 #~(begin
398 (mkdir #$output)
399 (symlink #$one (string-append #$output "/one"))
400 (call-with-output-file (string-append #$output "/two")
401 (lambda (port)
402 (display "This is the second one." port))))))
b53833b2
LC
403 (build-drv #~(begin
404 (use-modules (guix build store-copy))
6fd1a796 405
b53833b2
LC
406 (mkdir #$output)
407 (populate-store '("graph") #$output))))
6fd1a796
LC
408 (mlet* %store-monad ((one (gexp->derivation "one" build-one))
409 (two (gexp->derivation "two" (build-two one)))
b53833b2 410 (drv (gexp->derivation "store-copy" build-drv
6fd1a796 411 #:references-graphs
b53833b2 412 `(("graph" ,two))
6fd1a796
LC
413 #:modules
414 '((guix build store-copy)
415 (guix build utils))))
416 (ok? (built-derivations (list drv)))
417 (out -> (derivation->output-path drv)))
418 (let ((one (derivation->output-path one))
419 (two (derivation->output-path two)))
420 (return (and ok?
421 (file-exists? (string-append out "/" one))
422 (file-exists? (string-append out "/" two))
423 (file-exists? (string-append out "/" two "/two"))
424 (string=? (readlink (string-append out "/" two "/one"))
425 one)))))))
426
aa72d9af
LC
427(test-assertm "imported-files"
428 (mlet* %store-monad
429 ((files -> `(("x" . ,(search-path %load-path "ice-9/q.scm"))
430 ("a/b/c" . ,(search-path %load-path
431 "guix/derivations.scm"))
432 ("p/q" . ,(search-path %load-path "guix.scm"))
433 ("p/z" . ,(search-path %load-path "guix/store.scm"))))
434 (drv (imported-files files)))
435 (mbegin %store-monad
436 (built-derivations (list drv))
437 (let ((dir (derivation->output-path drv)))
438 (return
439 (every (match-lambda
440 ((path . source)
441 (equal? (call-with-input-file (string-append dir "/" path)
442 get-bytevector-all)
443 (call-with-input-file source
444 get-bytevector-all))))
445 files))))))
446
447(test-assertm "gexp->derivation #:modules"
448 (mlet* %store-monad
449 ((build -> #~(begin
450 (use-modules (guix build utils))
451 (mkdir-p (string-append #$output "/guile/guix/nix"))
452 #t))
453 (drv (gexp->derivation "test-with-modules" build
454 #:modules '((guix build utils)))))
455 (mbegin %store-monad
456 (built-derivations (list drv))
457 (let* ((p (derivation->output-path drv))
458 (s (stat (string-append p "/guile/guix/nix"))))
459 (return (eq? (stat:type s) 'directory))))))
460
b53833b2
LC
461(test-assertm "gexp->derivation #:references-graphs"
462 (mlet* %store-monad
463 ((one (text-file "one" "hello, world"))
464 (two (gexp->derivation "two"
465 #~(symlink #$one #$output:chbouib)))
466 (drv (gexp->derivation "ref-graphs"
467 #~(begin
468 (use-modules (guix build store-copy))
469 (with-output-to-file #$output
470 (lambda ()
471 (write (call-with-input-file "guile"
472 read-reference-graph))))
473 (with-output-to-file #$output:one
474 (lambda ()
475 (write (call-with-input-file "one"
476 read-reference-graph))))
477 (with-output-to-file #$output:two
478 (lambda ()
479 (write (call-with-input-file "two"
480 read-reference-graph)))))
481 #:references-graphs `(("one" ,one)
482 ("two" ,two "chbouib")
483 ("guile" ,%bootstrap-guile))
484 #:modules '((guix build store-copy)
485 (guix build utils))))
486 (ok? (built-derivations (list drv)))
487 (guile-drv (package->derivation %bootstrap-guile))
488 (g-one -> (derivation->output-path drv "one"))
489 (g-two -> (derivation->output-path drv "two"))
490 (g-guile -> (derivation->output-path drv)))
491 (return (and ok?
492 (equal? (call-with-input-file g-one read) (list one))
493 (equal? (call-with-input-file g-two read)
494 (list one (derivation->output-path two "chbouib")))
495 (equal? (call-with-input-file g-guile read)
496 (list (derivation->output-path guile-drv)))))))
497
c8351d9a
LC
498(test-assertm "gexp->derivation #:allowed-references"
499 (mlet %store-monad ((drv (gexp->derivation "allowed-refs"
500 #~(begin
501 (mkdir #$output)
502 (chdir #$output)
503 (symlink #$output "self")
504 (symlink #$%bootstrap-guile
505 "guile"))
506 #:allowed-references
507 (list "out" %bootstrap-guile))))
508 (built-derivations (list drv))))
509
510(test-assert "gexp->derivation #:allowed-references, disallowed"
511 (let ((drv (run-with-store %store
512 (gexp->derivation "allowed-refs"
513 #~(begin
514 (mkdir #$output)
515 (chdir #$output)
516 (symlink #$%bootstrap-guile "guile"))
517 #:allowed-references '()))))
518 (guard (c ((nix-protocol-error? c) #t))
519 (build-derivations %store (list drv))
520 #f)))
521
c17b5ab4 522(define shebang
c1bc358f 523 (string-append "#!" (derivation->output-path (%guile-for-build))
c17b5ab4
LC
524 "/bin/guile --no-auto-compile"))
525
526;; If we're going to hit the silly shebang limit (128 chars on Linux-based
527;; systems), then skip the following test.
528(test-skip (if (> (string-length shebang) 127) 1 0))
529
21b679f6
LC
530(test-assertm "gexp->script"
531 (mlet* %store-monad ((n -> (random (expt 2 50)))
532 (exp -> (gexp
533 (system*
534 (string-append (ungexp %bootstrap-guile)
535 "/bin/guile")
536 "-c" (object->string
537 '(display (expt (ungexp n) 2))))))
538 (drv (gexp->script "guile-thing" exp
539 #:guile %bootstrap-guile))
540 (out -> (derivation->output-path drv))
541 (done (built-derivations (list drv))))
542 (let* ((pipe (open-input-pipe out))
543 (str (get-string-all pipe)))
544 (return (and (zero? (close-pipe pipe))
545 (= (expt n 2) (string->number str)))))))
546
462a3fa3
LC
547(test-assert "text-file*"
548 (let ((references (store-lift references)))
549 (run-with-store %store
550 (mlet* %store-monad
551 ((drv (package->derivation %bootstrap-guile))
552 (guile -> (derivation->output-path drv))
553 (file (text-file "bar" "This is bar."))
554 (text (text-file* "foo"
555 %bootstrap-guile "/bin/guile "
556 `(,%bootstrap-guile "out") "/bin/guile "
557 drv "/bin/guile "
558 file))
559 (done (built-derivations (list text)))
560 (out -> (derivation->output-path text))
561 (refs (references out)))
562 ;; Make sure we get the right references and the right content.
563 (return (and (lset= string=? refs (list guile file))
564 (equal? (call-with-input-file out get-string-all)
565 (string-append guile "/bin/guile "
566 guile "/bin/guile "
567 guile "/bin/guile "
568 file)))))
569 #:guile-for-build (package-derivation %store %bootstrap-guile))))
570
2cf0ea0d
LC
571(test-assert "printer"
572 (string-match "^#<gexp \\(string-append .*#<package coreutils.*\
573 \"/bin/uname\"\\) [[:xdigit:]]+>$"
574 (with-output-to-string
575 (lambda ()
576 (write
577 (gexp (string-append (ungexp coreutils)
578 "/bin/uname")))))))
579
580(test-assert "printer vs. ungexp-splicing"
581 (string-match "^#<gexp .* [[:xdigit:]]+>$"
582 (with-output-to-string
583 (lambda ()
584 ;; #~(begin #$@#~())
585 (write
586 (gexp (begin (ungexp-splicing (gexp ())))))))))
587
21b679f6
LC
588(test-equal "sugar"
589 '(gexp (foo (ungexp bar) (ungexp baz "out")
590 (ungexp (chbouib 42))
667b2508
LC
591 (ungexp-splicing (list x y z))
592 (ungexp-native foo) (ungexp-native foo "out")
593 (ungexp-native (chbouib 42))
594 (ungexp-native-splicing (list x y z))))
595 '#~(foo #$bar #$baz:out #$(chbouib 42) #$@(list x y z)
596 #+foo #+foo:out #+(chbouib 42) #+@(list x y z)))
21b679f6
LC
597
598(test-end "gexp")
599
600\f
601(exit (= (test-runner-fail-count (test-runner-current)) 0))
602
603;; Local Variables:
604;; eval: (put 'test-assertm 'scheme-indent-function 1)
605;; End: