+(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")))))
+