From d938a58beefc669ab340aa1aeab49df3dc24d123 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 15 Mar 2017 22:14:36 +0100 Subject: gexp: Add '=>' syntax to import computed modules. * guix/gexp.scm (imported-files)[file-pair]: Add case for pairs where the cdr is not a string. (imported-modules): Support '=>' syntax in MODULES. * tests/gexp.scm ("imported-files with file-like objects") ("gexp->derivation & with-imported-module & computed module"): New tests. * doc/guix.texi (G-Expressions): Document '=>' syntax for 'with-imported-modules'. --- tests/gexp.scm | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests/gexp.scm') diff --git a/tests/gexp.scm b/tests/gexp.scm index baf78837ae..b3f7323984 100644 --- a/tests/gexp.scm +++ b/tests/gexp.scm @@ -598,6 +598,23 @@ get-bytevector-all)))) files)))))) +(test-assertm "imported-files with file-like objects" + (mlet* %store-monad ((plain -> (plain-file "foo" "bar!")) + (q-scm -> (search-path %load-path "ice-9/q.scm")) + (files -> `(("a/b/c" . ,q-scm) + ("p/q" . ,plain))) + (drv (imported-files files))) + (mbegin %store-monad + (built-derivations (list drv)) + (mlet %store-monad ((dir -> (derivation->output-path drv)) + (plain* (text-file "foo" "bar!")) + (q-scm* (interned-file q-scm "c"))) + (return + (and (string=? (readlink (string-append dir "/a/b/c")) + q-scm*) + (string=? (readlink (string-append dir "/p/q")) + plain*))))))) + (test-equal "gexp-modules & ungexp" '((bar) (foo)) ((@@ (guix gexp) gexp-modules) @@ -668,6 +685,28 @@ (equal? '(chdir "/foo") (call-with-input-file b read)))))))) +(test-assertm "gexp->derivation & with-imported-module & computed module" + (mlet* %store-monad + ((module -> (scheme-file "x" #~(begin + (define-module (foo bar) + #:export (the-answer)) + + (define the-answer 42)))) + (build -> (with-imported-modules `(((foo bar) => ,module) + (guix build utils)) + #~(begin + (use-modules (guix build utils) + (foo bar)) + mkdir-p + (call-with-output-file #$output + (lambda (port) + (write the-answer port)))))) + (drv (gexp->derivation "thing" build)) + (out -> (derivation->output-path drv))) + (mbegin %store-monad + (built-derivations (list drv)) + (return (= 42 (call-with-input-file out read)))))) + (test-assertm "gexp->derivation #:references-graphs" (mlet* %store-monad ((one (text-file "one" (random-text))) -- cgit v1.2.3