diff options
| author | Michael Albinus | 2019-09-03 13:55:42 +0200 |
|---|---|---|
| committer | Michael Albinus | 2019-09-03 13:55:42 +0200 |
| commit | ea5d591f29ba2e9e5d31da7ad450b958a4c9ca03 (patch) | |
| tree | b93ed8c3561205e249153eb24213cb71dea74267 | |
| parent | fda015e7b82a1ec3d1cb075799a67772744ce6c1 (diff) | |
| download | emacs-ea5d591f29ba2e9e5d31da7ad450b958a4c9ca03.tar.gz emacs-ea5d591f29ba2e9e5d31da7ad450b958a4c9ca03.zip | |
Fix Bug#37202
* lisp/shadowfile.el (shadow-debug): New defvar.
(shadow-read-files): Suppress error if there's no TODO file.
* test/lisp/shadowfile-tests.el (shadow-debug): Set to nil.
(shadow--tests-cleanup): New defun. Apply to all tests. (Bug#37202)
(shadow-test06-literal-groups): Cleanup temp buffer.
(shadow-test08-shadow-todo): Add debug messages.
(top): Cleanup initially.
| -rw-r--r-- | lisp/shadowfile.el | 5 | ||||
| -rw-r--r-- | test/lisp/shadowfile-tests.el | 186 |
2 files changed, 94 insertions, 97 deletions
diff --git a/lisp/shadowfile.el b/lisp/shadowfile.el index 07e78506654..4566ea19f8d 100644 --- a/lisp/shadowfile.el +++ b/lisp/shadowfile.el | |||
| @@ -165,6 +165,9 @@ created by `shadow-define-regexp-group'.") | |||
| 165 | (defvar shadow-info-buffer nil) ; buf visiting shadow-info-file | 165 | (defvar shadow-info-buffer nil) ; buf visiting shadow-info-file |
| 166 | (defvar shadow-todo-buffer nil) ; buf visiting shadow-todo-file | 166 | (defvar shadow-todo-buffer nil) ; buf visiting shadow-todo-file |
| 167 | 167 | ||
| 168 | (defvar shadow-debug nil | ||
| 169 | "Use for debug messages.") | ||
| 170 | |||
| 168 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 171 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 169 | ;;; Syntactic sugar; General list and string manipulation | 172 | ;;; Syntactic sugar; General list and string manipulation |
| 170 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 173 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| @@ -673,7 +676,7 @@ Return t unless files were locked; then return nil." | |||
| 673 | (eval-buffer)) | 676 | (eval-buffer)) |
| 674 | (when shadow-todo-file | 677 | (when shadow-todo-file |
| 675 | (set-buffer (setq shadow-todo-buffer | 678 | (set-buffer (setq shadow-todo-buffer |
| 676 | (find-file-noselect shadow-todo-file))) | 679 | (find-file-noselect shadow-todo-file 'nowarn))) |
| 677 | (when (and (not (buffer-modified-p)) | 680 | (when (and (not (buffer-modified-p)) |
| 678 | (file-newer-than-file-p (make-auto-save-file-name) | 681 | (file-newer-than-file-p (make-auto-save-file-name) |
| 679 | shadow-todo-file)) | 682 | shadow-todo-file)) |
diff --git a/test/lisp/shadowfile-tests.el b/test/lisp/shadowfile-tests.el index 2a777af4720..5ab663c69b3 100644 --- a/test/lisp/shadowfile-tests.el +++ b/test/lisp/shadowfile-tests.el | |||
| @@ -64,6 +64,7 @@ | |||
| 64 | "Temporary directory for Tramp tests.") | 64 | "Temporary directory for Tramp tests.") |
| 65 | 65 | ||
| 66 | (setq password-cache-expiry nil | 66 | (setq password-cache-expiry nil |
| 67 | shadow-debug nil | ||
| 67 | tramp-verbose 0 | 68 | tramp-verbose 0 |
| 68 | tramp-message-show-message nil) | 69 | tramp-message-show-message nil) |
| 69 | 70 | ||
| @@ -79,6 +80,35 @@ | |||
| 79 | (expand-file-name "shadow_todo_test" temporary-file-directory) | 80 | (expand-file-name "shadow_todo_test" temporary-file-directory) |
| 80 | "File to store the list of uncopied shadows in during tests.") | 81 | "File to store the list of uncopied shadows in during tests.") |
| 81 | 82 | ||
| 83 | (defun shadow--tests-cleanup () | ||
| 84 | "Reset all `shadowfile' internals." | ||
| 85 | ;; Delete auto-saved files. | ||
| 86 | (with-current-buffer (find-file-noselect shadow-info-file 'nowarn) | ||
| 87 | (ignore-errors (delete-file (make-auto-save-file-name))) | ||
| 88 | (set-buffer-modified-p nil) | ||
| 89 | (kill-buffer)) | ||
| 90 | (with-current-buffer (find-file-noselect shadow-todo-file 'nowarn) | ||
| 91 | (ignore-errors (delete-file (make-auto-save-file-name))) | ||
| 92 | (set-buffer-modified-p nil) | ||
| 93 | (kill-buffer)) | ||
| 94 | ;; Delete buffers. | ||
| 95 | (when (buffer-live-p shadow-info-buffer) | ||
| 96 | (with-current-buffer shadow-info-buffer | ||
| 97 | (set-buffer-modified-p nil) | ||
| 98 | (kill-buffer))) | ||
| 99 | (when (buffer-live-p shadow-todo-buffer) | ||
| 100 | (with-current-buffer shadow-todo-buffer | ||
| 101 | (set-buffer-modified-p nil) | ||
| 102 | (kill-buffer))) | ||
| 103 | ;; Delete files. | ||
| 104 | (ignore-errors (delete-file shadow-info-file)) | ||
| 105 | (ignore-errors (delete-file shadow-todo-file)) | ||
| 106 | ;; Reset variables. | ||
| 107 | (setq shadow-info-buffer nil | ||
| 108 | shadow-hashtable nil | ||
| 109 | shadow-todo-buffer nil | ||
| 110 | shadow-files-to-copy nil)) | ||
| 111 | |||
| 82 | (ert-deftest shadow-test00-clusters () | 112 | (ert-deftest shadow-test00-clusters () |
| 83 | "Check cluster definitions. | 113 | "Check cluster definitions. |
| 84 | Per definition, all files are identical on the different hosts of | 114 | Per definition, all files are identical on the different hosts of |
| @@ -101,11 +131,8 @@ guaranteed by the originator of a cluster definition." | |||
| 101 | ((symbol-function 'read-string) | 131 | ((symbol-function 'read-string) |
| 102 | (lambda (&rest args) (pop mocked-input)))) | 132 | (lambda (&rest args) (pop mocked-input)))) |
| 103 | 133 | ||
| 104 | ;; Cleanup. | 134 | ;; Cleanup. |
| 105 | (when (file-exists-p shadow-info-file) | 135 | (shadow--tests-cleanup) |
| 106 | (delete-file shadow-info-file)) | ||
| 107 | (when (file-exists-p shadow-todo-file) | ||
| 108 | (delete-file shadow-todo-file)) | ||
| 109 | 136 | ||
| 110 | ;; Define a cluster. | 137 | ;; Define a cluster. |
| 111 | (setq cluster "cluster" | 138 | (setq cluster "cluster" |
| @@ -198,10 +225,7 @@ guaranteed by the originator of a cluster definition." | |||
| 198 | 225 | ||
| 199 | ;; Cleanup. | 226 | ;; Cleanup. |
| 200 | (with-current-buffer (messages-buffer) (widen)) | 227 | (with-current-buffer (messages-buffer) (widen)) |
| 201 | (when (file-exists-p shadow-info-file) | 228 | (shadow--tests-cleanup)))) |
| 202 | (delete-file shadow-info-file)) | ||
| 203 | (when (file-exists-p shadow-todo-file) | ||
| 204 | (delete-file shadow-todo-file))))) | ||
| 205 | 229 | ||
| 206 | (ert-deftest shadow-test01-sites () | 230 | (ert-deftest shadow-test01-sites () |
| 207 | "Check site definitions. | 231 | "Check site definitions. |
| @@ -224,10 +248,7 @@ guaranteed by the originator of a cluster definition." | |||
| 224 | (lambda (&rest args) (pop mocked-input)))) | 248 | (lambda (&rest args) (pop mocked-input)))) |
| 225 | 249 | ||
| 226 | ;; Cleanup. | 250 | ;; Cleanup. |
| 227 | (when (file-exists-p shadow-info-file) | 251 | (shadow--tests-cleanup) |
| 228 | (delete-file shadow-info-file)) | ||
| 229 | (when (file-exists-p shadow-todo-file) | ||
| 230 | (delete-file shadow-todo-file)) | ||
| 231 | 252 | ||
| 232 | ;; Define a cluster. | 253 | ;; Define a cluster. |
| 233 | (setq cluster1 "cluster1" | 254 | (setq cluster1 "cluster1" |
| @@ -308,10 +329,7 @@ guaranteed by the originator of a cluster definition." | |||
| 308 | (shadow-site-match (shadow-site-primary cluster1) cluster2))) | 329 | (shadow-site-match (shadow-site-primary cluster1) cluster2))) |
| 309 | 330 | ||
| 310 | ;; Cleanup. | 331 | ;; Cleanup. |
| 311 | (when (file-exists-p shadow-info-file) | 332 | (shadow--tests-cleanup)))) |
| 312 | (delete-file shadow-info-file)) | ||
| 313 | (when (file-exists-p shadow-todo-file) | ||
| 314 | (delete-file shadow-todo-file))))) | ||
| 315 | 333 | ||
| 316 | (ert-deftest shadow-test02-files () | 334 | (ert-deftest shadow-test02-files () |
| 317 | "Check file manipulation functions." | 335 | "Check file manipulation functions." |
| @@ -325,10 +343,7 @@ guaranteed by the originator of a cluster definition." | |||
| 325 | (unwind-protect | 343 | (unwind-protect |
| 326 | (progn | 344 | (progn |
| 327 | ;; Cleanup. | 345 | ;; Cleanup. |
| 328 | (when (file-exists-p shadow-info-file) | 346 | (shadow--tests-cleanup) |
| 329 | (delete-file shadow-info-file)) | ||
| 330 | (when (file-exists-p shadow-todo-file) | ||
| 331 | (delete-file shadow-todo-file)) | ||
| 332 | 347 | ||
| 333 | ;; Define a cluster. | 348 | ;; Define a cluster. |
| 334 | (setq cluster "cluster" | 349 | (setq cluster "cluster" |
| @@ -384,10 +399,7 @@ guaranteed by the originator of a cluster definition." | |||
| 384 | (should-not (shadow-local-file nil))) | 399 | (should-not (shadow-local-file nil))) |
| 385 | 400 | ||
| 386 | ;; Cleanup. | 401 | ;; Cleanup. |
| 387 | (when (file-exists-p shadow-info-file) | 402 | (shadow--tests-cleanup)))) |
| 388 | (delete-file shadow-info-file)) | ||
| 389 | (when (file-exists-p shadow-todo-file) | ||
| 390 | (delete-file shadow-todo-file))))) | ||
| 391 | 403 | ||
| 392 | (ert-deftest shadow-test03-expand-cluster-in-file-name () | 404 | (ert-deftest shadow-test03-expand-cluster-in-file-name () |
| 393 | "Check canonical file name of a cluster or site." | 405 | "Check canonical file name of a cluster or site." |
| @@ -401,10 +413,7 @@ guaranteed by the originator of a cluster definition." | |||
| 401 | (unwind-protect | 413 | (unwind-protect |
| 402 | (progn | 414 | (progn |
| 403 | ;; Cleanup. | 415 | ;; Cleanup. |
| 404 | (when (file-exists-p shadow-info-file) | 416 | (shadow--tests-cleanup) |
| 405 | (delete-file shadow-info-file)) | ||
| 406 | (when (file-exists-p shadow-todo-file) | ||
| 407 | (delete-file shadow-todo-file)) | ||
| 408 | 417 | ||
| 409 | ;; Define a cluster. | 418 | ;; Define a cluster. |
| 410 | (setq cluster "cluster" | 419 | (setq cluster "cluster" |
| @@ -455,10 +464,7 @@ guaranteed by the originator of a cluster definition." | |||
| 455 | (concat primary file1)))) | 464 | (concat primary file1)))) |
| 456 | 465 | ||
| 457 | ;; Cleanup. | 466 | ;; Cleanup. |
| 458 | (when (file-exists-p shadow-info-file) | 467 | (shadow--tests-cleanup)))) |
| 459 | (delete-file shadow-info-file)) | ||
| 460 | (when (file-exists-p shadow-todo-file) | ||
| 461 | (delete-file shadow-todo-file))))) | ||
| 462 | 468 | ||
| 463 | (ert-deftest shadow-test04-contract-file-name () | 469 | (ert-deftest shadow-test04-contract-file-name () |
| 464 | "Check canonical file name of a cluster or site." | 470 | "Check canonical file name of a cluster or site." |
| @@ -472,10 +478,7 @@ guaranteed by the originator of a cluster definition." | |||
| 472 | (unwind-protect | 478 | (unwind-protect |
| 473 | (progn | 479 | (progn |
| 474 | ;; Cleanup. | 480 | ;; Cleanup. |
| 475 | (when (file-exists-p shadow-info-file) | 481 | (shadow--tests-cleanup) |
| 476 | (delete-file shadow-info-file)) | ||
| 477 | (when (file-exists-p shadow-todo-file) | ||
| 478 | (delete-file shadow-todo-file)) | ||
| 479 | 482 | ||
| 480 | ;; Define a cluster. | 483 | ;; Define a cluster. |
| 481 | (setq cluster "cluster" | 484 | (setq cluster "cluster" |
| @@ -516,10 +519,7 @@ guaranteed by the originator of a cluster definition." | |||
| 516 | (concat "/cluster:" file)))) | 519 | (concat "/cluster:" file)))) |
| 517 | 520 | ||
| 518 | ;; Cleanup. | 521 | ;; Cleanup. |
| 519 | (when (file-exists-p shadow-info-file) | 522 | (shadow--tests-cleanup)))) |
| 520 | (delete-file shadow-info-file)) | ||
| 521 | (when (file-exists-p shadow-todo-file) | ||
| 522 | (delete-file shadow-todo-file))))) | ||
| 523 | 523 | ||
| 524 | (ert-deftest shadow-test05-file-match () | 524 | (ert-deftest shadow-test05-file-match () |
| 525 | "Check `shadow-same-site' and `shadow-file-match'." | 525 | "Check `shadow-same-site' and `shadow-file-match'." |
| @@ -533,10 +533,7 @@ guaranteed by the originator of a cluster definition." | |||
| 533 | (unwind-protect | 533 | (unwind-protect |
| 534 | (progn | 534 | (progn |
| 535 | ;; Cleanup. | 535 | ;; Cleanup. |
| 536 | (when (file-exists-p shadow-info-file) | 536 | (shadow--tests-cleanup) |
| 537 | (delete-file shadow-info-file)) | ||
| 538 | (when (file-exists-p shadow-todo-file) | ||
| 539 | (delete-file shadow-todo-file)) | ||
| 540 | 537 | ||
| 541 | ;; Define a cluster. | 538 | ;; Define a cluster. |
| 542 | (setq cluster "cluster" | 539 | (setq cluster "cluster" |
| @@ -575,10 +572,7 @@ guaranteed by the originator of a cluster definition." | |||
| 575 | file))) | 572 | file))) |
| 576 | 573 | ||
| 577 | ;; Cleanup. | 574 | ;; Cleanup. |
| 578 | (when (file-exists-p shadow-info-file) | 575 | (shadow--tests-cleanup)))) |
| 579 | (delete-file shadow-info-file)) | ||
| 580 | (when (file-exists-p shadow-todo-file) | ||
| 581 | (delete-file shadow-todo-file))))) | ||
| 582 | 576 | ||
| 583 | (ert-deftest shadow-test06-literal-groups () | 577 | (ert-deftest shadow-test06-literal-groups () |
| 584 | "Check literal group definitions." | 578 | "Check literal group definitions." |
| @@ -598,10 +592,7 @@ guaranteed by the originator of a cluster definition." | |||
| 598 | (lambda (&rest args) (pop mocked-input)))) | 592 | (lambda (&rest args) (pop mocked-input)))) |
| 599 | 593 | ||
| 600 | ;; Cleanup. | 594 | ;; Cleanup. |
| 601 | (when (file-exists-p shadow-info-file) | 595 | (shadow--tests-cleanup) |
| 602 | (delete-file shadow-info-file)) | ||
| 603 | (when (file-exists-p shadow-todo-file) | ||
| 604 | (delete-file shadow-todo-file)) | ||
| 605 | 596 | ||
| 606 | ;; Define clusters. | 597 | ;; Define clusters. |
| 607 | (setq cluster1 "cluster1" | 598 | (setq cluster1 "cluster1" |
| @@ -627,7 +618,8 @@ guaranteed by the originator of a cluster definition." | |||
| 627 | mocked-input `(,cluster1 ,file1 ,cluster2 ,file2 ,(kbd "RET"))) | 618 | mocked-input `(,cluster1 ,file1 ,cluster2 ,file2 ,(kbd "RET"))) |
| 628 | (with-temp-buffer | 619 | (with-temp-buffer |
| 629 | (set-visited-file-name file1) | 620 | (set-visited-file-name file1) |
| 630 | (call-interactively 'shadow-define-literal-group)) | 621 | (call-interactively 'shadow-define-literal-group) |
| 622 | (set-buffer-modified-p nil)) | ||
| 631 | 623 | ||
| 632 | ;; `shadow-literal-groups' is a list of lists. | 624 | ;; `shadow-literal-groups' is a list of lists. |
| 633 | (should (consp shadow-literal-groups)) | 625 | (should (consp shadow-literal-groups)) |
| @@ -640,10 +632,7 @@ guaranteed by the originator of a cluster definition." | |||
| 640 | (car shadow-literal-groups)))) | 632 | (car shadow-literal-groups)))) |
| 641 | 633 | ||
| 642 | ;; Cleanup. | 634 | ;; Cleanup. |
| 643 | (when (file-exists-p shadow-info-file) | 635 | (shadow--tests-cleanup)))) |
| 644 | (delete-file shadow-info-file)) | ||
| 645 | (when (file-exists-p shadow-todo-file) | ||
| 646 | (delete-file shadow-todo-file))))) | ||
| 647 | 636 | ||
| 648 | (ert-deftest shadow-test07-regexp-groups () | 637 | (ert-deftest shadow-test07-regexp-groups () |
| 649 | "Check regexp group definitions." | 638 | "Check regexp group definitions." |
| @@ -663,10 +652,7 @@ guaranteed by the originator of a cluster definition." | |||
| 663 | (lambda (&rest args) (pop mocked-input)))) | 652 | (lambda (&rest args) (pop mocked-input)))) |
| 664 | 653 | ||
| 665 | ;; Cleanup. | 654 | ;; Cleanup. |
| 666 | (when (file-exists-p shadow-info-file) | 655 | (shadow--tests-cleanup) |
| 667 | (delete-file shadow-info-file)) | ||
| 668 | (when (file-exists-p shadow-todo-file) | ||
| 669 | (delete-file shadow-todo-file)) | ||
| 670 | 656 | ||
| 671 | ;; Define clusters. | 657 | ;; Define clusters. |
| 672 | (setq cluster1 "cluster1" | 658 | (setq cluster1 "cluster1" |
| @@ -707,10 +693,7 @@ guaranteed by the originator of a cluster definition." | |||
| 707 | (car shadow-regexp-groups)))) | 693 | (car shadow-regexp-groups)))) |
| 708 | 694 | ||
| 709 | ;; Cleanup. | 695 | ;; Cleanup. |
| 710 | (when (file-exists-p shadow-info-file) | 696 | (shadow--tests-cleanup)))) |
| 711 | (delete-file shadow-info-file)) | ||
| 712 | (when (file-exists-p shadow-todo-file) | ||
| 713 | (delete-file shadow-todo-file))))) | ||
| 714 | 697 | ||
| 715 | (ert-deftest shadow-test08-shadow-todo () | 698 | (ert-deftest shadow-test08-shadow-todo () |
| 716 | "Check that needed shadows are added to todo." | 699 | "Check that needed shadows are added to todo." |
| @@ -728,22 +711,23 @@ guaranteed by the originator of a cluster definition." | |||
| 728 | (unwind-protect | 711 | (unwind-protect |
| 729 | (progn | 712 | (progn |
| 730 | ;; Cleanup. | 713 | ;; Cleanup. |
| 731 | (when (file-exists-p shadow-info-file) | 714 | (shadow--tests-cleanup) |
| 732 | (delete-file shadow-info-file)) | ||
| 733 | (when (file-exists-p shadow-todo-file) | ||
| 734 | (delete-file shadow-todo-file)) | ||
| 735 | 715 | ||
| 736 | ;; Define clusters. | 716 | ;; Define clusters. |
| 737 | (setq cluster1 "cluster1" | 717 | (setq cluster1 "cluster1" |
| 738 | primary shadow-system-name | 718 | primary shadow-system-name |
| 739 | regexp (shadow-regexp-superquote primary)) | 719 | regexp (shadow-regexp-superquote primary)) |
| 740 | (shadow-set-cluster cluster1 primary regexp) | 720 | (shadow-set-cluster cluster1 primary regexp) |
| 721 | (when shadow-debug | ||
| 722 | (message "%s %s %s %s" cluster1 primary regexp shadow-clusters)) | ||
| 741 | 723 | ||
| 742 | (setq cluster2 "cluster2" | 724 | (setq cluster2 "cluster2" |
| 743 | primary | 725 | primary |
| 744 | (file-remote-p shadow-test-remote-temporary-file-directory) | 726 | (file-remote-p shadow-test-remote-temporary-file-directory) |
| 745 | regexp (shadow-regexp-superquote primary)) | 727 | regexp (shadow-regexp-superquote primary)) |
| 746 | (shadow-set-cluster cluster2 primary regexp) | 728 | (shadow-set-cluster cluster2 primary regexp) |
| 729 | (when shadow-debug | ||
| 730 | (message "%s %s %s %s" cluster2 primary regexp shadow-clusters)) | ||
| 747 | 731 | ||
| 748 | ;; Define a literal group. | 732 | ;; Define a literal group. |
| 749 | (setq file | 733 | (setq file |
| @@ -751,12 +735,19 @@ guaranteed by the originator of a cluster definition." | |||
| 751 | (expand-file-name "shadowfile-tests" temporary-file-directory)) | 735 | (expand-file-name "shadowfile-tests" temporary-file-directory)) |
| 752 | shadow-literal-groups | 736 | shadow-literal-groups |
| 753 | `((,(concat "/cluster1:" file) ,(concat "/cluster2:" file)))) | 737 | `((,(concat "/cluster1:" file) ,(concat "/cluster2:" file)))) |
| 738 | (when shadow-debug | ||
| 739 | (message "%s %s" file shadow-literal-groups)) | ||
| 754 | 740 | ||
| 755 | ;; Save file from "cluster1" definition. | 741 | ;; Save file from "cluster1" definition. |
| 756 | (with-temp-buffer | 742 | (with-temp-buffer |
| 757 | (set-visited-file-name file) | 743 | (set-visited-file-name file) |
| 758 | (insert "foo") | 744 | (insert "foo") |
| 759 | (save-buffer)) | 745 | (save-buffer)) |
| 746 | (when shadow-debug | ||
| 747 | (message | ||
| 748 | "%s %s" | ||
| 749 | (cons file (shadow-contract-file-name (concat "/cluster2:" file))) | ||
| 750 | shadow-files-to-copy)) | ||
| 760 | (should | 751 | (should |
| 761 | (member | 752 | (member |
| 762 | (cons file (shadow-contract-file-name (concat "/cluster2:" file))) | 753 | (cons file (shadow-contract-file-name (concat "/cluster2:" file))) |
| @@ -767,6 +758,13 @@ guaranteed by the originator of a cluster definition." | |||
| 767 | (set-visited-file-name (concat (shadow-site-primary cluster2) file)) | 758 | (set-visited-file-name (concat (shadow-site-primary cluster2) file)) |
| 768 | (insert "foo") | 759 | (insert "foo") |
| 769 | (save-buffer)) | 760 | (save-buffer)) |
| 761 | (when shadow-debug | ||
| 762 | (message | ||
| 763 | "%s %s" | ||
| 764 | (cons | ||
| 765 | (concat (shadow-site-primary cluster2) file) | ||
| 766 | (shadow-contract-file-name (concat "/cluster1:" file))) | ||
| 767 | shadow-files-to-copy)) | ||
| 770 | (should | 768 | (should |
| 771 | (member | 769 | (member |
| 772 | (cons | 770 | (cons |
| @@ -781,12 +779,19 @@ guaranteed by the originator of a cluster definition." | |||
| 781 | (shadow-regexp-superquote file)) | 779 | (shadow-regexp-superquote file)) |
| 782 | ,(concat (shadow-site-primary cluster2) | 780 | ,(concat (shadow-site-primary cluster2) |
| 783 | (shadow-regexp-superquote file))))) | 781 | (shadow-regexp-superquote file))))) |
| 782 | (when shadow-debug | ||
| 783 | (message "%s %s" file shadow-regexp-groups)) | ||
| 784 | 784 | ||
| 785 | ;; Save file from "cluster1" definition. | 785 | ;; Save file from "cluster1" definition. |
| 786 | (with-temp-buffer | 786 | (with-temp-buffer |
| 787 | (set-visited-file-name file) | 787 | (set-visited-file-name file) |
| 788 | (insert "foo") | 788 | (insert "foo") |
| 789 | (save-buffer)) | 789 | (save-buffer)) |
| 790 | (when shadow-debug | ||
| 791 | (message | ||
| 792 | "%s %s" | ||
| 793 | (cons file (shadow-contract-file-name (concat "/cluster2:" file))) | ||
| 794 | shadow-files-to-copy)) | ||
| 790 | (should | 795 | (should |
| 791 | (member | 796 | (member |
| 792 | (cons file (shadow-contract-file-name (concat "/cluster2:" file))) | 797 | (cons file (shadow-contract-file-name (concat "/cluster2:" file))) |
| @@ -797,6 +802,13 @@ guaranteed by the originator of a cluster definition." | |||
| 797 | (set-visited-file-name (concat (shadow-site-primary cluster2) file)) | 802 | (set-visited-file-name (concat (shadow-site-primary cluster2) file)) |
| 798 | (insert "foo") | 803 | (insert "foo") |
| 799 | (save-buffer)) | 804 | (save-buffer)) |
| 805 | (when shadow-debug | ||
| 806 | (message | ||
| 807 | "%s %s" | ||
| 808 | (cons | ||
| 809 | (concat (shadow-site-primary cluster2) file) | ||
| 810 | (shadow-contract-file-name (concat "/cluster1:" file))) | ||
| 811 | shadow-files-to-copy)) | ||
| 800 | (should | 812 | (should |
| 801 | (member | 813 | (member |
| 802 | (cons | 814 | (cons |
| @@ -805,16 +817,9 @@ guaranteed by the originator of a cluster definition." | |||
| 805 | shadow-files-to-copy))) | 817 | shadow-files-to-copy))) |
| 806 | 818 | ||
| 807 | ;; Cleanup. | 819 | ;; Cleanup. |
| 808 | (when (file-exists-p shadow-info-file) | 820 | (ignore-errors (delete-file file)) |
| 809 | (delete-file shadow-info-file)) | 821 | (ignore-errors (delete-file (concat (shadow-site-primary cluster2) file))) |
| 810 | (when (file-exists-p shadow-todo-file) | 822 | (shadow--tests-cleanup)))) |
| 811 | (delete-file shadow-todo-file)) | ||
| 812 | (ignore-errors | ||
| 813 | (when (file-exists-p file) | ||
| 814 | (delete-file file))) | ||
| 815 | (ignore-errors | ||
| 816 | (when (file-exists-p (concat (shadow-site-primary cluster2) file)) | ||
| 817 | (delete-file (concat (shadow-site-primary cluster2) file))))))) | ||
| 818 | 823 | ||
| 819 | (ert-deftest shadow-test09-shadow-copy-files () | 824 | (ert-deftest shadow-test09-shadow-copy-files () |
| 820 | "Check that needed shadow files are copied." | 825 | "Check that needed shadow files are copied." |
| @@ -832,12 +837,7 @@ guaranteed by the originator of a cluster definition." | |||
| 832 | (unwind-protect | 837 | (unwind-protect |
| 833 | (progn | 838 | (progn |
| 834 | ;; Cleanup. | 839 | ;; Cleanup. |
| 835 | (when (file-exists-p shadow-info-file) | 840 | (shadow--tests-cleanup) |
| 836 | (delete-file shadow-info-file)) | ||
| 837 | (when (file-exists-p shadow-todo-file) | ||
| 838 | (delete-file shadow-todo-file)) | ||
| 839 | (when (buffer-live-p shadow-todo-buffer) | ||
| 840 | (with-current-buffer shadow-todo-buffer (erase-buffer))) | ||
| 841 | 841 | ||
| 842 | ;; Define clusters. | 842 | ;; Define clusters. |
| 843 | (setq cluster1 "cluster1" | 843 | (setq cluster1 "cluster1" |
| @@ -894,16 +894,9 @@ guaranteed by the originator of a cluster definition." | |||
| 894 | 894 | ||
| 895 | ;; Cleanup. | 895 | ;; Cleanup. |
| 896 | (remove-function (symbol-function 'write-region) "write-region-mock") | 896 | (remove-function (symbol-function 'write-region) "write-region-mock") |
| 897 | (when (file-exists-p shadow-info-file) | 897 | (ignore-errors (delete-file file)) |
| 898 | (delete-file shadow-info-file)) | 898 | (ignore-errors (delete-file (concat (shadow-site-primary cluster2) file))) |
| 899 | (when (file-exists-p shadow-todo-file) | 899 | (shadow--tests-cleanup)))) |
| 900 | (delete-file shadow-todo-file)) | ||
| 901 | (ignore-errors | ||
| 902 | (when (file-exists-p file) | ||
| 903 | (delete-file file))) | ||
| 904 | (ignore-errors | ||
| 905 | (when (file-exists-p (concat (shadow-site-primary cluster2) file)) | ||
| 906 | (delete-file (concat (shadow-site-primary cluster2) file))))))) | ||
| 907 | 900 | ||
| 908 | (defun shadowfile-test-all (&optional interactive) | 901 | (defun shadowfile-test-all (&optional interactive) |
| 909 | "Run all tests for \\[shadowfile]." | 902 | "Run all tests for \\[shadowfile]." |
| @@ -914,6 +907,7 @@ guaranteed by the originator of a cluster definition." | |||
| 914 | 907 | ||
| 915 | (let ((shadow-info-file shadow-test-info-file) | 908 | (let ((shadow-info-file shadow-test-info-file) |
| 916 | (shadow-todo-file shadow-test-todo-file)) | 909 | (shadow-todo-file shadow-test-todo-file)) |
| 910 | (shadow--tests-cleanup) | ||
| 917 | (shadow-initialize)) | 911 | (shadow-initialize)) |
| 918 | 912 | ||
| 919 | (provide 'shadowfile-tests) | 913 | (provide 'shadowfile-tests) |