%%%% Starting test derivations Group begin: derivations Test begin: test-name: "parse & export" source-file: "tests/derivations.scm" source-line: 84 source-form: (test-assert "parse & export" (let* ((f (search-path %load-path "tests/test.drv")) (b1 (call-with-input-file f get-bytevector-all)) (d1 (read-derivation (open-bytevector-input-port b1))) (b2 (call-with-bytevector-output-port (cut write-derivation d1 <>))) (d2 (read-derivation (open-bytevector-input-port b2)))) (and (equal? b1 b2) (equal? d1 d2)))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "add-to-store, flat" source-file: "tests/derivations.scm" source-line: 95 source-form: (test-assert "add-to-store, flat" (let* ((file (search-path %load-path "language/tree-il/spec.scm")) (drv (add-to-store %store "flat-test" #f "sha256" file))) (and (eq? (quote regular) (stat:type (stat drv))) (valid-path? %store drv) (equal? (call-with-input-file file get-bytevector-all) (call-with-input-file drv get-bytevector-all))))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "add-to-store, recursive" source-file: "tests/derivations.scm" source-line: 103 source-form: (test-assert "add-to-store, recursive" (let* ((dir (dirname (search-path %load-path "language/tree-il/spec.scm"))) (drv (add-to-store %store "dir-tree-test" #t "sha256" dir))) (and (eq? (quote directory) (stat:type (stat drv))) (valid-path? %store drv) (equal? (directory-contents dir) (directory-contents drv))))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "derivation with no inputs" source-file: "tests/derivations.scm" source-line: 111 source-form: (test-assert "derivation with no inputs" (let* ((builder (add-text-to-store %store "my-builder.sh" "echo hello, world\n" (quote ()))) (drv (derivation %store "foo" %bash (quasiquote ("-e" (unquote builder))) #:env-vars (quote (("HOME" . "/homeless")))))) (and (store-path? (derivation-file-name drv)) (valid-path? %store (derivation-file-name drv))))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "build derivation with 1 source" source-file: "tests/derivations.scm" source-line: 121 source-form: (test-assert "build derivation with 1 source" (let* ((builder (add-text-to-store %store "my-builder.sh" "echo hello, world > \"$out\"\n" (quote ()))) (drv (derivation %store "foo" %bash (quasiquote ((unquote builder))) #:env-vars (quote (("HOME" . "/homeless") ("zzz" . "Z!") ("AAA" . "A!"))) #:inputs (quasiquote (((unquote %bash)) ((unquote builder)))))) (succeeded? (build-derivations %store (list drv)))) (and succeeded? (let ((path (derivation->output-path drv))) (and (valid-path? %store path) (string=? (call-with-input-file path read-line) "hello, world")))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "derivation with local file as input" source-file: "tests/derivations.scm" source-line: 139 source-form: (test-assert "derivation with local file as input" (let* ((builder (add-text-to-store %store "my-builder.sh" "(while read line ; do echo \"$line\" ; done) < $in > $out" (quote ()))) (input (search-path %load-path "ice-9/boot-9.scm")) (input* (add-to-store %store (basename input) #t "sha256" input)) (drv (derivation %store "derivation-with-input-file" %bash (quasiquote ((unquote builder))) #:env-vars (quasiquote (("in" unquote input*))) #:inputs (quasiquote (((unquote %bash)) ((unquote builder)) ((unquote input))))))) (and (build-derivations %store (list drv)) (valid-path? %store (derivation->output-path drv))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "fixed-output-derivation?" source-file: "tests/derivations.scm" source-line: 162 source-form: (test-assert "fixed-output-derivation?" (let* ((builder (add-text-to-store %store "my-fixed-builder.sh" "echo -n hello > $out" (quote ()))) (hash (sha256 (string->utf8 "hello"))) (drv (derivation %store "fixed" %bash (quasiquote ((unquote builder))) #:inputs (quasiquote (((unquote builder)))) #:hash hash #:hash-algo (quote sha256)))) (fixed-output-derivation? drv))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "fixed-output derivation" source-file: "tests/derivations.scm" source-line: 172 source-form: (test-assert "fixed-output derivation" (let* ((builder (add-text-to-store %store "my-fixed-builder.sh" "echo -n hello > $out" (quote ()))) (hash (sha256 (string->utf8 "hello"))) (drv (derivation %store "fixed" %bash (quasiquote ((unquote builder))) #:inputs (quasiquote (((unquote builder)))) #:hash hash #:hash-algo (quote sha256))) (succeeded? (build-derivations %store (list drv)))) (and succeeded? (let ((p (derivation->output-path drv))) (and (equal? (string->utf8 "hello") (call-with-input-file p get-bytevector-all)) (bytevector? (query-path-hash %store p))))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "fixed-output derivation: output paths are equal" source-file: "tests/derivations.scm" source-line: 187 source-form: (test-assert "fixed-output derivation: output paths are equal" (let* ((builder1 (add-text-to-store %store "fixed-builder1.sh" "echo -n hello > $out" (quote ()))) (builder2 (add-text-to-store %store "fixed-builder2.sh" "echo hey; echo -n hello > $out" (quote ()))) (hash (sha256 (string->utf8 "hello"))) (drv1 (derivation %store "fixed" %bash (quasiquote ((unquote builder1))) #:hash hash #:hash-algo (quote sha256))) (drv2 (derivation %store "fixed" %bash (quasiquote ((unquote builder2))) #:hash hash #:hash-algo (quote sha256))) (succeeded? (build-derivations %store (list drv1 drv2)))) (and succeeded? (equal? (derivation->output-path drv1) (derivation->output-path drv2))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "fixed-output derivation, recursive" source-file: "tests/derivations.scm" source-line: 204 source-form: (test-assert "fixed-output derivation, recursive" (let* ((builder (add-text-to-store %store "my-fixed-builder.sh" "echo -n hello > $out" (quote ()))) (hash (sha256 (string->utf8 "hello"))) (drv (derivation %store "fixed-rec" %bash (quasiquote ((unquote builder))) #:inputs (quasiquote (((unquote builder)))) #:hash (base32 "0sg9f58l1jj88w6pdrfdpj5x9b1zrwszk84j81zvby36q9whhhqa") #:hash-algo (quote sha256) #:recursive? #t)) (succeeded? (build-derivations %store (list drv)))) (and succeeded? (let ((p (derivation->output-path drv))) (and (equal? (string->utf8 "hello") (call-with-input-file p get-bytevector-all)) (bytevector? (query-path-hash %store p))))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "derivation with a fixed-output input" source-file: "tests/derivations.scm" source-line: 221 source-form: (test-assert "derivation with a fixed-output input" (let* ((builder1 (add-text-to-store %store "fixed-builder1.sh" "echo -n hello > $out" (quote ()))) (builder2 (add-text-to-store %store "fixed-builder2.sh" "echo hey; echo -n hello > $out" (quote ()))) (hash (sha256 (string->utf8 "hello"))) (fixed1 (derivation %store "fixed" %bash (quasiquote ((unquote builder1))) #:hash hash #:hash-algo (quote sha256))) (fixed2 (derivation %store "fixed" %bash (quasiquote ((unquote builder2))) #:hash hash #:hash-algo (quote sha256))) (fixed-out (derivation->output-path fixed1)) (builder3 (add-text-to-store %store "final-builder.sh" "echo $in ; (read -u 3 c; echo $c) 3< $in > $out" (quote ()))) (final1 (derivation %store "final" %bash (quasiquote ((unquote builder3))) #:env-vars (quasiquote (("in" unquote fixed-out))) #:inputs (quasiquote (((unquote %bash)) ((unquote builder3)) ((unquote fixed1)))))) (final2 (derivation %store "final" %bash (quasiquote ((unquote builder3))) #:env-vars (quasiquote (("in" unquote fixed-out))) #:inputs (quasiquote (((unquote %bash)) ((unquote builder3)) ((unquote fixed2)))))) (succeeded? (build-derivations %store (list final1 final2)))) (and succeeded? (equal? (derivation->output-path final1) (derivation->output-path final2))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "multiple-output derivation" source-file: "tests/derivations.scm" source-line: 255 source-form: (test-assert "multiple-output derivation" (let* ((builder (add-text-to-store %store "my-fixed-builder.sh" "echo one > $out ; echo two > $second" (quote ()))) (drv (derivation %store "fixed" %bash (quasiquote ((unquote builder))) #:env-vars (quote (("HOME" . "/homeless") ("zzz" . "Z!") ("AAA" . "A!"))) #:inputs (quasiquote (((unquote %bash)) ((unquote builder)))) #:outputs (quote ("out" "second")))) (succeeded? (build-derivations %store (list drv)))) (and succeeded? (let ((one (derivation->output-path drv "out")) (two (derivation->output-path drv "second"))) (and (lset= equal? (derivation->output-paths drv) (quasiquote (("out" unquote one) ("second" unquote two)))) (eq? (quote one) (call-with-input-file one read)) (eq? (quote two) (call-with-input-file two read))))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "multiple-output derivation, non-alphabetic order" source-file: "tests/derivations.scm" source-line: 276 source-form: (test-assert "multiple-output derivation, non-alphabetic order" (let* ((builder (add-text-to-store %store "my-fixed-builder.sh" "echo one > $out ; echo two > $AAA" (quote ()))) (drv (derivation %store "fixed" %bash (quasiquote ((unquote builder))) #:inputs (quasiquote (((unquote %bash)) ((unquote builder)))) #:outputs (quote ("out" "AAA")))) (succeeded? (build-derivations %store (list drv)))) (and succeeded? (let ((one (derivation->output-path drv "out")) (two (derivation->output-path drv "AAA"))) (and (eq? (quote one) (call-with-input-file one read)) (eq? (quote two) (call-with-input-file two read))))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "multiple-output derivation, derivation-path->output-path" source-file: "tests/derivations.scm" source-line: 293 source-form: (test-assert "multiple-output derivation, derivation-path->output-path" (let* ((builder (add-text-to-store %store "builder.sh" "echo one > $out ; echo two > $second" (quote ()))) (drv (derivation %store "multiple" %bash (quasiquote ((unquote builder))) #:outputs (quote ("out" "second")))) (drv-file (derivation-file-name drv)) (one (derivation->output-path drv "out")) (two (derivation->output-path drv "second")) (first (derivation-path->output-path drv-file "out")) (second (derivation-path->output-path drv-file "second"))) (and (not (string=? one two)) (string-suffix? "-second" two) (string=? first one) (string=? second two)))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "user of multiple-output derivation" source-file: "tests/derivations.scm" source-line: 310 source-form: (test-assert "user of multiple-output derivation" (let* ((builder1 (add-text-to-store %store "my-mo-builder.sh" "echo one > $out ; echo two > $two" (quote ()))) (mdrv (derivation %store "multiple-output" %bash (quasiquote ((unquote builder1))) #:inputs (quasiquote (((unquote %bash)) ((unquote builder1)))) #:outputs (quote ("out" "two")))) (builder2 (add-text-to-store %store "my-mo-user-builder.sh" "read x < $one;\n read y < $two;\n echo \"($x $y)\" > $out" (quote ()))) (udrv (derivation %store "multiple-output-user" %bash (quasiquote ((unquote builder2))) #:env-vars (quasiquote (("one" unquote (derivation->output-path mdrv "out")) ("two" unquote (derivation->output-path mdrv "two")))) #:inputs (quasiquote (((unquote %bash)) ((unquote builder2)) ((unquote mdrv)) ((unquote mdrv) "two")))))) (and (build-derivations %store (list (pk (quote udrv) udrv))) (let ((p (derivation->output-path udrv))) (and (valid-path? %store p) (equal? (quote (one two)) (call-with-input-file p read))))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "derivation with #:references-graphs" source-file: "tests/derivations.scm" source-line: 343 source-form: (test-assert "derivation with #:references-graphs" (let* ((input1 (add-text-to-store %store "foo" "hello" (list %bash))) (input2 (add-text-to-store %store "bar" (number->string (random 7777)) (list input1))) (builder (add-text-to-store %store "build-graph" (format #f "\n~a $out\n (while read l ; do echo $l ; done) < bash > $out/bash\n (while read l ; do echo $l ; done) < input1 > $out/input1\n (while read l ; do echo $l ; done) < input2 > $out/input2" %mkdir) (list %mkdir))) (drv (derivation %store "closure-graphs" %bash (quasiquote ((unquote builder))) #:references-graphs (quasiquote (("bash" unquote %bash) ("input1" unquote input1) ("input2" unquote input2))) #:inputs (quasiquote (((unquote %bash)) ((unquote builder)))))) (out (derivation->output-path drv))) (define (deps path . deps) (let ((count (length deps))) (string-append path "\n\n" (number->string count) "\n" (string-join (sort deps string? input1 %bash) (string-append (deps %bash) (deps input1 %bash)) (string-append (deps input1 %bash) (deps %bash)))) ("/input2" unquote (string-concatenate (map cdr (sort (map (lambda (p d) (cons p (apply deps p d))) (list %bash input1 input2) (list (quote ()) (list %bash) (list input1))) (lambda (x y) (match x ((p1 . _) (match y ((p2 . _) (string) Test begin: test-name: "build derivation with coreutils" source-file: "tests/derivations.scm" source-line: 402 source-form: (test-assert "build derivation with coreutils" (let* ((builder (add-text-to-store %store "build-with-coreutils.sh" "echo $PATH ; mkdir --version ; mkdir $out ; touch $out/good" (quote ()))) (drv (derivation %store "foo" %bash (quasiquote ((unquote builder))) #:env-vars (quasiquote (("PATH" unquote (string-append (derivation->output-path %coreutils) "/bin")))) #:inputs (quasiquote (((unquote builder)) ((unquote %coreutils)))))) (succeeded? (build-derivations %store (list drv)))) (and succeeded? (let ((p (derivation->output-path drv))) (and (valid-path? %store p) (file-exists? (string-append p "/good"))))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "build-expression->derivation and derivation-prerequisites" source-file: "tests/derivations.scm" source-line: 425 source-form: (test-assert "build-expression->derivation and derivation-prerequisites" (let ((drv (build-expression->derivation %store "fail" #f))) (any (match-lambda (($ path) (string=? path (derivation-file-name (%guile-for-build))))) (derivation-prerequisites drv)))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "build-expression->derivation without inputs" source-file: "tests/derivations.scm" source-line: 432 source-form: (test-assert "build-expression->derivation without inputs" (let* ((builder (quote (begin (mkdir %output) (call-with-output-file (string-append %output "/test") (lambda (p) (display (quote (hello guix)) p)))))) (drv (build-expression->derivation %store "goo" builder)) (succeeded? (build-derivations %store (list drv)))) (and succeeded? (let ((p (derivation->output-path drv))) (equal? (quote (hello guix)) (call-with-input-file (string-append p "/test") read)))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "build-expression->derivation and max-silent-time" source-file: "tests/derivations.scm" source-line: 445 source-form: (test-assert "build-expression->derivation and max-silent-time" (let* ((store (let ((s (open-connection))) (set-build-options s #:max-silent-time 1) s)) (builder (quote (begin (sleep 100) (mkdir %output) #t))) (drv (build-expression->derivation store "silent" builder)) (out-path (derivation->output-path drv))) (guard (c ((nix-protocol-error? c) (and (string-contains (nix-protocol-error-message c) "failed") (not (valid-path? store out-path))))) (build-derivations store (list drv)) #f))) Test end: result-kind: fail actual-value: #f Test begin: test-name: "build-expression->derivation and timeout" source-file: "tests/derivations.scm" source-line: 459 source-form: (test-assert "build-expression->derivation and timeout" (let* ((store (let ((s (open-connection))) (set-build-options s #:timeout 1) s)) (builder (quote (begin (sleep 100) (mkdir %output) #t))) (drv (build-expression->derivation store "slow" builder)) (out-path (derivation->output-path drv))) (guard (c ((nix-protocol-error? c) (and (string-contains (nix-protocol-error-message c) "failed") (not (valid-path? store out-path))))) (build-derivations store (list drv)) #f))) Test end: result-kind: fail actual-value: #f Test begin: test-name: "build-expression->derivation and derivation-prerequisites-to-build" source-file: "tests/derivations.scm" source-line: 473 source-form: (test-assert "build-expression->derivation and derivation-prerequisites-to-build" (let ((drv (build-expression->derivation %store "fail" #f))) (null? (derivation-prerequisites-to-build %store drv)))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "derivation-prerequisites-to-build when outputs already present" source-file: "tests/derivations.scm" source-line: 479 source-form: (test-assert "derivation-prerequisites-to-build when outputs already present" (let* ((builder (quote (begin (mkdir %output) #t))) (input-drv (build-expression->derivation %store "input" builder)) (input-path (derivation-output-path (assoc-ref (derivation-outputs input-drv) "out"))) (drv (build-expression->derivation %store "something" builder #:inputs (quasiquote (("i" (unquote input-drv)))))) (output (derivation->output-path drv))) (when (valid-path? %store input-path) (delete-paths %store (list input-path))) (when (valid-path? %store output) (delete-paths %store (list output))) (and (equal? (map derivation-input-path (derivation-prerequisites-to-build %store drv)) (list (derivation-file-name input-drv))) (build-derivations %store (list drv)) (delete-paths %store (list input-path)) (not (valid-path? %store input-path)) (null? (derivation-prerequisites-to-build %store drv))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "derivation-prerequisites-to-build and substitutes" source-file: "tests/derivations.scm" source-line: 509 source-form: (test-assert "derivation-prerequisites-to-build and substitutes" (let* ((store (open-connection)) (drv (build-expression->derivation store "prereq-subst" (random 1000))) (output (derivation->output-path drv)) (dir (and=> (getenv "GUIX_BINARY_SUBSTITUTE_URL") (compose uri-path string->uri)))) (call-with-output-file (string-append dir "/nix-cache-info") (lambda (p) (format p "StoreDir: ~a\nWantMassQuery: 0\n" (%store-prefix)))) (call-with-output-file (string-append dir "/" (store-path-hash-part output) ".narinfo") (lambda (p) (format p "StorePath: ~a\nURL: ~a\nCompression: none\nNarSize: 1234\nReferences: \nSystem: ~a\nDeriver: ~a~%" output (string-append dir "/example.nar") (%current-system) (basename (derivation-file-name drv))))) (set-build-options store #:use-substitutes? #t) (let-values (((build download) (derivation-prerequisites-to-build store drv)) ((build* download*) (derivation-prerequisites-to-build store drv #:use-substitutes? #f))) (pk build download build* download*) (and (null? build) (equal? download (list output)) (null? download*) (null? build*))))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "build-expression->derivation with expression returning #f" source-file: "tests/derivations.scm" source-line: 551 source-form: (test-assert "build-expression->derivation with expression returning #f" (let* ((builder (quote (begin (mkdir %output) #f))) (drv (build-expression->derivation %store "fail" builder)) (out-path (derivation->output-path drv))) (guard (c ((nix-protocol-error? c) (and (string-match "build .* failed" (nix-protocol-error-message c)) (not (valid-path? %store out-path))))) (build-derivations %store (list drv)) #f))) Test end: result-kind: fail actual-value: #f Test begin: test-name: "build-expression->derivation with two outputs" source-file: "tests/derivations.scm" source-line: 566 source-form: (test-assert "build-expression->derivation with two outputs" (let* ((builder (quote (begin (call-with-output-file (assoc-ref %outputs "out") (lambda (p) (display (quote (hello)) p))) (call-with-output-file (assoc-ref %outputs "second") (lambda (p) (display (quote (world)) p)))))) (drv (build-expression->derivation %store "double" builder #:outputs (quote ("out" "second")))) (succeeded? (build-derivations %store (list drv)))) (and succeeded? (let ((one (derivation->output-path drv)) (two (derivation->output-path drv "second"))) (and (equal? (quote (hello)) (call-with-input-file one read)) (equal? (quote (world)) (call-with-input-file two read))))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "build-expression->derivation with one input" source-file: "tests/derivations.scm" source-line: 585 source-form: (test-assert "build-expression->derivation with one input" (let* ((builder (quote (call-with-output-file %output (lambda (p) (let ((cu (assoc-ref %build-inputs "cu"))) (close 1) (dup2 (port->fdes p) 1) (execl (string-append cu "/bin/uname") "uname" "-a")))))) (drv (build-expression->derivation %store "uname" builder #:inputs (quasiquote (("cu" (unquote %coreutils)))))) (succeeded? (build-derivations %store (list drv)))) (and succeeded? (let ((p (derivation->output-path drv))) (string-contains (call-with-input-file p read-line) "GNU"))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "imported-files" source-file: "tests/derivations.scm" source-line: 601 source-form: (test-assert "imported-files" (let* ((files (quasiquote (("x" unquote (search-path %load-path "ice-9/q.scm")) ("a/b/c" unquote (search-path %load-path "guix/derivations.scm")) ("p/q" unquote (search-path %load-path "guix.scm")) ("p/z" unquote (search-path %load-path "guix/store.scm"))))) (drv (imported-files %store files))) (and (build-derivations %store (list drv)) (let ((dir (derivation->output-path drv))) (every (match-lambda ((path . source) (equal? (call-with-input-file (string-append dir "/" path) get-bytevector-all) (call-with-input-file source get-bytevector-all)))) files))))) Test end: result-kind: pass actual-value: #t Test begin: test-name: "build-expression->derivation with modules" source-file: "tests/derivations.scm" source-line: 618 source-form: (test-assert "build-expression->derivation with modules" (let* ((builder (quasiquote (begin (use-modules (guix build utils)) (let ((out (assoc-ref %outputs "out"))) (mkdir-p (string-append out "/guile/guix/nix")) #t)))) (drv (build-expression->derivation %store "test-with-modules" builder #:modules (quote ((guix build utils)))))) (and (build-derivations %store (list drv)) (let* ((p (derivation->output-path drv)) (s (stat (string-append p "/guile/guix/nix")))) (eq? (stat:type s) (quote directory)))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "build-expression->derivation: same fixed-output path" source-file: "tests/derivations.scm" source-line: 633 source-form: (test-assert "build-expression->derivation: same fixed-output path" (let* ((builder1 (quote (call-with-output-file %output (lambda (p) (write "hello" p))))) (builder2 (quote (call-with-output-file (pk (quote difference-here!) %output) (lambda (p) (write "hello" p))))) (hash (sha256 (string->utf8 "hello"))) (input1 (build-expression->derivation %store "fixed" builder1 #:hash hash #:hash-algo (quote sha256))) (input2 (build-expression->derivation %store "fixed" builder2 #:hash hash #:hash-algo (quote sha256))) (succeeded? (build-derivations %store (list input1 input2)))) (and succeeded? (not (string=? (derivation-file-name input1) (derivation-file-name input2))) (string=? (derivation->output-path input1) (derivation->output-path input2))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "build-expression->derivation with a fixed-output input" source-file: "tests/derivations.scm" source-line: 654 source-form: (test-assert "build-expression->derivation with a fixed-output input" (let* ((builder1 (quote (call-with-output-file %output (lambda (p) (write "hello" p))))) (builder2 (quote (call-with-output-file (pk (quote difference-here!) %output) (lambda (p) (write "hello" p))))) (hash (sha256 (string->utf8 "hello"))) (input1 (build-expression->derivation %store "fixed" builder1 #:hash hash #:hash-algo (quote sha256))) (input2 (build-expression->derivation %store "fixed" builder2 #:hash hash #:hash-algo (quote sha256))) (builder3 (quote (let ((input (assoc-ref %build-inputs "input"))) (call-with-output-file %output (lambda (out) (format #f "My input is ~a.~%" input)))))) (final1 (build-expression->derivation %store "final" builder3 #:inputs (quasiquote (("input" (unquote input1)))))) (final2 (build-expression->derivation %store "final" builder3 #:inputs (quasiquote (("input" (unquote input2))))))) (and (string=? (derivation->output-path final1) (derivation->output-path final2)) (string=? (derivation->output-path final1) (derivation-path->output-path (derivation-file-name final1))) (build-derivations %store (list final1 final2))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "build-expression->derivation produces recursive fixed-output" source-file: "tests/derivations.scm" source-line: 685 source-form: (test-assert "build-expression->derivation produces recursive fixed-output" (let* ((builder (quote (begin (use-modules (srfi srfi-26)) (mkdir %output) (chdir %output) (call-with-output-file "exe" (cut display "executable" <>)) (chmod "exe" 511) (symlink "exe" "symlink") (mkdir "subdir")))) (drv (build-expression->derivation %store "fixed-rec" builder #:hash-algo (quote sha256) #:hash (base32 "10k1lw41wyrjf9mxydi0is5nkpynlsvgslinics4ppir13g7d74p") #:recursive? #t))) (and (build-derivations %store (list drv)) (let* ((dir (derivation->output-path drv)) (exe (string-append dir "/exe")) (link (string-append dir "/symlink")) (subdir (string-append dir "/subdir"))) (and (executable-file? exe) (string=? "executable" (call-with-input-file exe get-string-all)) (string=? "exe" (readlink link)) (file-is-directory? subdir)))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "build-expression->derivation uses recursive fixed-output" source-file: "tests/derivations.scm" source-line: 711 source-form: (test-assert "build-expression->derivation uses recursive fixed-output" (let* ((builder (quote (call-with-output-file %output (lambda (port) (display "hello" port))))) (fixed (build-expression->derivation %store "small-fixed-rec" builder #:hash-algo (quote sha256) #:hash (base32 "0sg9f58l1jj88w6pdrfdpj5x9b1zrwszk84j81zvby36q9whhhqa") #:recursive? #t)) (in (derivation->output-path fixed)) (builder (quasiquote (begin (mkdir %output) (chdir %output) (symlink (unquote in) "symlink")))) (drv (build-expression->derivation %store "fixed-rec-user" builder #:inputs (quasiquote (("fixed" (unquote fixed))))))) (and (build-derivations %store (list drv)) (let ((out (derivation->output-path drv))) (string=? (readlink (string-append out "/symlink")) in))))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) Test begin: test-name: "build-expression->derivation with #:references-graphs" source-file: "tests/derivations.scm" source-line: 733 source-form: (test-assert "build-expression->derivation with #:references-graphs" (let* ((input (add-text-to-store %store "foo" "hello" (list %bash %mkdir))) (builder (quote (copy-file "input" %output))) (drv (build-expression->derivation %store "references-graphs" builder #:references-graphs (quasiquote (("input" unquote input))))) (out (derivation->output-path drv))) (define (deps path . deps) (let ((count (length deps))) (string-append path "\n\n" (number->string count) "\n" (string-join (sort deps string) Test begin: test-name: "map-derivation" source-file: "tests/derivations.scm" source-line: 765 source-form: (test-equal "map-derivation" "hello" (let* ((joke (package-derivation %store guile-1.8)) (good (package-derivation %store %bootstrap-guile)) (drv1 (build-expression->derivation %store "original-drv1" #f #:guile-for-build joke)) (drv2 (build-expression->derivation %store "original-drv2" (quote (call-with-output-file %output (lambda (p) (display "hello" p)))))) (drv3 (build-expression->derivation %store "drv-to-remap" (quote (let ((in (assoc-ref %build-inputs "in"))) (copy-file in %output))) #:inputs (quasiquote (("in" (unquote drv1)))) #:guile-for-build joke)) (drv4 (map-derivation %store drv3 (quasiquote (((unquote drv1) unquote drv2) ((unquote joke) unquote good))))) (out (derivation->output-path drv4))) (and (build-derivations %store (list (pk (quote remapped) drv4))) (call-with-input-file out get-string-all)))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) expected-value: "hello" Test begin: test-name: "map-derivation, sources" source-file: "tests/derivations.scm" source-line: 788 source-form: (test-equal "map-derivation, sources" "hello" (let* ((script1 (add-text-to-store %store "fail.sh" "exit 1")) (script2 (add-text-to-store %store "hi.sh" "echo -n hello > $out")) (bash-full (package-derivation %store (@ (gnu packages bash) bash))) (drv1 (derivation %store "drv-to-remap" (derivation->output-path bash-full) (quasiquote ("-e" (unquote script1))) #:inputs (quasiquote (((unquote bash-full)) ((unquote script1)))))) (drv2 (map-derivation %store drv1 (quasiquote (((unquote bash-full) unquote %bash) ((unquote script1) unquote script2))))) (out (derivation->output-path drv2))) (and (build-derivations %store (list (pk (quote remapped*) drv2))) (call-with-input-file out get-string-all)))) Test end: result-kind: fail actual-value: #f actual-error: (srfi-34 #) expected-value: "hello" Group end: derivations # of expected passes 10 # of unexpected failures 26