vc-bzr.el 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. ;;; vc-bzr.el --- tests for vc/vc-bzr.el
  2. ;; Copyright (C) 2011-2012 Free Software Foundation, Inc.
  3. ;; Author: Glenn Morris <rgm@gnu.org>
  4. ;; This file is part of GNU Emacs.
  5. ;; GNU Emacs is free software: you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; GNU Emacs is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Commentary:
  16. ;;; Code:
  17. (require 'ert)
  18. (require 'vc-bzr)
  19. (require 'vc-dir)
  20. ;; FIXME it would be better to skip all these tests if there is no
  21. ;; bzr installed. We could just put everything inside an IF
  22. ;; statement, but it would be nice if ERT had a "skipped" facility (?).
  23. (ert-deftest vc-bzr-test-bug9726 ()
  24. "Test for http://debbugs.gnu.org/9726 ."
  25. :expected-result (if (executable-find vc-bzr-program) :passed :failed)
  26. (should (executable-find vc-bzr-program))
  27. (let* ((tempdir (make-temp-file "vc-bzr-test" t))
  28. (ignored-dir (expand-file-name "ignored-dir" tempdir))
  29. (default-directory (file-name-as-directory tempdir)))
  30. (unwind-protect
  31. (progn
  32. (make-directory ignored-dir)
  33. (with-temp-buffer
  34. (insert (file-name-nondirectory ignored-dir))
  35. (write-region nil nil (expand-file-name ".bzrignore" tempdir)
  36. nil 'silent))
  37. (call-process vc-bzr-program nil nil nil "init")
  38. (call-process vc-bzr-program nil nil nil "add")
  39. (call-process vc-bzr-program nil nil nil "commit" "-m" "Commit 1")
  40. (with-temp-buffer
  41. (insert "unregistered file")
  42. (write-region nil nil (expand-file-name "testfile2" ignored-dir)
  43. nil 'silent))
  44. (vc-dir ignored-dir)
  45. (while (vc-dir-busy)
  46. (sit-for 0.1))
  47. ;; FIXME better to explicitly test for error from process sentinel.
  48. (with-current-buffer "*vc-dir*"
  49. (goto-char (point-min))
  50. (should (search-forward "unregistered" nil t))))
  51. (delete-directory tempdir t))))
  52. ;; Not specific to bzr.
  53. (ert-deftest vc-bzr-test-bug9781 ()
  54. "Test for http://debbugs.gnu.org/9781 ."
  55. :expected-result (if (executable-find vc-bzr-program) :passed :failed)
  56. (should (executable-find vc-bzr-program))
  57. (let* ((tempdir (make-temp-file "vc-bzr-test" t))
  58. (subdir (expand-file-name "subdir" tempdir))
  59. (file (expand-file-name "file" tempdir))
  60. (default-directory (file-name-as-directory tempdir)))
  61. (unwind-protect
  62. (progn
  63. (call-process vc-bzr-program nil nil nil "init")
  64. (make-directory subdir)
  65. (with-temp-buffer
  66. (insert "text")
  67. (write-region nil nil file nil 'silent)
  68. (write-region nil nil (expand-file-name "subfile" subdir)
  69. nil 'silent))
  70. (call-process vc-bzr-program nil nil nil "add")
  71. (call-process vc-bzr-program nil nil nil "commit" "-m" "Commit 1")
  72. (call-process vc-bzr-program nil nil nil "remove" subdir)
  73. (with-temp-buffer
  74. (insert "different text")
  75. (write-region nil nil file nil 'silent))
  76. (vc-dir tempdir)
  77. (while (vc-dir-busy)
  78. (sit-for 0.1))
  79. (vc-dir-mark-all-files t)
  80. (let ((f (symbol-function 'y-or-n-p)))
  81. (unwind-protect
  82. (progn
  83. (fset 'y-or-n-p (lambda (prompt) t))
  84. (vc-next-action nil))
  85. (fset 'y-or-n-p f)))
  86. (should (get-buffer "*vc-log*")))
  87. (delete-directory tempdir t))))
  88. ;;; vc-bzr.el ends here