summaryrefslogtreecommitdiff
path: root/tests/gexp.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-03-23 18:21:28 +0100
committerLudovic Courtès <ludo@gnu.org>2018-03-23 18:41:07 +0100
commit1ae16033f34cebe802023922436883867010850f (patch)
tree8627cad912e9238153e64e41ad733dade018f4df /tests/gexp.scm
parent7aff5d025d65c0fa44e6f897471b2b8b78b98738 (diff)
downloadgnu-guix-1ae16033f34cebe802023922436883867010850f.tar
gnu-guix-1ae16033f34cebe802023922436883867010850f.tar.gz
gexp: 'gexp->script' and 'gexp->file' have a new #:module-path parameter.
* guix/gexp.scm (load-path-expression): Add 'path' optional parameter. (gexp->script): Add #:module-path and honor it. (gexp->file): Likewise. * tests/gexp.scm ("gexp->script #:module-path"): New test. * doc/guix.texi (G-Expressions): Update accordingly.
Diffstat (limited to 'tests/gexp.scm')
-rw-r--r--tests/gexp.scm34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/gexp.scm b/tests/gexp.scm
index 5873abdd41..a0198b13a0 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -25,6 +25,7 @@
#:use-module (guix packages)
#:use-module (guix tests)
#:use-module ((guix build utils) #:select (with-directory-excursion))
+ #:use-module ((guix utils) #:select (call-with-temporary-directory))
#:use-module (gnu packages)
#:use-module (gnu packages base)
#:use-module (gnu packages bootstrap)
@@ -853,6 +854,37 @@
(return (and (zero? (close-pipe pipe))
(= (expt n 2) (string->number str)))))))
+(test-assertm "gexp->script #:module-path"
+ (call-with-temporary-directory
+ (lambda (directory)
+ (define str
+ "Fake (guix base32) module!")
+
+ (mkdir (string-append directory "/guix"))
+ (call-with-output-file (string-append directory "/guix/base32.scm")
+ (lambda (port)
+ (write `(begin (define-module (guix base32))
+ (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))))))))))))
+
(test-assertm "program-file"
(let* ((n (random (expt 2 50)))
(exp (with-imported-modules '((guix build utils))