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