From: Basil L. Contovounesios Date: Mon, 10 Apr 2023 09:23:06 +0000 (+0100) Subject: Tweak file/dir creation in eglot-tests X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=44cc54e409943275f4a600136bf5136e9c655626;p=emacs.git Tweak file/dir creation in eglot-tests * test/lisp/progmodes/eglot-tests.el (eglot--make-file-or-dir): Expand file name only once, under default-directory, avoiding duplicate dir separators. Ensure default-directory ends with a dir separator. Use with-temp-file. (Bug#61637) --- diff --git a/test/lisp/progmodes/eglot-tests.el b/test/lisp/progmodes/eglot-tests.el index 86e7b21def0..0486c938558 100644 --- a/test/lisp/progmodes/eglot-tests.el +++ b/test/lisp/progmodes/eglot-tests.el @@ -70,17 +70,16 @@ directory hierarchy." `(eglot--call-with-fixture ,fixture (lambda () ,@body))) (defun eglot--make-file-or-dir (ass) - (let ((file-or-dir-name (car ass)) + (let ((file-or-dir-name (expand-file-name (car ass))) (content (cdr ass))) (cond ((listp content) (make-directory file-or-dir-name 'parents) - (let ((default-directory (concat default-directory "/" file-or-dir-name))) + (let ((default-directory (file-name-as-directory file-or-dir-name))) (mapcan #'eglot--make-file-or-dir content))) ((stringp content) - (with-temp-buffer - (insert content) - (write-region nil nil file-or-dir-name nil 'nomessage)) - (list (expand-file-name file-or-dir-name))) + (with-temp-file file-or-dir-name + (insert content)) + (list file-or-dir-name)) (t (eglot--error "Expected a string or a directory spec")))))