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
))
37 (process-environment (cons (format "BZR_LOG=%s" null-device
)
38 process-environment
)))
41 (make-directory ignored-dir
)
43 (insert (file-name-nondirectory ignored-dir
))
44 (write-region nil nil
(expand-file-name ".bzrignore" tempdir
)
46 (call-process vc-bzr-program nil nil nil
"init")
47 (call-process vc-bzr-program nil nil nil
"add")
48 (call-process vc-bzr-program nil nil nil
"commit" "-m" "Commit 1")
50 (insert "unregistered file")
51 (write-region nil nil
(expand-file-name "testfile2" ignored-dir
)
56 ;; FIXME better to explicitly test for error from process sentinel.
57 (with-current-buffer "*vc-dir*"
58 (goto-char (point-min))
59 (should (search-forward "unregistered" nil t
))))
60 (delete-directory tempdir t
))))
62 ;; Not specific to bzr.
63 (ert-deftest vc-bzr-test-bug9781
()
64 "Test for http://debbugs.gnu.org/9781 ."
65 (skip-unless (executable-find vc-bzr-program
))
66 (let* ((tempdir (make-temp-file "vc-bzr-test" t
))
67 (subdir (expand-file-name "subdir" tempdir
))
68 (file (expand-file-name "file" tempdir
))
69 (default-directory (file-name-as-directory tempdir
))
70 (process-environment (cons (format "BZR_LOG=%s" null-device
)
71 process-environment
)))
74 (call-process vc-bzr-program nil nil nil
"init")
75 (make-directory subdir
)
78 (write-region nil nil file nil
'silent
)
79 (write-region nil nil
(expand-file-name "subfile" subdir
)
81 (call-process vc-bzr-program nil nil nil
"add")
82 (call-process vc-bzr-program nil nil nil
"commit" "-m" "Commit 1")
83 (call-process vc-bzr-program nil nil nil
"remove" subdir
)
85 (insert "different text")
86 (write-region nil nil file nil
'silent
))
90 (vc-dir-mark-all-files t
)
91 (let ((f (symbol-function 'y-or-n-p
)))
94 (fset 'y-or-n-p
(lambda (prompt) t
))
97 (should (get-buffer "*vc-log*")))
98 (delete-directory tempdir t
))))
100 ;; http://lists.gnu.org/archive/html/help-gnu-emacs/2012-04/msg00145.html
101 (ert-deftest vc-bzr-test-faulty-bzr-autoloads
()
102 "Test we can generate autoloads in a bzr directory when bzr is faulty."
103 (skip-unless (executable-find vc-bzr-program
))
104 (let* ((tempdir (make-temp-file "vc-bzr-test" t
))
105 (file (expand-file-name "foo.el" tempdir
))
106 (default-directory (file-name-as-directory tempdir
))
107 (generated-autoload-file (expand-file-name "loaddefs.el" tempdir
))
108 (process-environment (cons (format "BZR_LOG=%s" null-device
)
109 process-environment
)))
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