From: Glenn Morris Date: Sun, 21 May 2017 00:00:02 +0000 (-0700) Subject: Prevent running vc-tests writing to ~/.bzr.log X-Git-Tag: emacs-26.0.90~521^2~336 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ed8b4e0c0c5da838e639d1505bdd090a7e2d735f;p=emacs.git Prevent running vc-tests writing to ~/.bzr.log * 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. --- diff --git a/test/lisp/vc/vc-tests.el b/test/lisp/vc/vc-tests.el index 656f673b201..1104085a2e1 100644 --- a/test/lisp/vc/vc-tests.el +++ b/test/lisp/vc/vc-tests.el @@ -115,7 +115,7 @@ (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.