diff options
author | Ludovic Courtès <ludo@gnu.org> | 2020-11-05 14:52:29 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2020-11-05 16:13:50 +0100 |
commit | ca465a9c8454289b7aded22719cd5d919e441780 (patch) | |
tree | 4b0eb37a79eacd5df06157dbf6df99cd9d493141 /tests | |
parent | 18fc84bce86eedb85d44a8708a9a5ef7c1b23da5 (diff) | |
download | guix-ca465a9c8454289b7aded22719cd5d919e441780.tar guix-ca465a9c8454289b7aded22719cd5d919e441780.tar.gz |
gexp: Warn when importing (guix config) or (ice-9 …).
While importing those modules from the host system is valid, it is often
a mistake that introduces non-reproducibility. This patch prints a
warning when that happens.
* guix/gexp.scm (gexp-attribute): Add #:validate parameter and honor it.
(gexp-modules)[validate-modules]: New procedure.
Pass it to 'gexp-attribute'.
* tests/gexp.scm ("gexp-modules, warning"): New test.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gexp.scm | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/gexp.scm b/tests/gexp.scm index 0487f2a96d..686334af61 100644 --- a/tests/gexp.scm +++ b/tests/gexp.scm @@ -30,6 +30,7 @@ #:use-module (gnu packages) #:use-module (gnu packages base) #:use-module (gnu packages bootstrap) + #:use-module ((guix diagnostics) #:select (guix-warning-port)) #:use-module (srfi srfi-1) #:use-module (srfi srfi-34) #:use-module (srfi srfi-64) @@ -818,6 +819,17 @@ '() (gexp-modules #t)) +(test-assert "gexp-modules, warning" + (string-match "tests/gexp.scm:[0-9]+:[0-9]+: warning: \ +importing.* \\(guix config\\) from the host" + (call-with-output-string + (lambda (port) + (parameterize ((guix-warning-port port)) + (let* ((x (with-imported-modules '((guix config)) + #~(+ 1 2 3))) + (y #~(+ 39 #$x))) + (gexp-modules y))))))) + (test-assertm "gexp->derivation #:modules" (mlet* %store-monad ((build -> #~(begin |