summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-08-26 22:12:46 +0200
committerLudovic Courtès <ludo@gnu.org>2013-08-26 22:20:53 +0200
commit5b0c9d1635df1608a498db8718af575d2f0e1663 (patch)
treec4e38d7d3b566507b8d966971b780705506fabb8 /tests
parenta987d2c02525efd1bf37b4bb5b5df405a06bd15c (diff)
derivations: Add #:dependency-graphs `derivation' parameter.
* guix/derivations.scm (derivation): Add `dependency-graphs' keyword parameter; honor it. * tests/derivations.scm (bootstrap-binary): New procedure. (%bash): Use it. (%mkdir): New variable. (directory-contents): Add `slurp' optional parameter. ("derivation with #:dependency-graphs"): New test. * doc/guix.texi (Derivations): Update accordingly.
Diffstat (limited to 'tests')
-rw-r--r--tests/derivations.scm68
1 files changed, 61 insertions, 7 deletions
diff --git a/tests/derivations.scm b/tests/derivations.scm
index 9833e15112..9b3d92a7bf 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -50,19 +50,23 @@
(let ((drv (package-derivation %store %bootstrap-guile)))
(%guile-for-build drv)))
-(define %bash
- (let ((bash (search-bootstrap-binary "bash" (%current-system))))
+(define (bootstrap-binary name)
+ (let ((bin (search-bootstrap-binary name (%current-system))))
(and %store
- (add-to-store %store "bash" #t "sha256" bash))))
+ (add-to-store %store name #t "sha256" bin))))
+
+(define %bash
+ (bootstrap-binary "bash"))
+(define %mkdir
+ (bootstrap-binary "mkdir"))
-(define (directory-contents dir)
+(define* (directory-contents dir #:optional (slurp get-bytevector-all))
"Return an alist representing the contents of DIR."
(define prefix-len (string-length dir))
(sort (file-system-fold (const #t) ; enter?
(lambda (path stat result) ; leaf
(alist-cons (string-drop path prefix-len)
- (call-with-input-file path
- get-bytevector-all)
+ (call-with-input-file path slurp)
result))
(lambda (path stat result) result) ; down
(lambda (path stat result) result) ; up
@@ -84,7 +88,7 @@
(and (equal? b1 b2)
(equal? d1 d2))))
-(test-skip (if %store 0 11))
+(test-skip (if %store 0 12))
(test-assert "add-to-store, flat"
(let* ((file (search-path %load-path "language/tree-il/spec.scm"))
@@ -292,6 +296,56 @@
(and (valid-path? %store p)
(equal? '(one two) (call-with-input-file p read)))))))
+(test-assert "derivation with #:dependency-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 "
+~a $out
+ (while read l ; do echo $l ; done) < bash > $out/bash
+ (while read l ; do echo $l ; done) < input1 > $out/input1
+ (while read l ; do echo $l ; done) < input2 > $out/input2"
+ %mkdir)
+ (list %mkdir)))
+ (drv (derivation %store "closure-graphs"
+ %bash `(,builder)
+ #:dependency-graphs
+ `(("bash" . ,%bash)
+ ("input1" . ,input1)
+ ("input2" . ,input2))
+ #:inputs `((,%bash) (,builder))))
+ (out (derivation-path->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<?) "\n")
+ (if (zero? count) "" "\n"))))
+
+ (and (build-derivations %store (list drv))
+ (equal? (directory-contents out get-string-all)
+ `(("/bash" . ,(string-append %bash "\n\n0\n"))
+ ("/input1" . ,(if (string>? input1 %bash)
+ (string-append (deps %bash)
+ (deps input1 %bash))
+ (string-append (deps input1 %bash)
+ (deps %bash))))
+ ("/input2" . ,(string-concatenate
+ (map cdr
+ (sort
+ (map (lambda (p d)
+ (cons p (apply deps p d)))
+ (list %bash input1 input2)
+ (list '() (list %bash) (list input1)))
+ (lambda (x y)
+ (match x
+ ((p1 . _)
+ (match y
+ ((p2 . _)
+ (string<? p1 p2)))))))))))))))
+
(define %coreutils
(false-if-exception