From ed80d6d88cd8c14fd585390a1fa622ba4f7a67d0 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Wed, 4 Sep 2019 14:13:13 +0200 Subject: [PATCH] Further work on Bug#37202 * test/lisp/shadowfile-tests.el (shadow-debug): Set to t. (shadow--tests-cleanup): Simplify. (shadow-test*): Call `shadow-initialize'. (shadow-test08-shadow-todo, shadow-test09-shadow-copy-files): In cleanup, kill buffers used for test. (top): Do not initialize. --- test/lisp/shadowfile-tests.el | 63 +++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/test/lisp/shadowfile-tests.el b/test/lisp/shadowfile-tests.el index 5ab663c69b3..a523a340a40 100644 --- a/test/lisp/shadowfile-tests.el +++ b/test/lisp/shadowfile-tests.el @@ -64,7 +64,7 @@ "Temporary directory for Tramp tests.") (setq password-cache-expiry nil - shadow-debug nil + shadow-debug t tramp-verbose 0 tramp-message-show-message nil) @@ -92,11 +92,11 @@ (set-buffer-modified-p nil) (kill-buffer)) ;; Delete buffers. - (when (buffer-live-p shadow-info-buffer) + (ignore-errors (with-current-buffer shadow-info-buffer (set-buffer-modified-p nil) (kill-buffer))) - (when (buffer-live-p shadow-todo-buffer) + (ignore-errors (with-current-buffer shadow-todo-buffer (set-buffer-modified-p nil) (kill-buffer))) @@ -131,8 +131,9 @@ guaranteed by the originator of a cluster definition." ((symbol-function 'read-string) (lambda (&rest args) (pop mocked-input)))) - ;; Cleanup. + ;; Cleanup & initialize. (shadow--tests-cleanup) + (shadow-initialize) ;; Define a cluster. (setq cluster "cluster" @@ -247,8 +248,9 @@ guaranteed by the originator of a cluster definition." ((symbol-function 'read-string) (lambda (&rest args) (pop mocked-input)))) - ;; Cleanup. + ;; Cleanup & initialize. (shadow--tests-cleanup) + (shadow-initialize) ;; Define a cluster. (setq cluster1 "cluster1" @@ -342,8 +344,10 @@ guaranteed by the originator of a cluster definition." cluster primary regexp file hup) (unwind-protect (progn - ;; Cleanup. + + ;; Cleanup & initialize. (shadow--tests-cleanup) + (shadow-initialize) ;; Define a cluster. (setq cluster "cluster" @@ -412,8 +416,10 @@ guaranteed by the originator of a cluster definition." cluster primary regexp file1 file2) (unwind-protect (progn - ;; Cleanup. + + ;; Cleanup & initialize. (shadow--tests-cleanup) + (shadow-initialize) ;; Define a cluster. (setq cluster "cluster" @@ -477,8 +483,10 @@ guaranteed by the originator of a cluster definition." cluster primary regexp file) (unwind-protect (progn - ;; Cleanup. + + ;; Cleanup & initialize. (shadow--tests-cleanup) + (shadow-initialize) ;; Define a cluster. (setq cluster "cluster" @@ -532,8 +540,10 @@ guaranteed by the originator of a cluster definition." cluster primary regexp file) (unwind-protect (progn - ;; Cleanup. + + ;; Cleanup & initialize. (shadow--tests-cleanup) + (shadow-initialize) ;; Define a cluster. (setq cluster "cluster" @@ -591,8 +601,9 @@ guaranteed by the originator of a cluster definition." ((symbol-function 'read-string) (lambda (&rest args) (pop mocked-input)))) - ;; Cleanup. + ;; Cleanup & initialize. (shadow--tests-cleanup) + (shadow-initialize) ;; Define clusters. (setq cluster1 "cluster1" @@ -651,8 +662,9 @@ guaranteed by the originator of a cluster definition." ((symbol-function 'read-string) (lambda (&rest args) (pop mocked-input)))) - ;; Cleanup. + ;; Cleanup & initialize. (shadow--tests-cleanup) + (shadow-initialize) ;; Define clusters. (setq cluster1 "cluster1" @@ -710,8 +722,10 @@ guaranteed by the originator of a cluster definition." cluster1 cluster2 primary regexp file) (unwind-protect (progn - ;; Cleanup. + + ;; Cleanup & initialize. (shadow--tests-cleanup) + (shadow-initialize) ;; Define clusters. (setq cluster1 "cluster1" @@ -817,8 +831,12 @@ guaranteed by the originator of a cluster definition." shadow-files-to-copy))) ;; Cleanup. - (ignore-errors (delete-file file)) - (ignore-errors (delete-file (concat (shadow-site-primary cluster2) file))) + (dolist (elt `(,file ,(concat (shadow-site-primary cluster2) file))) + (ignore-errors + (with-current-buffer (get-file-buffer elt) + (set-buffer-modified-p nil) + (kill-buffer))) + (ignore-errors (delete-file elt))) (shadow--tests-cleanup)))) (ert-deftest shadow-test09-shadow-copy-files () @@ -836,8 +854,10 @@ guaranteed by the originator of a cluster definition." cluster1 cluster2 primary regexp file mocked-input) (unwind-protect (progn - ;; Cleanup. + + ;; Cleanup & initialize. (shadow--tests-cleanup) + (shadow-initialize) ;; Define clusters. (setq cluster1 "cluster1" @@ -894,8 +914,12 @@ guaranteed by the originator of a cluster definition." ;; Cleanup. (remove-function (symbol-function 'write-region) "write-region-mock") - (ignore-errors (delete-file file)) - (ignore-errors (delete-file (concat (shadow-site-primary cluster2) file))) + (dolist (elt `(,file ,(concat (shadow-site-primary cluster2) file))) + (ignore-errors + (with-current-buffer (get-file-buffer elt) + (set-buffer-modified-p nil) + (kill-buffer))) + (ignore-errors (delete-file elt))) (shadow--tests-cleanup)))) (defun shadowfile-test-all (&optional interactive) @@ -905,10 +929,5 @@ guaranteed by the originator of a cluster definition." (ert-run-tests-interactively "^shadowfile-") (ert-run-tests-batch "^shadowfile-"))) -(let ((shadow-info-file shadow-test-info-file) - (shadow-todo-file shadow-test-todo-file)) - (shadow--tests-cleanup) - (shadow-initialize)) - (provide 'shadowfile-tests) ;;; shadowfile-tests.el ends here -- 2.39.5