test/automated/vc-bzr.el: disable bzr's logging
[emacs.git] / test / automated / vc-bzr.el
blob5cfa3c2691fc842b3fae0fa02d060e1e34d0d07f
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/>.
23 ;;; Commentary:
25 ;;; Code:
27 (require 'ert)
28 (require 'vc-bzr)
29 (require 'vc-dir)
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)))
39 (unwind-protect
40 (progn
41 (make-directory ignored-dir)
42 (with-temp-buffer
43 (insert (file-name-nondirectory ignored-dir))
44 (write-region nil nil (expand-file-name ".bzrignore" tempdir)
45 nil 'silent))
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")
49 (with-temp-buffer
50 (insert "unregistered file")
51 (write-region nil nil (expand-file-name "testfile2" ignored-dir)
52 nil 'silent))
53 (vc-dir ignored-dir)
54 (while (vc-dir-busy)
55 (sit-for 0.1))
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)))
72 (unwind-protect
73 (progn
74 (call-process vc-bzr-program nil nil nil "init")
75 (make-directory subdir)
76 (with-temp-buffer
77 (insert "text")
78 (write-region nil nil file nil 'silent)
79 (write-region nil nil (expand-file-name "subfile" subdir)
80 nil 'silent))
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)
84 (with-temp-buffer
85 (insert "different text")
86 (write-region nil nil file nil 'silent))
87 (vc-dir tempdir)
88 (while (vc-dir-busy)
89 (sit-for 0.1))
90 (vc-dir-mark-all-files t)
91 (let ((f (symbol-function 'y-or-n-p)))
92 (unwind-protect
93 (progn
94 (fset 'y-or-n-p (lambda (prompt) t))
95 (vc-next-action nil))
96 (fset 'y-or-n-p f)))
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)))
110 (unwind-protect
111 (progn
112 (call-process vc-bzr-program nil nil nil "init")
113 (with-temp-buffer
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
122 ;; installation.
123 (delete-file ".bzr/checkout/dirstate")
124 (should (progn (update-directory-autoloads default-directory)
125 t)))
126 (delete-directory tempdir t))))
128 ;;; vc-bzr.el ends here