From de4c3f26cbf25149265f779b5af08c79de47859c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 7 Jun 2012 23:15:00 +0200 Subject: Allow derivations with input derivations. * guix/derivations.scm (derivation-path->output-path): New procedure. (derivation-hash): Call `memoize'. In the fixed-output case, convert HASH-ALGO to a string. In the other case, sort inputs in the alphabetical order of their hex hash. For inputs with no sub-drvs, add "out" as the sub-drv. * guix/utils.scm (%nixpkgs-directory): New parameter. (nixpkgs-derivation, memoize): New procedures. * tests/derivations.scm ("build derivation with 1 source"): Remove useless shebang. (%coreutils): New variable. ("build derivation with coreutils"): New test. --- tests/derivations.scm | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/derivations.scm b/tests/derivations.scm index 64bc678828..f2a3bb2d55 100644 --- a/tests/derivations.scm +++ b/tests/derivations.scm @@ -20,6 +20,7 @@ (define-module (test-derivations) #:use-module (guix derivations) #:use-module (guix store) + #:use-module (guix utils) #:use-module (srfi srfi-11) #:use-module (srfi srfi-26) #:use-module (srfi srfi-64) @@ -40,7 +41,7 @@ (and (equal? b1 b2) (equal? d1 d2)))) -(test-skip (if %store 0 2)) +(test-skip (if %store 0 3)) (test-assert "derivation with no inputs" (let ((builder (add-text-to-store %store "my-builder.sh" @@ -52,7 +53,7 @@ (test-assert "build derivation with 1 source" (let*-values (((builder) (add-text-to-store %store "my-builder.sh" - "#!/bin/sh\necho hello, world > \"$out\"\n" + "echo hello, world > \"$out\"\n" '())) ((drv-path drv) (derivation %store "foo" "x86_64-linux" @@ -67,6 +68,32 @@ (string=? (call-with-input-file path read-line) "hello, world"))))) + +(define %coreutils + (false-if-exception (nixpkgs-derivation "coreutils"))) + +(test-skip (if %coreutils 0 1)) + +(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" + '())) + (drv-path + (derivation %store "foo" "x86_64-linux" + "/bin/sh" `(,builder) + `(("PATH" . + ,(string-append + (derivation-path->output-path %coreutils) + "/bin"))) + `((,builder) + (,%coreutils)))) + (succeeded? + (build-derivations %store (list drv-path)))) + (and succeeded? + (let ((p (derivation-path->output-path drv-path))) + (file-exists? (string-append p "/good")))))) + (test-end) -- cgit v1.2.3