summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-03-23 18:35:32 +0100
committerLudovic Courtès <ludo@gnu.org>2018-03-23 18:41:07 +0100
commit427ec19e8887b8036690734564a86496000e12a6 (patch)
treece9262cc6a68c9e1a3f23cc3024b32fe9a8d585f /tests
parent1ae16033f34cebe802023922436883867010850f (diff)
downloadguix-427ec19e8887b8036690734564a86496000e12a6.tar.gz
gexp: 'program-file' has a new #:module-path parameter.
* guix/gexp.scm (<program-file>): Add 'path' field.
(program-file): Add #:module-path parameter and honor it.
(program-file-compiler): Honor the 'path' field.
* tests/gexp.scm ("program-file #:module-path"): New test.
* doc/guix.texi (G-Expressions): Update.
Diffstat (limited to 'tests')
-rw-r--r--tests/gexp.scm27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/gexp.scm b/tests/gexp.scm
index a0198b13a0..2f8940e2c6 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -902,6 +902,33 @@
           (return (and (zero? (close-pipe pipe))
                        (= n (string->number str)))))))))
 
+(test-assertm "program-file #:module-path"
+  (call-with-temporary-directory
+   (lambda (directory)
+     (define text (random-text))
+
+     (call-with-output-file (string-append directory "/stupid-module.scm")
+       (lambda (port)
+         (write `(begin (define-module (stupid-module))
+                        (define-public %stupid-thing ,text))
+                port)))
+
+     (let* ((exp    (with-imported-modules '((stupid-module))
+                      (gexp (begin
+                              (use-modules (stupid-module))
+                              (display %stupid-thing)))))
+            (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))))))))))
+
 (test-assertm "scheme-file"
   (let* ((text   (plain-file "foo" "Hello, world!"))
          (scheme (scheme-file "bar" #~(list "foo" #$text))))