tests: Don't rely on temporary directories being permanent.

* tests/gexp.scm ("gexp->script #:module-path",
"program-file #:module-path"): Use run-with-store.
This commit is contained in:
Leo Famulari 2018-07-13 15:53:25 -04:00
parent 82da291abe
commit 92bcccc51f
No known key found for this signature in database
GPG key ID: 2646FA30BACA7F08

View file

@ -948,7 +948,7 @@ (define shebang
(return (and (zero? (close-pipe pipe))
(= (expt n 2) (string->number str)))))))
(test-assertm "gexp->script #:module-path"
(test-assert "gexp->script #:module-path"
(call-with-temporary-directory
(lambda (directory)
(define str
@ -961,23 +961,24 @@ (define str
(define-public %fake! ,str))
port)))
(mlet* %store-monad ((exp -> (with-imported-modules '((guix base32))
(gexp (begin
(use-modules (guix base32))
(write (list %load-path
%fake!))))))
(drv (gexp->script "guile-thing" exp
#:guile %bootstrap-guile
#:module-path (list directory)))
(out -> (derivation->output-path drv))
(done (built-derivations (list drv))))
(let* ((pipe (open-input-pipe out))
(data (read pipe)))
(return (and (zero? (close-pipe pipe))
(match data
((load-path str*)
(and (string=? str* str)
(not (member directory load-path))))))))))))
(run-with-store %store
(mlet* %store-monad ((exp -> (with-imported-modules '((guix base32))
(gexp (begin
(use-modules (guix base32))
(write (list %load-path
%fake!))))))
(drv (gexp->script "guile-thing" exp
#:guile %bootstrap-guile
#:module-path (list directory)))
(out -> (derivation->output-path drv))
(done (built-derivations (list drv))))
(let* ((pipe (open-input-pipe out))
(data (read pipe)))
(return (and (zero? (close-pipe pipe))
(match data
((load-path str*)
(and (string=? str* str)
(not (member directory load-path)))))))))))))
(test-assertm "program-file"
(let* ((n (random (expt 2 50)))
@ -996,7 +997,7 @@ (define-public %fake! ,str))
(return (and (zero? (close-pipe pipe))
(= n (string->number str)))))))))
(test-assertm "program-file #:module-path"
(test-assert "program-file #:module-path"
(call-with-temporary-directory
(lambda (directory)
(define text (random-text))
@ -1014,14 +1015,15 @@ (define-public %stupid-thing ,text))
(file (program-file "program" exp
#:guile %bootstrap-guile
#:module-path (list directory))))
(mlet* %store-monad ((drv (lower-object file))
(out -> (derivation->output-path drv)))
(mbegin %store-monad
(built-derivations (list drv))
(let* ((pipe (open-input-pipe out))
(str (get-string-all pipe)))
(return (and (zero? (close-pipe pipe))
(string=? text str))))))))))
(run-with-store %store
(mlet* %store-monad ((drv (lower-object file))
(out -> (derivation->output-path drv)))
(mbegin %store-monad
(built-derivations (list drv))
(let* ((pipe (open-input-pipe out))
(str (get-string-all pipe)))
(return (and (zero? (close-pipe pipe))
(string=? text str)))))))))))
(test-assertm "program-file & with-extensions"
(let* ((exp (with-extensions (list %extension-package)