diff options
| author | João Távora | 2023-03-04 19:14:48 +0000 |
|---|---|---|
| committer | João Távora | 2023-03-04 19:15:48 +0000 |
| commit | a7cd125d490295eb24edf43119f3d3511c3dfddd (patch) | |
| tree | d769848082ad1b7943ec0139532dee84c2c323ad /test | |
| parent | 6c66dbd02c7773a4347583b35b8caa219df30807 (diff) | |
| download | emacs-a7cd125d490295eb24edf43119f3d3511c3dfddd.tar.gz emacs-a7cd125d490295eb24edf43119f3d3511c3dfddd.zip | |
More robustly unspoof HOME in Eglot tests (bug#61637)
A fair number of LSP servers allow user-local installations instead of
system wide installations. Emacs's technique of spoofing the HOME env
var to some non-existent or non-home directory during 'make check'
breaks these tests. That's because the executables are still found by
executable-find, but their invocation will rarely be successful as
HOME isn't what they expect it to be.
Eglot tests already had a technique for dealing with this,
"unspoffing" HOME just for the invocations of LSP server but it
stopped working a while back. So make it more robust.
Eventually, we'll want to decide wether these local servers should be
considered in 'make check' runs at all, or whether there is a way to
use them with a spoofed HOME.
* test/lisp/progmodes/eglot-tests.el (eglot--call-with-fixture):
More robustly unspoof HOME.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/progmodes/eglot-tests.el | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/test/lisp/progmodes/eglot-tests.el b/test/lisp/progmodes/eglot-tests.el index 5d5de59a19a..7a90d68d213 100644 --- a/test/lisp/progmodes/eglot-tests.el +++ b/test/lisp/progmodes/eglot-tests.el | |||
| @@ -103,22 +103,21 @@ then restored." | |||
| 103 | (set (car spec) (cadr spec))) | 103 | (set (car spec) (cadr spec))) |
| 104 | ((stringp (car spec)) (push spec file-specs)))) | 104 | ((stringp (car spec)) (push spec file-specs)))) |
| 105 | (unwind-protect | 105 | (unwind-protect |
| 106 | (let* ((home (getenv "HOME")) | 106 | (let* ((process-environment |
| 107 | (process-environment | ||
| 108 | (append | 107 | (append |
| 109 | `(;; Set XDF_CONFIG_HOME to /dev/null to prevent | 108 | `(;; Set XDF_CONFIG_HOME to /dev/null to prevent |
| 110 | ;; user-configuration to have an influence on | 109 | ;; user-configuration to have an influence on |
| 111 | ;; language servers. (See github#441) | 110 | ;; language servers. (See github#441) |
| 112 | "XDG_CONFIG_HOME=/dev/null" | 111 | "XDG_CONFIG_HOME=/dev/null" |
| 113 | ;; ... on the flip-side, a similar technique by | 112 | ;; ... on the flip-side, a similar technique by |
| 114 | ;; Emacs's test makefiles means that HOME is set to | 113 | ;; Emacs's test makefiles means that HOME is |
| 115 | ;; /nonexistent. This breaks some common | 114 | ;; spoofed to /nonexistent, or sometimes /tmp. |
| 116 | ;; installations for LSP servers like pylsp, making | 115 | ;; This breaks some common installations for LSP |
| 117 | ;; these tests mostly useless, so we hack around it | 116 | ;; servers like pylsp, rust-analyzer making these |
| 118 | ;; here with a great big hack. | 117 | ;; tests mostly useless, so we hack around it here |
| 118 | ;; with a great big hack. | ||
| 119 | ,(format "HOME=%s" | 119 | ,(format "HOME=%s" |
| 120 | (if (file-exists-p home) home | 120 | (expand-file-name (format "~%s" (user-login-name))))) |
| 121 | (format "/home/%s" (getenv "USER"))))) | ||
| 122 | process-environment)) | 121 | process-environment)) |
| 123 | ;; Prevent "Can't guess python-indent-offset ..." messages. | 122 | ;; Prevent "Can't guess python-indent-offset ..." messages. |
| 124 | (python-indent-guess-indent-offset-verbose . nil) | 123 | (python-indent-guess-indent-offset-verbose . nil) |