diff options
| author | Dmitry Gutov | 2021-08-29 03:17:08 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2021-08-29 03:17:08 +0300 |
| commit | 6d361775891956bccffcc4ba6faee58bcfc1fcea (patch) | |
| tree | 0c2c915bd112cf8ffa382898fa72f098eeac2049 | |
| parent | 692da8c6a82f8de376a2eec9304773b3e85205f3 (diff) | |
| download | emacs-6d361775891956bccffcc4ba6faee58bcfc1fcea.tar.gz emacs-6d361775891956bccffcc4ba6faee58bcfc1fcea.zip | |
Add tests for vc-rename-file
* test/lisp/vc/vc-tests.el (vc-test--rename-file): New function.
(vc-test-%s05-rename-file): New family of tests (bug#39452).
| -rw-r--r-- | test/lisp/vc/vc-tests.el | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/test/lisp/vc/vc-tests.el b/test/lisp/vc/vc-tests.el index 5430535c5ed..4f75e5ec612 100644 --- a/test/lisp/vc/vc-tests.el +++ b/test/lisp/vc/vc-tests.el | |||
| @@ -100,7 +100,7 @@ | |||
| 100 | ;; - log-edit-mode () | 100 | ;; - log-edit-mode () |
| 101 | ;; - check-headers () | 101 | ;; - check-headers () |
| 102 | ;; - delete-file (file) | 102 | ;; - delete-file (file) |
| 103 | ;; - rename-file (old new) | 103 | ;; - rename-file (old new) DONE |
| 104 | ;; - find-file-hook () | 104 | ;; - find-file-hook () |
| 105 | ;; - extra-menu () | 105 | ;; - extra-menu () |
| 106 | ;; - extra-dir-menu () | 106 | ;; - extra-dir-menu () |
| @@ -547,6 +547,56 @@ This checks also `vc-backend' and `vc-responsible-backend'." | |||
| 547 | (if tempdir (delete-directory tempdir t)) | 547 | (if tempdir (delete-directory tempdir t)) |
| 548 | (run-hooks 'vc-test--cleanup-hook))))) | 548 | (run-hooks 'vc-test--cleanup-hook))))) |
| 549 | 549 | ||
| 550 | (defun vc-test--rename-file (backend) | ||
| 551 | "Check the rename-file action." | ||
| 552 | |||
| 553 | (let ((vc-handled-backends `(,backend)) | ||
| 554 | (default-directory | ||
| 555 | (file-name-as-directory | ||
| 556 | (expand-file-name | ||
| 557 | (make-temp-name "vc-test") temporary-file-directory))) | ||
| 558 | (process-environment process-environment) | ||
| 559 | tempdir | ||
| 560 | vc-test--cleanup-hook) | ||
| 561 | (when (eq backend 'Bzr) | ||
| 562 | (setq tempdir (make-temp-file "vc-test--rename-file" t) | ||
| 563 | process-environment (cons (format "BZR_HOME=%s" tempdir) | ||
| 564 | process-environment))) | ||
| 565 | |||
| 566 | (unwind-protect | ||
| 567 | (progn | ||
| 568 | ;; Cleanup. | ||
| 569 | (add-hook | ||
| 570 | 'vc-test--cleanup-hook | ||
| 571 | `(lambda () (delete-directory ,default-directory 'recursive))) | ||
| 572 | |||
| 573 | ;; Create empty repository. | ||
| 574 | (make-directory default-directory) | ||
| 575 | (vc-test--create-repo-function backend) | ||
| 576 | |||
| 577 | (let ((tmp-name (expand-file-name "foo" default-directory)) | ||
| 578 | (new-name (expand-file-name "bar" default-directory))) | ||
| 579 | ;; Write a new file. | ||
| 580 | (write-region "foo" nil tmp-name nil 'nomessage) | ||
| 581 | |||
| 582 | ;; Register it. Renaming can fail otherwise. | ||
| 583 | (vc-register | ||
| 584 | (list backend (list (file-name-nondirectory tmp-name)))) | ||
| 585 | |||
| 586 | (vc-rename-file tmp-name new-name) | ||
| 587 | |||
| 588 | (should (not (file-exists-p tmp-name))) | ||
| 589 | (should (file-exists-p new-name)) | ||
| 590 | |||
| 591 | ;; implicit: Bzr CVS Git Hg Mtn SRC SVN | ||
| 592 | ;; locking: RCS SCCS | ||
| 593 | (should (equal (vc-state new-name) 'added)))) | ||
| 594 | |||
| 595 | ;; Save exit. | ||
| 596 | (ignore-errors | ||
| 597 | (if tempdir (delete-directory tempdir t)) | ||
| 598 | (run-hooks 'vc-test--cleanup-hook))))) | ||
| 599 | |||
| 550 | ;; Create the test cases. | 600 | ;; Create the test cases. |
| 551 | 601 | ||
| 552 | (defun vc-test--rcs-enabled () | 602 | (defun vc-test--rcs-enabled () |
| @@ -648,7 +698,20 @@ This checks also `vc-backend' and `vc-responsible-backend'." | |||
| 648 | (ert-get-test | 698 | (ert-get-test |
| 649 | ',(intern | 699 | ',(intern |
| 650 | (format "vc-test-%s01-register" backend-string)))))) | 700 | (format "vc-test-%s01-register" backend-string)))))) |
| 651 | (vc-test--checkout-model ',backend)))))) | 701 | (vc-test--checkout-model ',backend)) |
| 702 | |||
| 703 | (ert-deftest | ||
| 704 | ,(intern (format "vc-test-%s05-rename-file" backend-string)) () | ||
| 705 | ,(format "Check `vc-rename-file' for the %s backend." | ||
| 706 | backend-string) | ||
| 707 | (skip-unless | ||
| 708 | (ert-test-passed-p | ||
| 709 | (ert-test-most-recent-result | ||
| 710 | (ert-get-test | ||
| 711 | ',(intern | ||
| 712 | (format "vc-test-%s01-register" backend-string)))))) | ||
| 713 | (vc-test--rename-file ',backend)) | ||
| 714 | )))) | ||
| 652 | 715 | ||
| 653 | (provide 'vc-tests) | 716 | (provide 'vc-tests) |
| 654 | ;;; vc-tests.el ends here | 717 | ;;; vc-tests.el ends here |