tests: Test 'wrap-program' without building a package.
* tests/build-utils.scm (%store): Remove. ("wrap-program, one input, multiple calls"): Rewrite without resorting to packages and derivations.
This commit is contained in:
parent
c4c8cfddd5
commit
7370c02148
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2012, 2015 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2012, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -19,12 +19,9 @@
|
||||||
|
|
||||||
(define-module (test-build-utils)
|
(define-module (test-build-utils)
|
||||||
#:use-module (guix tests)
|
#:use-module (guix tests)
|
||||||
#:use-module (guix store)
|
|
||||||
#:use-module (guix derivations)
|
|
||||||
#:use-module (guix build utils)
|
#:use-module (guix build utils)
|
||||||
#:use-module (guix packages)
|
#:use-module ((guix utils)
|
||||||
#:use-module (guix build-system)
|
#:select (%current-system call-with-temporary-directory))
|
||||||
#:use-module (guix build-system trivial)
|
|
||||||
#:use-module (gnu packages)
|
#:use-module (gnu packages)
|
||||||
#:use-module (gnu packages bootstrap)
|
#:use-module (gnu packages bootstrap)
|
||||||
#:use-module (srfi srfi-34)
|
#:use-module (srfi srfi-34)
|
||||||
|
@ -32,9 +29,6 @@
|
||||||
#:use-module (rnrs io ports)
|
#:use-module (rnrs io ports)
|
||||||
#:use-module (ice-9 popen))
|
#:use-module (ice-9 popen))
|
||||||
|
|
||||||
(define %store
|
|
||||||
(open-connection-for-tests))
|
|
||||||
|
|
||||||
|
|
||||||
(test-begin "build-utils")
|
(test-begin "build-utils")
|
||||||
|
|
||||||
|
@ -95,49 +89,38 @@
|
||||||
port
|
port
|
||||||
cons)))))
|
cons)))))
|
||||||
|
|
||||||
(test-assert "wrap-program, one input, multiple calls"
|
(test-equal "wrap-program, one input, multiple calls"
|
||||||
(let* ((p (package
|
"hello world\n"
|
||||||
(name "test-wrap-program") (version "0") (source #f)
|
(call-with-temporary-directory
|
||||||
(synopsis #f) (description #f) (license #f) (home-page #f)
|
(lambda (directory)
|
||||||
(build-system trivial-build-system)
|
(let ((bash (search-bootstrap-binary "bash" (%current-system)))
|
||||||
(arguments
|
(foo (string-append directory "/foo")))
|
||||||
`(#: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
|
(call-with-output-file foo
|
||||||
(lambda (p)
|
(lambda (p)
|
||||||
(format p
|
(format p
|
||||||
"#!~a~%echo \"${GUIX_FOO} ${GUIX_BAR}\"~%"
|
"#!~a~%echo \"${GUIX_FOO} ${GUIX_BAR}\"~%"
|
||||||
bash)))
|
bash)))
|
||||||
(chmod foo #o777)
|
(chmod foo #o777)
|
||||||
;; wrap-program uses `which' to find bash for the wrapper
|
|
||||||
;; shebang, but it can't know about the bootstrap bash in
|
;; wrap-program uses `which' to find bash for the wrapper shebang, but
|
||||||
;; the store, since it's not named "bash". Help it out a
|
;; it can't know about the bootstrap bash in the store, since it's not
|
||||||
;; bit by providing a symlink it this package's output.
|
;; named "bash". Help it out a bit by providing a symlink it this
|
||||||
(symlink bash (string-append out "/bash"))
|
;; package's output.
|
||||||
(setenv "PATH" out)
|
(setenv "PATH" (dirname bash))
|
||||||
(wrap-program foo `("GUIX_FOO" prefix ("hello")))
|
(wrap-program foo `("GUIX_FOO" prefix ("hello")))
|
||||||
(wrap-program foo `("GUIX_BAR" prefix ("world")))
|
(wrap-program foo `("GUIX_BAR" prefix ("world")))
|
||||||
#t))))
|
|
||||||
(inputs `(("bash" ,(search-bootstrap-binary "bash"
|
|
||||||
(%current-system)))))))
|
|
||||||
(d (package-derivation %store p)))
|
|
||||||
|
|
||||||
;; The bootstrap Bash is linked against an old libc and would abort with
|
;; The bootstrap Bash is linked against an old libc and would abort with
|
||||||
;; an assertion failure when trying to load incompatible locale data.
|
;; an assertion failure when trying to load incompatible locale data.
|
||||||
(unsetenv "LOCPATH")
|
(unsetenv "LOCPATH")
|
||||||
|
|
||||||
(and (build-derivations %store (pk 'drv d (list d)))
|
(let* ((pipe (open-input-pipe foo))
|
||||||
(let* ((p (derivation->output-path d))
|
|
||||||
(foo (string-append p "/foo"))
|
|
||||||
(pipe (open-input-pipe foo))
|
|
||||||
(str (get-string-all pipe)))
|
(str (get-string-all pipe)))
|
||||||
(equal? str "hello world\n")))))
|
(with-directory-excursion directory
|
||||||
|
(for-each delete-file
|
||||||
|
'("foo" ".foo-real" ".foo-wrap-01" ".foo-wrap-02")))
|
||||||
|
(and (zero? (close-pipe pipe))
|
||||||
|
str))))))
|
||||||
|
|
||||||
(test-end)
|
(test-end)
|
||||||
|
|
Loading…
Reference in New Issue