]> git.eshelyaron.com Git - emacs.git/commitdiff
Further work on Bug#37202
authorMichael Albinus <michael.albinus@gmx.de>
Wed, 4 Sep 2019 12:13:13 +0000 (14:13 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Wed, 4 Sep 2019 12:13:13 +0000 (14:13 +0200)
* 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

index 5ab663c69b3160f3eae729a5c68c91cf3483318b..a523a340a40c0893ec38c94c815c21104394a143 100644 (file)
@@ -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)
 
     (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