summaryrefslogtreecommitdiff
path: root/tests/build-utils.scm
diff options
context:
space:
mode:
authorEric Bavier <bavier@member.fsf.org>2014-09-13 01:05:03 -0500
committerEric Bavier <bavier@member.fsf.org>2014-09-13 21:53:21 -0500
commitde61113857d3ebda1f4557c5a8f6bffe63100060 (patch)
tree11f673cf9a33ee9ae2b967826d85d7360828df43 /tests/build-utils.scm
parent9fac9e3be3925713c20f1d5ff8b35353af10baa2 (diff)
downloadpatches-de61113857d3ebda1f4557c5a8f6bffe63100060.tar
patches-de61113857d3ebda1f4557c5a8f6bffe63100060.tar.gz
utils: Allow wrap-program to be called multiple times.
* guix/build/utils.scm (wrap-program): Multiple invocations of wrap-program for the same file create successive wrappers. Adjust docstring. * tests/build-utils.scm: Test new wrap-program behavior. (%store): New variable.
Diffstat (limited to 'tests/build-utils.scm')
-rw-r--r--tests/build-utils.scm57
1 files changed, 56 insertions, 1 deletions
diff --git a/tests/build-utils.scm b/tests/build-utils.scm
index e94f04b239..a5ea640c47 100644
--- a/tests/build-utils.scm
+++ b/tests/build-utils.scm
@@ -18,9 +18,24 @@
(define-module (test-build-utils)
+ #:use-module (guix tests)
+ #:use-module (guix store)
+ #:use-module (guix derivations)
#:use-module (guix build utils)
- #:use-module (srfi srfi-64))
+ #:use-module (guix packages)
+ #:use-module (guix build-system)
+ #:use-module (guix build-system trivial)
+ #:use-module (gnu packages)
+ #:use-module (gnu packages bootstrap)
+ #:use-module (srfi srfi-34)
+ #:use-module (srfi srfi-64)
+ #:use-module (rnrs io ports)
+ #:use-module (ice-9 popen))
+(define %store
+ (open-connection-for-tests))
+
+
(test-begin "build-utils")
(test-equal "alist-cons-before"
@@ -80,6 +95,46 @@
port
cons)))))
+(test-assert "wrap-program, one input, multiple calls"
+ (let* ((p (package
+ (name "test-wrap-program") (version "0") (source #f)
+ (synopsis #f) (description #f) (license #f) (home-page #f)
+ (build-system trivial-build-system)
+ (arguments
+ `(#:guile ,%bootstrap-guile
+ #:modules ((guix build utils))
+ #:builder
+ (let* ((out (assoc-ref %outputs "out"))
+ (bash (assoc-ref %build-inputs "bash"))
+ (foo (string-append out "/foo")))
+ (begin
+ (use-modules (guix build utils))
+ (mkdir out)
+ (call-with-output-file foo
+ (lambda (p)
+ (format p
+ "#!~a~%echo \"${GUIX_FOO} ${GUIX_BAR}\"~%"
+ bash)))
+ (chmod foo #o777)
+ ;; wrap-program uses `which' to find bash for the wrapper
+ ;; shebang, but it can't know about the bootstrap bash in
+ ;; the store, since it's not named "bash". Help it out a
+ ;; bit by providing a symlink it this package's output.
+ (symlink bash (string-append out "/bash"))
+ (setenv "PATH" out)
+ (wrap-program foo `("GUIX_FOO" prefix ("hello")))
+ (wrap-program foo `("GUIX_BAR" prefix ("world")))
+ #t))))
+ (inputs `(("bash" ,(search-bootstrap-binary "bash"
+ (%current-system)))))))
+ (d (package-derivation %store p)))
+ (and (build-derivations %store (pk 'drv d (list d)))
+ (let* ((p (derivation->output-path d))
+ (foo (string-append p "/foo"))
+ (pipe (open-input-pipe foo))
+ (str (get-string-all pipe)))
+ (equal? str "hello world\n")))))
+
(test-end)