1 ;;; vc-bzr.el --- tests for vc/vc-bzr.el
3 ;; Copyright (C) 2011-2015 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 ;; Bzr wants to access HOME, e.g. to write ~/.bzr.log.
35 ;; This is a problem on hydra, where HOME is non-existent.
36 ;; You can disable logging with BZR_LOG=/dev/null, but then some
37 ;; commands (eg `bzr status') want to access ~/.bazaar, and will
38 ;; abort if they cannot. I could not figure out how to stop bzr
39 ;; doing that, so just give it a temporary homedir for the duration.
40 ;; http://bugs.launchpad.net/bzr/+bug/137407 ?
41 (let* ((homedir (make-temp-file "vc-bzr-test" t
))
42 (bzrdir (expand-file-name "bzr" homedir
))
44 (make-directory bzrdir
)
45 (expand-file-name "ignored-dir" bzrdir
)))
46 (default-directory (file-name-as-directory bzrdir
))
47 (process-environment (cons (format "BZR_HOME=%s" homedir
)
48 process-environment
)))
51 (make-directory ignored-dir
)
53 (insert (file-name-nondirectory ignored-dir
))
54 (write-region nil nil
(expand-file-name ".bzrignore" bzrdir
)
56 (call-process vc-bzr-program nil nil nil
"init")
57 (call-process vc-bzr-program nil nil nil
"add")
58 (call-process vc-bzr-program nil nil nil
"commit" "-m" "Commit 1")
60 (insert "unregistered file")
61 (write-region nil nil
(expand-file-name "testfile2" ignored-dir
)
66 ;; FIXME better to explicitly test for error from process sentinel.
67 (with-current-buffer "*vc-dir*"
68 (goto-char (point-min))
69 (should (search-forward "unregistered" nil t
))))
70 (delete-directory homedir t
))))
72 ;; Not specific to bzr.
73 (ert-deftest vc-bzr-test-bug9781
()
74 "Test for http://debbugs.gnu.org/9781 ."
75 (skip-unless (executable-find vc-bzr-program
))
76 (let* ((homedir (make-temp-file "vc-bzr-test" t
))
77 (bzrdir (expand-file-name "bzr" homedir
))
79 (make-directory bzrdir
)
80 (expand-file-name "subdir" bzrdir
)))
81 (file (expand-file-name "file" bzrdir
))
82 (default-directory (file-name-as-directory bzrdir
))
83 (process-environment (cons (format "BZR_HOME=%s" homedir
)
84 process-environment
)))
87 (call-process vc-bzr-program nil nil nil
"init")
88 (make-directory subdir
)
91 (write-region nil nil file nil
'silent
)
92 (write-region nil nil
(expand-file-name "subfile" subdir
)
94 (call-process vc-bzr-program nil nil nil
"add")
95 (call-process vc-bzr-program nil nil nil
"commit" "-m" "Commit 1")
96 (call-process vc-bzr-program nil nil nil
"remove" subdir
)
98 (insert "different text")
99 (write-region nil nil file nil
'silent
))
103 (vc-dir-mark-all-files t
)
104 (let ((f (symbol-function 'y-or-n-p
)))
107 (fset 'y-or-n-p
(lambda (prompt) t
))
108 (vc-next-action nil
))
110 (should (get-buffer "*vc-log*")))
111 (delete-directory homedir t
))))
113 ;; http://lists.gnu.org/archive/html/help-gnu-emacs/2012-04/msg00145.html
114 (ert-deftest vc-bzr-test-faulty-bzr-autoloads
()
115 "Test we can generate autoloads in a bzr directory when bzr is faulty."
116 (skip-unless (executable-find vc-bzr-program
))
117 (let* ((homedir (make-temp-file "vc-bzr-test" t
))
118 (bzrdir (expand-file-name "bzr" homedir
))
120 (make-directory bzrdir
)
121 (expand-file-name "foo.el" bzrdir
)))
122 (default-directory (file-name-as-directory bzrdir
))
123 (generated-autoload-file (expand-file-name "loaddefs.el" bzrdir
))
124 (process-environment (cons (format "BZR_HOME=%s" homedir
)
125 process-environment
)))
128 (call-process vc-bzr-program nil nil nil
"init")
130 (insert ";;;###autoload
131 \(defun foo () \"foo\" (interactive) (message \"foo!\"))")
132 (write-region nil nil file nil
'silent
))
133 (call-process vc-bzr-program nil nil nil
"add")
134 (call-process vc-bzr-program nil nil nil
"commit" "-m" "Commit 1")
135 ;; Deleting dirstate ensures both that vc-bzr's status heuristic
136 ;; fails, so it has to call the external bzr status, and
137 ;; causes bzr status to fail. This simulates a broken bzr
139 (delete-file ".bzr/checkout/dirstate")
140 (should (progn (update-directory-autoloads default-directory
)
142 (delete-directory homedir t
))))
144 ;;; vc-bzr.el ends here