1 ;;; vc-bzr.el --- tests for vc/vc-bzr.el
3 ;; Copyright (C) 2011-2013 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 ;; FIXME it would be better to skip all these tests if there is no
31 ;; bzr installed. We could just put everything inside an IF
32 ;; statement, but it would be nice if ERT had a "skipped" facility (?).
34 (ert-deftest vc-bzr-test-bug9726
()
35 "Test for http://debbugs.gnu.org/9726 ."
36 :expected-result
(if (executable-find vc-bzr-program
) :passed
:failed
)
37 (should (executable-find vc-bzr-program
))
38 (let* ((tempdir (make-temp-file "vc-bzr-test" t
))
39 (ignored-dir (expand-file-name "ignored-dir" tempdir
))
40 (default-directory (file-name-as-directory tempdir
)))
43 (make-directory ignored-dir
)
45 (insert (file-name-nondirectory ignored-dir
))
46 (write-region nil nil
(expand-file-name ".bzrignore" tempdir
)
48 (call-process vc-bzr-program nil nil nil
"init")
49 (call-process vc-bzr-program nil nil nil
"add")
50 (call-process vc-bzr-program nil nil nil
"commit" "-m" "Commit 1")
52 (insert "unregistered file")
53 (write-region nil nil
(expand-file-name "testfile2" ignored-dir
)
58 ;; FIXME better to explicitly test for error from process sentinel.
59 (with-current-buffer "*vc-dir*"
60 (goto-char (point-min))
61 (should (search-forward "unregistered" nil t
))))
62 (delete-directory tempdir t
))))
64 ;; Not specific to bzr.
65 (ert-deftest vc-bzr-test-bug9781
()
66 "Test for http://debbugs.gnu.org/9781 ."
67 :expected-result
(if (executable-find vc-bzr-program
) :passed
:failed
)
68 (should (executable-find vc-bzr-program
))
69 (let* ((tempdir (make-temp-file "vc-bzr-test" t
))
70 (subdir (expand-file-name "subdir" tempdir
))
71 (file (expand-file-name "file" tempdir
))
72 (default-directory (file-name-as-directory tempdir
)))
75 (call-process vc-bzr-program nil nil nil
"init")
76 (make-directory subdir
)
79 (write-region nil nil file nil
'silent
)
80 (write-region nil nil
(expand-file-name "subfile" subdir
)
82 (call-process vc-bzr-program nil nil nil
"add")
83 (call-process vc-bzr-program nil nil nil
"commit" "-m" "Commit 1")
84 (call-process vc-bzr-program nil nil nil
"remove" subdir
)
86 (insert "different text")
87 (write-region nil nil file nil
'silent
))
91 (vc-dir-mark-all-files t
)
92 (let ((f (symbol-function 'y-or-n-p
)))
95 (fset 'y-or-n-p
(lambda (prompt) t
))
98 (should (get-buffer "*vc-log*")))
99 (delete-directory tempdir t
))))
101 ;; http://lists.gnu.org/archive/html/help-gnu-emacs/2012-04/msg00145.html
102 (ert-deftest vc-bzr-test-faulty-bzr-autoloads
()
103 "Test we can generate autoloads in a bzr directory when bzr is faulty."
104 :expected-result
(if (executable-find vc-bzr-program
) :passed
:failed
)
105 (should (executable-find vc-bzr-program
))
106 (let* ((tempdir (make-temp-file "vc-bzr-test" t
))
107 (file (expand-file-name "foo.el" tempdir
))
108 (default-directory (file-name-as-directory tempdir
))
109 (generated-autoload-file (expand-file-name "loaddefs.el" tempdir
)))
112 (call-process vc-bzr-program nil nil nil
"init")
114 (insert ";;;###autoload
115 \(defun foo () \"foo\" (interactive) (message \"foo!\"))")
116 (write-region nil nil file nil
'silent
))
117 (call-process vc-bzr-program nil nil nil
"add")
118 (call-process vc-bzr-program nil nil nil
"commit" "-m" "Commit 1")
119 ;; Deleting dirstate ensures both that vc-bzr's status heuristic
120 ;; fails, so it has to call the external bzr status, and
121 ;; causes bzr status to fail. This simulates a broken bzr
123 (delete-file ".bzr/checkout/dirstate")
124 (should (progn (update-directory-autoloads default-directory
)
126 (delete-directory tempdir t
))))
128 ;;; vc-bzr.el ends here