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/>.
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
)))
39 (make-directory ignored-dir
)
41 (insert (file-name-nondirectory ignored-dir
))
42 (write-region nil nil
(expand-file-name ".bzrignore" tempdir
)
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")
48 (insert "unregistered file")
49 (write-region nil nil
(expand-file-name "testfile2" ignored-dir
)
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
)))
70 (call-process vc-bzr-program nil nil nil
"init")
71 (make-directory subdir
)
74 (write-region nil nil file nil
'silent
)
75 (write-region nil nil
(expand-file-name "subfile" subdir
)
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
)
81 (insert "different text")
82 (write-region nil nil file nil
'silent
))
86 (vc-dir-mark-all-files t
)
87 (let ((f (symbol-function 'y-or-n-p
)))
90 (fset 'y-or-n-p
(lambda (prompt) t
))
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
)))
106 (call-process vc-bzr-program nil nil nil
"init")
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
117 (delete-file ".bzr/checkout/dirstate")
118 (should (progn (update-directory-autoloads default-directory
)
120 (delete-directory tempdir t
))))
122 ;;; vc-bzr.el ends here