guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/06: tests: Unset NIX_STORE_DIR when running external tests.


From: guix-commits
Subject: 01/06: tests: Unset NIX_STORE_DIR when running external tests.
Date: Mon, 5 Jul 2021 10:58:28 -0400 (EDT)

civodul pushed a commit to branch core-updates
in repository guix.

commit 99ea6a2996a388134c6ea8fdce34f70d446b1450
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Jul 5 15:34:24 2021 +0200

    tests: Unset NIX_STORE_DIR when running external tests.
    
    This is a followup to cfcead2e515c0dae02127e5a76496463898be6b6 and
    47a6a938c3c4d0bbe7b6a3c64ff75d7bfb2f24fb, which made (guix packages)
    dependent on the value of NIX_STORE_DIR.
    
    * guix/tests.scm (call-with-external-store): Unset NIX_STORE_DIR before
    calling PROC.
---
 guix/tests.scm | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/guix/tests.scm b/guix/tests.scm
index e1b053f..063b201 100644
--- a/guix/tests.scm
+++ b/guix/tests.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès 
<ludo@gnu.org>
+;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic 
Courtès <ludo@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -138,13 +138,21 @@ no external store to talk to."
           (open-connection))
         (const #f)))
 
-    (dynamic-wind
-      (const #t)
-      (lambda ()
-        (proc store))
-      (lambda ()
-        (when store
-          (close-connection store))))))
+    (let ((store-variable (getenv "NIX_STORE_DIR")))
+      (dynamic-wind
+        (lambda ()
+          ;; This environment variable is set by 'pre-inst-env' but it
+          ;; influences '%store-directory' in (guix build utils), which is
+          ;; itself used in (guix packages).  Thus, unset it before going any
+          ;; further.
+          (unsetenv "NIX_STORE_DIR"))
+        (lambda ()
+          (proc store))
+        (lambda ()
+          (when store-variable
+            (setenv "NIX_STORE_DIR" store-variable))
+          (when store
+            (close-connection store)))))))
 
 (define-syntax-rule (with-external-store store exp ...)
   "Evaluate EXP with STORE bound to the external store rather than the



reply via email to

[Prev in Thread] Current Thread [Next in Thread]