diff options
| author | Kenichi Handa | 2014-07-05 23:07:57 +0900 |
|---|---|---|
| committer | Kenichi Handa | 2014-07-05 23:07:57 +0900 |
| commit | aeb894a9a06d84d29b93ca04432d7cbed366e665 (patch) | |
| tree | e2b73f9a76bc826c7a443e9a8d4fb3b49bdf7332 /test/automated | |
| parent | 763a11d0d0dcf543e89a22c98f55ea07c40ceefa (diff) | |
| parent | a984543a4488ed08778eb775d62f7091db117945 (diff) | |
| download | emacs-aeb894a9a06d84d29b93ca04432d7cbed366e665.tar.gz emacs-aeb894a9a06d84d29b93ca04432d7cbed366e665.zip | |
merge trunk
Diffstat (limited to 'test/automated')
| -rw-r--r-- | test/automated/dbus-tests.el | 50 | ||||
| -rw-r--r-- | test/automated/python-tests.el | 114 |
2 files changed, 137 insertions, 27 deletions
diff --git a/test/automated/dbus-tests.el b/test/automated/dbus-tests.el index 1af5c77de53..b157a365a4c 100644 --- a/test/automated/dbus-tests.el +++ b/test/automated/dbus-tests.el | |||
| @@ -103,7 +103,7 @@ | |||
| 103 | (should-error (dbus-unregister-service bus dbus-service-dbus))) | 103 | (should-error (dbus-unregister-service bus dbus-service-dbus))) |
| 104 | 104 | ||
| 105 | (ert-deftest dbus-test02-register-service-session () | 105 | (ert-deftest dbus-test02-register-service-session () |
| 106 | "Check service registration at `:session'." | 106 | "Check service registration at `:session' bus." |
| 107 | (skip-unless (and dbus--test-enabled-session-bus | 107 | (skip-unless (and dbus--test-enabled-session-bus |
| 108 | (dbus-register-service :session dbus-service-emacs))) | 108 | (dbus-register-service :session dbus-service-emacs))) |
| 109 | (dbus--test-register-service :session) | 109 | (dbus--test-register-service :session) |
| @@ -121,11 +121,57 @@ | |||
| 121 | (should (eq (dbus-unregister-service :session service) :not-owner))))) | 121 | (should (eq (dbus-unregister-service :session service) :not-owner))))) |
| 122 | 122 | ||
| 123 | (ert-deftest dbus-test02-register-service-system () | 123 | (ert-deftest dbus-test02-register-service-system () |
| 124 | "Check service registration at `:system'." | 124 | "Check service registration at `:system' bus." |
| 125 | (skip-unless (and dbus--test-enabled-system-bus | 125 | (skip-unless (and dbus--test-enabled-system-bus |
| 126 | (dbus-register-service :system dbus-service-emacs))) | 126 | (dbus-register-service :system dbus-service-emacs))) |
| 127 | (dbus--test-register-service :system)) | 127 | (dbus--test-register-service :system)) |
| 128 | 128 | ||
| 129 | (ert-deftest dbus-test02-register-service-own-bus () | ||
| 130 | "Check service registration with an own bus. | ||
| 131 | This includes initialization and closing the bus." | ||
| 132 | ;; Start bus. | ||
| 133 | (let ((output | ||
| 134 | (ignore-errors | ||
| 135 | (shell-command-to-string "dbus-launch --sh-syntax"))) | ||
| 136 | bus pid) | ||
| 137 | (skip-unless (stringp output)) | ||
| 138 | (when (string-match "DBUS_SESSION_BUS_ADDRESS='\\(.+\\)';" output) | ||
| 139 | (setq bus (match-string 1 output))) | ||
| 140 | (when (string-match "DBUS_SESSION_BUS_PID=\\([[:digit:]]+\\);" output) | ||
| 141 | (setq pid (match-string 1 output))) | ||
| 142 | (unwind-protect | ||
| 143 | (progn | ||
| 144 | (skip-unless | ||
| 145 | (dbus-ignore-errors | ||
| 146 | (and bus pid | ||
| 147 | (featurep 'dbusbind) | ||
| 148 | (dbus-init-bus bus) | ||
| 149 | (dbus-get-unique-name bus) | ||
| 150 | (dbus-register-service bus dbus-service-emacs)))) | ||
| 151 | ;; Run the test. | ||
| 152 | (dbus--test-register-service bus)) | ||
| 153 | |||
| 154 | ;; Save exit. | ||
| 155 | (when pid (call-process "kill" nil nil nil pid))))) | ||
| 156 | |||
| 157 | (ert-deftest dbus-test03-peer-interface () | ||
| 158 | "Check `dbus-interface-peer' methods." | ||
| 159 | (skip-unless | ||
| 160 | (and dbus--test-enabled-session-bus | ||
| 161 | (dbus-register-service :session dbus-service-emacs) | ||
| 162 | ;; "GetMachineId" is not implemented (yet). When it returns a | ||
| 163 | ;; value, another D-Bus client like dbus-monitor is reacting | ||
| 164 | ;; on `dbus-interface-peer'. We cannot test then. | ||
| 165 | (not | ||
| 166 | (dbus-ignore-errors | ||
| 167 | (dbus-call-method | ||
| 168 | :session dbus-service-emacs dbus-path-dbus | ||
| 169 | dbus-interface-peer "GetMachineId" :timeout 100))))) | ||
| 170 | |||
| 171 | (should (dbus-ping :session dbus-service-emacs 100)) | ||
| 172 | (dbus-unregister-service :session dbus-service-emacs) | ||
| 173 | (should-not (dbus-ping :session dbus-service-emacs 100))) | ||
| 174 | |||
| 129 | (defun dbus-test-all (&optional interactive) | 175 | (defun dbus-test-all (&optional interactive) |
| 130 | "Run all tests for \\[dbus]." | 176 | "Run all tests for \\[dbus]." |
| 131 | (interactive "p") | 177 | (interactive "p") |
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index f580e946b8f..a35242fe882 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el | |||
| @@ -86,6 +86,24 @@ STRING, it is skipped so the next STRING occurrence is selected." | |||
| 86 | found-point | 86 | found-point |
| 87 | (and restore-point (goto-char starting-point))))) | 87 | (and restore-point (goto-char starting-point))))) |
| 88 | 88 | ||
| 89 | (defun python-tests-self-insert (char-or-str) | ||
| 90 | "Call `self-insert-command' for chars in CHAR-OR-STR." | ||
| 91 | (let ((chars | ||
| 92 | (cond | ||
| 93 | ((characterp char-or-str) | ||
| 94 | (list char-or-str)) | ||
| 95 | ((stringp char-or-str) | ||
| 96 | (string-to-list char-or-str)) | ||
| 97 | ((not | ||
| 98 | (cl-remove-if #'characterp char-or-str)) | ||
| 99 | char-or-str) | ||
| 100 | (t (error "CHAR-OR-STR must be a char, string, or list of char"))))) | ||
| 101 | (mapc | ||
| 102 | (lambda (char) | ||
| 103 | (let ((last-command-event char)) | ||
| 104 | (call-interactively 'self-insert-command))) | ||
| 105 | chars))) | ||
| 106 | |||
| 89 | 107 | ||
| 90 | ;;; Tests for your tests, so you can test while you test. | 108 | ;;; Tests for your tests, so you can test while you test. |
| 91 | 109 | ||
| @@ -2715,9 +2733,6 @@ def foo(a, b, c): | |||
| 2715 | (should (string= (python-util-strip-string "\n \t \n\r ") "")) | 2733 | (should (string= (python-util-strip-string "\n \t \n\r ") "")) |
| 2716 | (should (string= (python-util-strip-string "") ""))) | 2734 | (should (string= (python-util-strip-string "") ""))) |
| 2717 | 2735 | ||
| 2718 | |||
| 2719 | ;;; Electricity | ||
| 2720 | |||
| 2721 | (ert-deftest python-util-forward-comment-1 () | 2736 | (ert-deftest python-util-forward-comment-1 () |
| 2722 | (python-tests-with-temp-buffer | 2737 | (python-tests-with-temp-buffer |
| 2723 | (concat | 2738 | (concat |
| @@ -2730,36 +2745,85 @@ def foo(a, b, c): | |||
| 2730 | (python-util-forward-comment -1) | 2745 | (python-util-forward-comment -1) |
| 2731 | (should (= (point) (point-min))))) | 2746 | (should (= (point) (point-min))))) |
| 2732 | 2747 | ||
| 2748 | |||
| 2749 | ;;; Electricity | ||
| 2750 | |||
| 2751 | (ert-deftest python-parens-electric-indent-1 () | ||
| 2752 | (require 'electric) | ||
| 2753 | (let ((eim electric-indent-mode)) | ||
| 2754 | (unwind-protect | ||
| 2755 | (progn | ||
| 2756 | (python-tests-with-temp-buffer | ||
| 2757 | " | ||
| 2758 | from django.conf.urls import patterns, include, url | ||
| 2759 | |||
| 2760 | from django.contrib import admin | ||
| 2761 | |||
| 2762 | from myapp import views | ||
| 2763 | |||
| 2764 | |||
| 2765 | urlpatterns = patterns('', | ||
| 2766 | url(r'^$', views.index | ||
| 2767 | ) | ||
| 2768 | " | ||
| 2769 | (electric-indent-mode 1) | ||
| 2770 | (python-tests-look-at "views.index") | ||
| 2771 | (end-of-line) | ||
| 2772 | |||
| 2773 | ;; Inserting commas within the same line should leave | ||
| 2774 | ;; indentation unchanged. | ||
| 2775 | (python-tests-self-insert ",") | ||
| 2776 | (should (= (current-indentation) 4)) | ||
| 2777 | |||
| 2778 | ;; As well as any other input happening within the same | ||
| 2779 | ;; set of parens. | ||
| 2780 | (python-tests-self-insert " name='index')") | ||
| 2781 | (should (= (current-indentation) 4)) | ||
| 2782 | |||
| 2783 | ;; But a comma outside it, should trigger indentation. | ||
| 2784 | (python-tests-self-insert ",") | ||
| 2785 | (should (= (current-indentation) 23)) | ||
| 2786 | |||
| 2787 | ;; Newline indents to the first argument column | ||
| 2788 | (python-tests-self-insert "\n") | ||
| 2789 | (should (= (current-indentation) 23)) | ||
| 2790 | |||
| 2791 | ;; All this input must not change indentation | ||
| 2792 | (indent-line-to 4) | ||
| 2793 | (python-tests-self-insert "url(r'^/login$', views.login)") | ||
| 2794 | (should (= (current-indentation) 4)) | ||
| 2795 | |||
| 2796 | ;; But this comma does | ||
| 2797 | (python-tests-self-insert ",") | ||
| 2798 | (should (= (current-indentation) 23)))) | ||
| 2799 | (or eim (electric-indent-mode -1))))) | ||
| 2800 | |||
| 2733 | (ert-deftest python-triple-quote-pairing () | 2801 | (ert-deftest python-triple-quote-pairing () |
| 2734 | (require 'electric) | 2802 | (require 'electric) |
| 2735 | (let ((epm electric-pair-mode)) | 2803 | (let ((epm electric-pair-mode)) |
| 2736 | (unwind-protect | 2804 | (unwind-protect |
| 2737 | (progn | 2805 | (progn |
| 2738 | (python-tests-with-temp-buffer | 2806 | (python-tests-with-temp-buffer |
| 2739 | "\"\"\n" | 2807 | "\"\"\n" |
| 2740 | (or epm (electric-pair-mode 1)) | 2808 | (or epm (electric-pair-mode 1)) |
| 2741 | (goto-char (1- (point-max))) | 2809 | (goto-char (1- (point-max))) |
| 2742 | (let ((last-command-event ?\")) | 2810 | (python-tests-self-insert ?\") |
| 2743 | (call-interactively 'self-insert-command)) | 2811 | (should (string= (buffer-string) |
| 2744 | (should (string= (buffer-string) | 2812 | "\"\"\"\"\"\"\n")) |
| 2745 | "\"\"\"\"\"\"\n")) | 2813 | (should (= (point) 4))) |
| 2746 | (should (= (point) 4))) | ||
| 2747 | (python-tests-with-temp-buffer | 2814 | (python-tests-with-temp-buffer |
| 2748 | "\n" | 2815 | "\n" |
| 2749 | (let ((last-command-event ?\")) | 2816 | (python-tests-self-insert (list ?\" ?\" ?\")) |
| 2750 | (dotimes (i 3) | 2817 | (should (string= (buffer-string) |
| 2751 | (call-interactively 'self-insert-command))) | 2818 | "\"\"\"\"\"\"\n")) |
| 2752 | (should (string= (buffer-string) | 2819 | (should (= (point) 4))) |
| 2753 | "\"\"\"\"\"\"\n")) | ||
| 2754 | (should (= (point) 4))) | ||
| 2755 | (python-tests-with-temp-buffer | 2820 | (python-tests-with-temp-buffer |
| 2756 | "\"\n\"\"\n" | 2821 | "\"\n\"\"\n" |
| 2757 | (goto-char (1- (point-max))) | 2822 | (goto-char (1- (point-max))) |
| 2758 | (let ((last-command-event ?\")) | 2823 | (python-tests-self-insert ?\") |
| 2759 | (call-interactively 'self-insert-command)) | 2824 | (should (= (point) (1- (point-max)))) |
| 2760 | (should (= (point) (1- (point-max)))) | 2825 | (should (string= (buffer-string) |
| 2761 | (should (string= (buffer-string) | 2826 | "\"\n\"\"\"\n")))) |
| 2762 | "\"\n\"\"\"\n")))) | ||
| 2763 | (or epm (electric-pair-mode -1))))) | 2827 | (or epm (electric-pair-mode -1))))) |
| 2764 | 2828 | ||
| 2765 | 2829 | ||