update unidata-gen.el
[bpt/emacs.git] / test / automated / vc-bzr.el
CommitLineData
6e0a9be7
GM
1;;; vc-bzr.el --- tests for vc/vc-bzr.el
2
ba318903 3;; Copyright (C) 2011-2014 Free Software Foundation, Inc.
6e0a9be7
GM
4
5;; Author: Glenn Morris <rgm@gnu.org>
34dc21db 6;; Maintainer: emacs-devel@gnu.org
6e0a9be7
GM
7
8;; This file is part of GNU Emacs.
9
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.
14
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.
19
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/>.
22
23;;; Commentary:
24
25;;; Code:
26
27(require 'ert)
28(require 'vc-bzr)
29(require 'vc-dir)
30
6e0a9be7
GM
31(ert-deftest vc-bzr-test-bug9726 ()
32 "Test for http://debbugs.gnu.org/9726 ."
c76489d6 33 (skip-unless (executable-find vc-bzr-program))
b2a929a2
GM
34 ;; Bzr wants to access HOME, e.g. to write ~/.bzr.log.
35 ;; This is a problem on hydra, where HOME is non-existent.
833737d7
GM
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 ?
b2a929a2
GM
41 (let* ((homedir (make-temp-file "vc-bzr-test" t))
42 (bzrdir (expand-file-name "bzr" homedir))
43 (ignored-dir (progn
44 (make-directory bzrdir)
45 (expand-file-name "ignored-dir" bzrdir)))
46 (default-directory (file-name-as-directory bzrdir))
833737d7 47 (process-environment (cons (format "BZR_HOME=%s" homedir)
606695a6 48 process-environment)))
6e0a9be7
GM
49 (unwind-protect
50 (progn
51 (make-directory ignored-dir)
52 (with-temp-buffer
53 (insert (file-name-nondirectory ignored-dir))
b2a929a2 54 (write-region nil nil (expand-file-name ".bzrignore" bzrdir)
6e0a9be7
GM
55 nil 'silent))
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")
59 (with-temp-buffer
60 (insert "unregistered file")
61 (write-region nil nil (expand-file-name "testfile2" ignored-dir)
62 nil 'silent))
63 (vc-dir ignored-dir)
64 (while (vc-dir-busy)
65 (sit-for 0.1))
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))))
b2a929a2 70 (delete-directory homedir t))))
6e0a9be7 71
e195ae68
GM
72;; Not specific to bzr.
73(ert-deftest vc-bzr-test-bug9781 ()
74 "Test for http://debbugs.gnu.org/9781 ."
c76489d6 75 (skip-unless (executable-find vc-bzr-program))
b2a929a2
GM
76 (let* ((homedir (make-temp-file "vc-bzr-test" t))
77 (bzrdir (expand-file-name "bzr" homedir))
78 (subdir (progn
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))
833737d7 83 (process-environment (cons (format "BZR_HOME=%s" homedir)
606695a6 84 process-environment)))
e195ae68
GM
85 (unwind-protect
86 (progn
87 (call-process vc-bzr-program nil nil nil "init")
88 (make-directory subdir)
89 (with-temp-buffer
90 (insert "text")
91 (write-region nil nil file nil 'silent)
92 (write-region nil nil (expand-file-name "subfile" subdir)
93 nil 'silent))
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)
97 (with-temp-buffer
98 (insert "different text")
99 (write-region nil nil file nil 'silent))
b2a929a2 100 (vc-dir bzrdir)
e195ae68
GM
101 (while (vc-dir-busy)
102 (sit-for 0.1))
103 (vc-dir-mark-all-files t)
104 (let ((f (symbol-function 'y-or-n-p)))
105 (unwind-protect
106 (progn
107 (fset 'y-or-n-p (lambda (prompt) t))
108 (vc-next-action nil))
109 (fset 'y-or-n-p f)))
110 (should (get-buffer "*vc-log*")))
b2a929a2 111 (delete-directory homedir t))))
e195ae68 112
ab7ce8c1
GM
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."
c76489d6 116 (skip-unless (executable-find vc-bzr-program))
b2a929a2
GM
117 (let* ((homedir (make-temp-file "vc-bzr-test" t))
118 (bzrdir (expand-file-name "bzr" homedir))
119 (file (progn
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))
833737d7 124 (process-environment (cons (format "BZR_HOME=%s" homedir)
606695a6 125 process-environment)))
ab7ce8c1
GM
126 (unwind-protect
127 (progn
128 (call-process vc-bzr-program nil nil nil "init")
129 (with-temp-buffer
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
138 ;; installation.
139 (delete-file ".bzr/checkout/dirstate")
140 (should (progn (update-directory-autoloads default-directory)
141 t)))
b2a929a2 142 (delete-directory homedir t))))
ab7ce8c1 143
6e0a9be7 144;;; vc-bzr.el ends here