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/>.
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
)))
38 (make-directory ignored-dir
)
40 (insert (file-name-nondirectory ignored-dir
))
41 (write-region nil nil
(expand-file-name ".bzrignore" tempdir
)
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")
47 (insert "unregistered file")
48 (write-region nil nil
(expand-file-name "testfile2" ignored-dir
)
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
)))
69 (call-process vc-bzr-program nil nil nil
"init")
70 (make-directory subdir
)
73 (write-region nil nil file nil
'silent
)
74 (write-region nil nil
(expand-file-name "subfile" subdir
)
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
)
80 (insert "different text")
81 (write-region nil nil file nil
'silent
))
85 (vc-dir-mark-all-files t
)
86 (let ((f (symbol-function 'y-or-n-p
)))
89 (fset 'y-or-n-p
(lambda (prompt) t
))
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
)))
105 (call-process vc-bzr-program nil nil nil
"init")
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
116 (delete-file ".bzr/checkout/dirstate")
117 (should (progn (update-directory-autoloads default-directory
)
119 (delete-directory tempdir t
))))
121 ;;; vc-bzr.el ends here