store: 'run-with-store' initializes %CURRENT-TARGET-SYSTEM to #f.

* guix/store.scm (run-with-store): Set %CURRENT-TARGET-SYSTEM to #f.
* tests/gexp.scm ("gexp->derivation vs. %current-target-system"): New test.
This commit is contained in:
Ludovic Courtès 2015-07-07 22:57:54 +02:00
parent d7facc6603
commit a8afb9aed3
2 changed files with 16 additions and 1 deletions

View File

@ -996,8 +996,12 @@ permission bits are kept."
(system (%current-system)))
"Run MVAL, a monadic value in the store monad, in STORE, an open store
connection, and return the result."
;; Initialize the dynamic bindings here to avoid bad surprises. The
;; difficulty lies in the fact that dynamic bindings are resolved at
;; bind-time and not at call time, which can be disconcerting.
(parameterize ((%guile-for-build guile-for-build)
(%current-system system))
(%current-system system)
(%current-target-system #f))
(call-with-values (lambda ()
(run-with-state mval store))
(lambda (result store)

View File

@ -636,6 +636,17 @@
file)))))
#:guile-for-build (package-derivation %store %bootstrap-guile))))
(test-assert "gexp->derivation vs. %current-target-system"
(let ((mval (gexp->derivation "foo"
#~(begin
(mkdir #$output)
(foo #+gnu-make))
#:target #f)))
;; The value of %CURRENT-TARGET-SYSTEM at bind-time should have no
;; influence.
(parameterize ((%current-target-system "fooooo"))
(derivation? (run-with-store %store mval)))))
(test-assert "printer"
(string-match "^#<gexp \\(string-append .*#<package coreutils.*\
\"/bin/uname\"\\) [[:xdigit:]]+>$"