Subject: bug#70195: 30.0.50; vc-test-bzr02-state fails

From: Stefan Kangas <[email-masked]>
Date: Sat, 1 Mar 2025 16:00:59 -0800

Michael Albinus <[email-masked]> writes:

> --8<---------------cut here---------------start------------->8---
> # make -C test vc-tests
> Ran 42 tests, 40 results as expected, 1 unexpected, 1 skipped (2025-03-01 10:15:59+0100, 18.968494 sec)
>
> 1 unexpected results:
>    FAILED  vc-test-bzr02-state
> --8<---------------cut here---------------end--------------->8---

Hmm, we have this comment in vc-bzr-tests.el:

  ;; Bzr wants to access HOME, e.g. to write ~/.bzr.log.
  ;; This is a problem on hydra, where HOME is non-existent.
  ;; You can disable logging with BZR_LOG=/dev/null, but then some
  ;; commands (eg `bzr status') want to access ~/.bazaar, and will
  ;; abort if they cannot.  I could not figure out how to stop bzr
  ;; doing that, so just give it a temporary homedir for the duration.
  ;; https://bugs.launchpad.net/bzr/+bug/137407 ?
  ;;
  ;; Note that with bzr 2.x, this works:
  ;; mkdir /tmp/bzr
  ;; HOME=/nonexistent BZR_HOME=/tmp/bzr bzr status
  ;; but with brz 3.1, it complains:
  ;; "failed to open trace file: [Errno 13] Permission denied: '/nonexistent'"
  ;; which confuses vc-dir.
  ;; We can quieten brz by adding either BRZ_LOG=/dev/null, or
  ;; XDG_CACHE_HOME=/tmp/bzr (log defaults to XDG_CACHE_HOME/breezy/brz.log),
  ;; but it seems simpler to just set HOME to a newly created
  ;; temporary directory.
  ;; TODO does this means tests should be setting XDG_ variables (not
  ;; just HOME) to temporary values too?

Maybe the below patch would fix it?

diff --git a/test/lisp/vc/vc-tests.el b/test/lisp/vc/vc-tests.el
index 62938c41227..1c17756ed31 100644
--- a/test/lisp/vc/vc-tests.el
+++ b/test/lisp/vc/vc-tests.el
@@ -324,8 +324,9 @@ vc-test--state
           (process-environment process-environment)
           vc-test--cleanup-hook)
       (when (eq backend 'Bzr)
-        (setq process-environment (cons (format "BZR_HOME=%s" tempdir)
-                                        process-environment)))
+        ;; See the comment in `vc-bzr-test-bug9726'.
+        (push (format "BZR_HOME=%s" tempdir) process-environment)
+        (push (format "HOME=%s" tempdir) process-environment ))
       (unwind-protect
           (progn
             ;; Cleanup.