]> git.eshelyaron.com Git - emacs.git/commitdiff
Prevent running vc-tests writing to ~/.bzr.log
authorGlenn Morris <rgm@gnu.org>
Sun, 21 May 2017 00:00:02 +0000 (17:00 -0700)
committerGlenn Morris <rgm@gnu.org>
Sun, 21 May 2017 00:00:02 +0000 (17:00 -0700)
* test/lisp/vc/vc-tests.el (vc-test--create-repo)
(vc-test--register, vc-test--working-revision)
(vc-test--checkout-model): Set temporary BZR_HOME, to disable logging.

test/lisp/vc/vc-tests.el

index 656f673b201eb8c853d0ca25515f2168024d77b1..1104085a2e17420c5efa728e1c57535436424d6c 100644 (file)
 
 (defvar vc-test--cleanup-hook nil
   "Functions for cleanup at the end of an ert test.
-Don't set it globally, the functions shall be let-bound.")
+Don't set it globally, the functions should be let-bound.")
 
 (defun vc-test--revision-granularity-function (backend)
   "Run the `vc-revision-granularity' backend function."
@@ -181,7 +181,13 @@ For backends which dont support it, it is emulated."
          (file-name-as-directory
           (expand-file-name
            (make-temp-name "vc-test") temporary-file-directory)))
+       (process-environment process-environment)
+       tempdir
        vc-test--cleanup-hook)
+    (when (eq backend 'Bzr)
+      (setq tempdir (make-temp-file "vc-test--create-repo" t)
+           process-environment (cons (format "BZR_HOME=%s" tempdir)
+                                     process-environment)))
 
     (unwind-protect
        (progn
@@ -201,7 +207,9 @@ For backends which dont support it, it is emulated."
          (should (eq (vc-responsible-backend default-directory) backend)))
 
       ;; Save exit.
-      (ignore-errors (run-hooks 'vc-test--cleanup-hook)))))
+      (ignore-errors
+        (if tempdir (delete-directory tempdir t))
+        (run-hooks 'vc-test--cleanup-hook)))))
 
 ;; FIXME: Why isn't there `vc-unregister'?
 (defun vc-test--unregister-function (backend file)
@@ -231,8 +239,13 @@ This checks also `vc-backend' and `vc-responsible-backend'."
          (file-name-as-directory
           (expand-file-name
            (make-temp-name "vc-test") temporary-file-directory)))
+       (process-environment process-environment)
+       tempdir
        vc-test--cleanup-hook)
-
+    (when (eq backend 'Bzr)
+      (setq tempdir (make-temp-file "vc-test--register" t)
+           process-environment (cons (format "BZR_HOME=%s" tempdir)
+                                     process-environment)))
     (unwind-protect
        (progn
          ;; Cleanup.
@@ -292,12 +305,14 @@ This checks also `vc-backend' and `vc-responsible-backend'."
               (should-not (vc-backend tmp-name2))
               (should-not (vc-registered tmp-name2)))
 
-            ;; The files shall still exist.
+            ;; The files should still exist.
            (should (file-exists-p tmp-name1))
            (should (file-exists-p tmp-name2))))
 
       ;; Save exit.
-      (ignore-errors (run-hooks 'vc-test--cleanup-hook)))))
+      (ignore-errors
+        (if tempdir (delete-directory tempdir t))
+        (run-hooks 'vc-test--cleanup-hook)))))
 
 (defun vc-test--state (backend)
   "Check the different states of a file."
@@ -374,7 +389,13 @@ This checks also `vc-backend' and `vc-responsible-backend'."
          (file-name-as-directory
           (expand-file-name
            (make-temp-name "vc-test") temporary-file-directory)))
+       (process-environment process-environment)
+       tempdir
        vc-test--cleanup-hook)
+    (when (eq backend 'Bzr)
+      (setq tempdir (make-temp-file "vc-test--working-revision" t)
+           process-environment (cons (format "BZR_HOME=%s" tempdir)
+                                     process-environment)))
 
     (unwind-protect
        (progn
@@ -435,7 +456,9 @@ This checks also `vc-backend' and `vc-responsible-backend'."
               (should-not (vc-working-revision tmp-name)))))
 
       ;; Save exit.
-      (ignore-errors (run-hooks 'vc-test--cleanup-hook)))))
+      (ignore-errors
+        (if tempdir (delete-directory tempdir t))
+        (run-hooks 'vc-test--cleanup-hook)))))
 
 (defun vc-test--checkout-model (backend)
   "Check the checkout model of a repository."
@@ -445,7 +468,13 @@ This checks also `vc-backend' and `vc-responsible-backend'."
          (file-name-as-directory
           (expand-file-name
            (make-temp-name "vc-test") temporary-file-directory)))
+       (process-environment process-environment)
+       tempdir
        vc-test--cleanup-hook)
+    (when (eq backend 'Bzr)
+      (setq tempdir (make-temp-file "vc-test--checkout-model" t)
+           process-environment (cons (format "BZR_HOME=%s" tempdir)
+                                     process-environment)))
 
     (unwind-protect
        (progn
@@ -512,7 +541,9 @@ This checks also `vc-backend' and `vc-responsible-backend'."
                             '(announce implicit locking))))))
 
       ;; Save exit.
-      (ignore-errors (run-hooks 'vc-test--cleanup-hook)))))
+      (ignore-errors
+        (if tempdir (delete-directory tempdir t))
+        (run-hooks 'vc-test--cleanup-hook)))))
 
 ;; Create the test cases.