Replace "Maintainer: FSF" with the emacs-devel mailing address
[emacs.git] / test / automated / vc-bzr.el
blobe2ea3f6aeeadf6932002526117bbda127141f435
1 ;;; vc-bzr.el --- tests for vc/vc-bzr.el
3 ;; Copyright (C) 2011-2014 Free Software Foundation, Inc.
5 ;; Author: Glenn Morris <rgm@gnu.org>
6 ;; Maintainer: emacs-devel@gnu.org
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;;; Code:
27 (require 'ert)
28 (require 'vc-bzr)
29 (require 'vc-dir)
31 (ert-deftest vc-bzr-test-bug9726 ()
32 "Test for http://debbugs.gnu.org/9726 ."
33 (skip-unless (executable-find vc-bzr-program))
34 (let* ((tempdir (make-temp-file "vc-bzr-test" t))
35 (ignored-dir (expand-file-name "ignored-dir" tempdir))
36 (default-directory (file-name-as-directory tempdir)))
37 (unwind-protect
38 (progn
39 (make-directory ignored-dir)
40 (with-temp-buffer
41 (insert (file-name-nondirectory ignored-dir))
42 (write-region nil nil (expand-file-name ".bzrignore" tempdir)
43 nil 'silent))
44 (call-process vc-bzr-program nil nil nil "init")
45 (call-process vc-bzr-program nil nil nil "add")
46 (call-process vc-bzr-program nil nil nil "commit" "-m" "Commit 1")
47 (with-temp-buffer
48 (insert "unregistered file")
49 (write-region nil nil (expand-file-name "testfile2" ignored-dir)
50 nil 'silent))
51 (vc-dir ignored-dir)
52 (while (vc-dir-busy)
53 (sit-for 0.1))
54 ;; FIXME better to explicitly test for error from process sentinel.
55 (with-current-buffer "*vc-dir*"
56 (goto-char (point-min))
57 (should (search-forward "unregistered" nil t))))
58 (delete-directory tempdir t))))
60 ;; Not specific to bzr.
61 (ert-deftest vc-bzr-test-bug9781 ()
62 "Test for http://debbugs.gnu.org/9781 ."
63 (skip-unless (executable-find vc-bzr-program))
64 (let* ((tempdir (make-temp-file "vc-bzr-test" t))
65 (subdir (expand-file-name "subdir" tempdir))
66 (file (expand-file-name "file" tempdir))
67 (default-directory (file-name-as-directory tempdir)))
68 (unwind-protect
69 (progn
70 (call-process vc-bzr-program nil nil nil "init")
71 (make-directory subdir)
72 (with-temp-buffer
73 (insert "text")
74 (write-region nil nil file nil 'silent)
75 (write-region nil nil (expand-file-name "subfile" subdir)
76 nil 'silent))
77 (call-process vc-bzr-program nil nil nil "add")
78 (call-process vc-bzr-program nil nil nil "commit" "-m" "Commit 1")
79 (call-process vc-bzr-program nil nil nil "remove" subdir)
80 (with-temp-buffer
81 (insert "different text")
82 (write-region nil nil file nil 'silent))
83 (vc-dir tempdir)
84 (while (vc-dir-busy)
85 (sit-for 0.1))
86 (vc-dir-mark-all-files t)
87 (let ((f (symbol-function 'y-or-n-p)))
88 (unwind-protect
89 (progn
90 (fset 'y-or-n-p (lambda (prompt) t))
91 (vc-next-action nil))
92 (fset 'y-or-n-p f)))
93 (should (get-buffer "*vc-log*")))
94 (delete-directory tempdir t))))
96 ;; http://lists.gnu.org/archive/html/help-gnu-emacs/2012-04/msg00145.html
97 (ert-deftest vc-bzr-test-faulty-bzr-autoloads ()
98 "Test we can generate autoloads in a bzr directory when bzr is faulty."
99 (skip-unless (executable-find vc-bzr-program))
100 (let* ((tempdir (make-temp-file "vc-bzr-test" t))
101 (file (expand-file-name "foo.el" tempdir))
102 (default-directory (file-name-as-directory tempdir))
103 (generated-autoload-file (expand-file-name "loaddefs.el" tempdir)))
104 (unwind-protect
105 (progn
106 (call-process vc-bzr-program nil nil nil "init")
107 (with-temp-buffer
108 (insert ";;;###autoload
109 \(defun foo () \"foo\" (interactive) (message \"foo!\"))")
110 (write-region nil nil file nil 'silent))
111 (call-process vc-bzr-program nil nil nil "add")
112 (call-process vc-bzr-program nil nil nil "commit" "-m" "Commit 1")
113 ;; Deleting dirstate ensures both that vc-bzr's status heuristic
114 ;; fails, so it has to call the external bzr status, and
115 ;; causes bzr status to fail. This simulates a broken bzr
116 ;; installation.
117 (delete-file ".bzr/checkout/dirstate")
118 (should (progn (update-directory-autoloads default-directory)
119 t)))
120 (delete-directory tempdir t))))
122 ;;; vc-bzr.el ends here