From: Michael Albinus Date: Wed, 1 Jun 2022 16:36:35 +0000 (+0200) Subject: Make files-tests.el more robust X-Git-Tag: emacs-29.0.90~1910^2~295^2~6 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=84e122dc9676f1bcf36db62f313b0343a073982b;p=emacs.git Make files-tests.el more robust * test/lisp/files-tests.el (files-tests--with-temp-non-special) (files-tests--with-temp-non-special-and-file-name-handler): Make it more robust wrt parallel test jobs. (Bug#55706) --- diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 978f96912fb..c7ce03cc9b2 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -393,6 +393,8 @@ After evaluating BODY, the temporary file or directory is deleted." (cl-check-type name symbol) (cl-check-type non-special-name symbol) `(let* ((temporary-file-directory (file-truename temporary-file-directory)) + (temporary-file-directory + (file-name-as-directory (make-temp-file "files-tests" t))) (,name (make-temp-file "files-tests" ,dir-flag)) (,non-special-name (file-name-quote ,name))) (unwind-protect @@ -402,7 +404,9 @@ After evaluating BODY, the temporary file or directory is deleted." (delete-file ,name))) (when (file-exists-p ,non-special-name) (if ,dir-flag (delete-directory ,non-special-name t) - (delete-file ,non-special-name)))))) + (delete-file ,non-special-name))) + (when (file-exists-p temporary-file-directory) + (delete-directory temporary-file-directory t))))) (defconst files-tests--special-file-name-extension ".special" "Trailing string for test file name handler.") @@ -444,14 +448,16 @@ unquoted file names." (cl-check-type name symbol) (cl-check-type non-special-name symbol) `(let* ((temporary-file-directory (file-truename temporary-file-directory)) + (temporary-file-directory + (file-name-as-directory (make-temp-file "files-tests" t))) (file-name-handler-alist `((,files-tests--special-file-name-regexp . files-tests--special-file-name-handler) . ,file-name-handler-alist)) - (,name (concat + (,name (concat (make-temp-file "files-tests" ,dir-flag) files-tests--special-file-name-extension)) - (,non-special-name (file-name-quote ,name))) + (,non-special-name (file-name-quote ,name))) (unwind-protect (progn ,@body) (when (file-exists-p ,name) @@ -459,7 +465,9 @@ unquoted file names." (delete-file ,name))) (when (file-exists-p ,non-special-name) (if ,dir-flag (delete-directory ,non-special-name t) - (delete-file ,non-special-name)))))) + (delete-file ,non-special-name))) + (when (file-exists-p temporary-file-directory) + (delete-directory temporary-file-directory t))))) (defun files-tests--new-name (name part) (let (file-name-handler-alist)