diff options
| author | Stefan Monnier | 2011-03-06 16:22:16 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2011-03-06 16:22:16 -0500 |
| commit | 0d6459dfb52188481bfd6bb53f1b2f653ecd6a5d (patch) | |
| tree | 306b87fc2903ad23343f3c84be1cccfa72e5a97e /test | |
| parent | 798cb64441228d473f7bdd213183c70fb582595c (diff) | |
| parent | 892777baa1739fa5f1f2d1c2975488c3e6f57bae (diff) | |
| download | emacs-0d6459dfb52188481bfd6bb53f1b2f653ecd6a5d.tar.gz emacs-0d6459dfb52188481bfd6bb53f1b2f653ecd6a5d.zip | |
Merge from trunk
Diffstat (limited to 'test')
| -rw-r--r-- | test/ChangeLog | 9 | ||||
| -rw-r--r-- | test/automated/ert-tests.el | 33 | ||||
| -rw-r--r-- | test/eshell.el | 421 |
3 files changed, 449 insertions, 14 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index dbfc6c6cefe..b247b88bc94 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2011-03-05 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * eshell.el: Move here from lisp/eshell/esh-test.el. | ||
| 4 | |||
| 5 | 2011-03-03 Christian Ohler <ohler@gnu.org> | ||
| 6 | |||
| 7 | * automated/ert-tests.el (ert-test-explain-not-equal-keymaps): | ||
| 8 | New test. | ||
| 9 | |||
| 1 | 2011-02-20 Ulf Jasper <ulf.jasper@web.de> | 10 | 2011-02-20 Ulf Jasper <ulf.jasper@web.de> |
| 2 | 11 | ||
| 3 | * automated/icalendar-tests.el: Move from icalendar-testsuite.el; | 12 | * automated/icalendar-tests.el: Move from icalendar-testsuite.el; |
diff --git a/test/automated/ert-tests.el b/test/automated/ert-tests.el index b6d70dee7e2..cea994f64b8 100644 --- a/test/automated/ert-tests.el +++ b/test/automated/ert-tests.el | |||
| @@ -796,27 +796,32 @@ This macro is used to test if macroexpansion in `should' works." | |||
| 796 | (should (equal (ert--string-first-line "foo\nbar") "foo")) | 796 | (should (equal (ert--string-first-line "foo\nbar") "foo")) |
| 797 | (should (equal (ert--string-first-line " foo\nbar\nbaz\n") " foo"))) | 797 | (should (equal (ert--string-first-line " foo\nbar\nbaz\n") " foo"))) |
| 798 | 798 | ||
| 799 | (ert-deftest ert-test-explain-not-equal () | 799 | (ert-deftest ert-test-explain-equal () |
| 800 | (should (equal (ert--explain-not-equal nil 'foo) | 800 | (should (equal (ert--explain-equal nil 'foo) |
| 801 | '(different-atoms nil foo))) | 801 | '(different-atoms nil foo))) |
| 802 | (should (equal (ert--explain-not-equal '(a a) '(a b)) | 802 | (should (equal (ert--explain-equal '(a a) '(a b)) |
| 803 | '(list-elt 1 (different-atoms a b)))) | 803 | '(list-elt 1 (different-atoms a b)))) |
| 804 | (should (equal (ert--explain-not-equal '(1 48) '(1 49)) | 804 | (should (equal (ert--explain-equal '(1 48) '(1 49)) |
| 805 | '(list-elt 1 (different-atoms (48 "#x30" "?0") | 805 | '(list-elt 1 (different-atoms (48 "#x30" "?0") |
| 806 | (49 "#x31" "?1"))))) | 806 | (49 "#x31" "?1"))))) |
| 807 | (should (equal (ert--explain-not-equal 'nil '(a)) | 807 | (should (equal (ert--explain-equal 'nil '(a)) |
| 808 | '(different-types nil (a)))) | 808 | '(different-types nil (a)))) |
| 809 | (should (equal (ert--explain-not-equal '(a b c) '(a b c d)) | 809 | (should (equal (ert--explain-equal '(a b c) '(a b c d)) |
| 810 | '(proper-lists-of-different-length 3 4 (a b c) (a b c d) | 810 | '(proper-lists-of-different-length 3 4 (a b c) (a b c d) |
| 811 | first-mismatch-at 3))) | 811 | first-mismatch-at 3))) |
| 812 | (let ((sym (make-symbol "a"))) | 812 | (let ((sym (make-symbol "a"))) |
| 813 | (should (equal (ert--explain-not-equal 'a sym) | 813 | (should (equal (ert--explain-equal 'a sym) |
| 814 | `(different-symbols-with-the-same-name a ,sym))))) | 814 | `(different-symbols-with-the-same-name a ,sym))))) |
| 815 | 815 | ||
| 816 | (ert-deftest ert-test-explain-not-equal-improper-list () | 816 | (ert-deftest ert-test-explain-equal-improper-list () |
| 817 | (should (equal (ert--explain-not-equal '(a . b) '(a . c)) | 817 | (should (equal (ert--explain-equal '(a . b) '(a . c)) |
| 818 | '(cdr (different-atoms b c))))) | 818 | '(cdr (different-atoms b c))))) |
| 819 | 819 | ||
| 820 | (ert-deftest ert-test-explain-equal-keymaps () | ||
| 821 | ;; This used to be very slow. | ||
| 822 | (should (equal (make-keymap) (make-keymap))) | ||
| 823 | (should (equal (make-sparse-keymap) (make-sparse-keymap)))) | ||
| 824 | |||
| 820 | (ert-deftest ert-test-significant-plist-keys () | 825 | (ert-deftest ert-test-significant-plist-keys () |
| 821 | (should (equal (ert--significant-plist-keys '()) '())) | 826 | (should (equal (ert--significant-plist-keys '()) '())) |
| 822 | (should (equal (ert--significant-plist-keys '(a b c d e f c g p q r nil s t)) | 827 | (should (equal (ert--significant-plist-keys '(a b c d e f c g p q r nil s t)) |
| @@ -852,21 +857,21 @@ This macro is used to test if macroexpansion in `should' works." | |||
| 852 | (should (equal (ert--abbreviate-string "bar" 1 t) "r")) | 857 | (should (equal (ert--abbreviate-string "bar" 1 t) "r")) |
| 853 | (should (equal (ert--abbreviate-string "bar" 0 t) ""))) | 858 | (should (equal (ert--abbreviate-string "bar" 0 t) ""))) |
| 854 | 859 | ||
| 855 | (ert-deftest ert-test-explain-not-equal-string-properties () | 860 | (ert-deftest ert-test-explain-equal-string-properties () |
| 856 | (should | 861 | (should |
| 857 | (equal (ert--explain-not-equal-including-properties #("foo" 0 1 (a b)) | 862 | (equal (ert--explain-equal-including-properties #("foo" 0 1 (a b)) |
| 858 | "foo") | 863 | "foo") |
| 859 | '(char 0 "f" | 864 | '(char 0 "f" |
| 860 | (different-properties-for-key a (different-atoms b nil)) | 865 | (different-properties-for-key a (different-atoms b nil)) |
| 861 | context-before "" | 866 | context-before "" |
| 862 | context-after "oo"))) | 867 | context-after "oo"))) |
| 863 | (should (equal (ert--explain-not-equal-including-properties | 868 | (should (equal (ert--explain-equal-including-properties |
| 864 | #("foo" 1 3 (a b)) | 869 | #("foo" 1 3 (a b)) |
| 865 | #("goo" 0 1 (c d))) | 870 | #("goo" 0 1 (c d))) |
| 866 | '(array-elt 0 (different-atoms (?f "#x66" "?f") | 871 | '(array-elt 0 (different-atoms (?f "#x66" "?f") |
| 867 | (?g "#x67" "?g"))))) | 872 | (?g "#x67" "?g"))))) |
| 868 | (should | 873 | (should |
| 869 | (equal (ert--explain-not-equal-including-properties | 874 | (equal (ert--explain-equal-including-properties |
| 870 | #("foo" 0 1 (a b c d) 1 3 (a b)) | 875 | #("foo" 0 1 (a b c d) 1 3 (a b)) |
| 871 | #("foo" 0 1 (c d a b) 1 2 (a foo))) | 876 | #("foo" 0 1 (c d a b) 1 2 (a foo))) |
| 872 | '(char 1 "o" (different-properties-for-key a (different-atoms b foo)) | 877 | '(char 1 "o" (different-properties-for-key a (different-atoms b foo)) |
diff --git a/test/eshell.el b/test/eshell.el new file mode 100644 index 00000000000..3b392e84c24 --- /dev/null +++ b/test/eshell.el | |||
| @@ -0,0 +1,421 @@ | |||
| 1 | ;;; esh-test.el --- Eshell test suite | ||
| 2 | |||
| 3 | ;; Copyright (C) 1999-2011 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: John Wiegley <johnw@gnu.org> | ||
| 6 | |||
| 7 | ;; This file is part of GNU Emacs. | ||
| 8 | |||
| 9 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 10 | ;; it under the terms of the GNU General Public License as published by | ||
| 11 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 12 | ;; (at your option) any later version. | ||
| 13 | |||
| 14 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | ;; GNU General Public License for more details. | ||
| 18 | |||
| 19 | ;; You should have received a copy of the GNU General Public License | ||
| 20 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | |||
| 22 | ;;; Commentary: | ||
| 23 | |||
| 24 | ;; The purpose of this module is to verify that Eshell works as | ||
| 25 | ;; expected. To run it on your system, use the command | ||
| 26 | ;; \\[eshell-test]. | ||
| 27 | |||
| 28 | ;;; Code: | ||
| 29 | |||
| 30 | (eval-when-compile | ||
| 31 | (require 'cl) ; assert | ||
| 32 | (require 'eshell) | ||
| 33 | (require 'esh-util)) | ||
| 34 | (require 'esh-mode) | ||
| 35 | |||
| 36 | (defgroup eshell-test nil | ||
| 37 | "This module is meant to ensure that Eshell is working correctly." | ||
| 38 | :tag "Eshell test suite" | ||
| 39 | :group 'eshell) | ||
| 40 | |||
| 41 | ;;; User Variables: | ||
| 42 | |||
| 43 | (defface eshell-test-ok | ||
| 44 | '((((class color) (background light)) (:foreground "Green" :bold t)) | ||
| 45 | (((class color) (background dark)) (:foreground "Green" :bold t))) | ||
| 46 | "The face used to highlight OK result strings." | ||
| 47 | :group 'eshell-test) | ||
| 48 | (define-obsolete-face-alias 'eshell-test-ok-face 'eshell-test-ok "22.1") | ||
| 49 | |||
| 50 | (defface eshell-test-failed | ||
| 51 | '((((class color) (background light)) (:foreground "OrangeRed" :bold t)) | ||
| 52 | (((class color) (background dark)) (:foreground "OrangeRed" :bold t)) | ||
| 53 | (t (:bold t))) | ||
| 54 | "The face used to highlight FAILED result strings." | ||
| 55 | :group 'eshell-test) | ||
| 56 | (define-obsolete-face-alias 'eshell-test-failed-face 'eshell-test-failed "22.1") | ||
| 57 | |||
| 58 | (defcustom eshell-show-usage-metrics nil | ||
| 59 | "If non-nil, display different usage metrics for each Eshell command." | ||
| 60 | :set (lambda (symbol value) | ||
| 61 | (if value | ||
| 62 | (add-hook 'eshell-mode-hook 'eshell-show-usage-metrics) | ||
| 63 | (remove-hook 'eshell-mode-hook 'eshell-show-usage-metrics)) | ||
| 64 | (set symbol value)) | ||
| 65 | :type '(choice (const :tag "No metrics" nil) | ||
| 66 | (const :tag "Cons cells consumed" t) | ||
| 67 | (const :tag "Time elapsed" 0)) | ||
| 68 | :group 'eshell-test) | ||
| 69 | |||
| 70 | ;;; Code: | ||
| 71 | |||
| 72 | (defvar test-buffer) | ||
| 73 | |||
| 74 | (defun eshell-insert-command (text &optional func) | ||
| 75 | "Insert a command at the end of the buffer." | ||
| 76 | (goto-char eshell-last-output-end) | ||
| 77 | (insert-and-inherit text) | ||
| 78 | (funcall (or func 'eshell-send-input))) | ||
| 79 | |||
| 80 | (defun eshell-match-result (regexp) | ||
| 81 | "Insert a command at the end of the buffer." | ||
| 82 | (goto-char eshell-last-input-end) | ||
| 83 | (looking-at regexp)) | ||
| 84 | |||
| 85 | (defun eshell-command-result-p (text regexp &optional func) | ||
| 86 | "Insert a command at the end of the buffer." | ||
| 87 | (eshell-insert-command text func) | ||
| 88 | (eshell-match-result regexp)) | ||
| 89 | |||
| 90 | (defvar eshell-test-failures nil) | ||
| 91 | |||
| 92 | (defun eshell-run-test (module funcsym label command) | ||
| 93 | "Test whether FORM evaluates to a non-nil value." | ||
| 94 | (when (let ((sym (intern-soft (concat "eshell-" (symbol-name module))))) | ||
| 95 | (or (memq sym (eshell-subgroups 'eshell)) | ||
| 96 | (eshell-using-module sym))) | ||
| 97 | (with-current-buffer test-buffer | ||
| 98 | (insert-before-markers | ||
| 99 | (format "%-70s " (substring label 0 (min 70 (length label))))) | ||
| 100 | (insert-before-markers " ....") | ||
| 101 | (eshell-redisplay)) | ||
| 102 | (let ((truth (eval command))) | ||
| 103 | (with-current-buffer test-buffer | ||
| 104 | (delete-char -6) | ||
| 105 | (insert-before-markers | ||
| 106 | "[" (let (str) | ||
| 107 | (if truth | ||
| 108 | (progn | ||
| 109 | (setq str " OK ") | ||
| 110 | (put-text-property 0 6 'face 'eshell-test-ok str)) | ||
| 111 | (setq str "FAILED") | ||
| 112 | (setq eshell-test-failures (1+ eshell-test-failures)) | ||
| 113 | (put-text-property 0 6 'face 'eshell-test-failed str)) | ||
| 114 | str) "]") | ||
| 115 | (add-text-properties (line-beginning-position) (point) | ||
| 116 | (list 'test-func funcsym)) | ||
| 117 | (eshell-redisplay))))) | ||
| 118 | |||
| 119 | (defun eshell-test-goto-func () | ||
| 120 | "Jump to the function that defines a particular test." | ||
| 121 | (interactive) | ||
| 122 | (let ((fsym (get-text-property (point) 'test-func))) | ||
| 123 | (when fsym | ||
| 124 | (let* ((def (symbol-function fsym)) | ||
| 125 | (library (locate-library (symbol-file fsym 'defun))) | ||
| 126 | (name (substring (symbol-name fsym) | ||
| 127 | (length "eshell-test--"))) | ||
| 128 | (inhibit-redisplay t)) | ||
| 129 | (find-file library) | ||
| 130 | (goto-char (point-min)) | ||
| 131 | (re-search-forward (concat "^(eshell-deftest\\s-+\\w+\\s-+" | ||
| 132 | name)) | ||
| 133 | (beginning-of-line))))) | ||
| 134 | |||
| 135 | (defun eshell-run-one-test (&optional arg) | ||
| 136 | "Jump to the function that defines a particular test." | ||
| 137 | (interactive "P") | ||
| 138 | (let ((fsym (get-text-property (point) 'test-func))) | ||
| 139 | (when fsym | ||
| 140 | (beginning-of-line) | ||
| 141 | (delete-region (point) (line-end-position)) | ||
| 142 | (let ((test-buffer (current-buffer))) | ||
| 143 | (set-buffer (let ((inhibit-redisplay t)) | ||
| 144 | (save-window-excursion (eshell t)))) | ||
| 145 | (funcall fsym) | ||
| 146 | (unless arg | ||
| 147 | (kill-buffer (current-buffer))))))) | ||
| 148 | |||
| 149 | ;;;###autoload | ||
| 150 | (defun eshell-test (&optional arg) | ||
| 151 | "Test Eshell to verify that it works as expected." | ||
| 152 | (interactive "P") | ||
| 153 | (let* ((begin (float-time)) | ||
| 154 | (test-buffer (get-buffer-create "*eshell test*"))) | ||
| 155 | (set-buffer (let ((inhibit-redisplay t)) | ||
| 156 | (save-window-excursion (eshell t)))) | ||
| 157 | (with-current-buffer test-buffer | ||
| 158 | (erase-buffer) | ||
| 159 | (setq major-mode 'eshell-test-mode) | ||
| 160 | (setq mode-name "EShell Test") | ||
| 161 | (set (make-local-variable 'eshell-test-failures) 0) | ||
| 162 | (local-set-key [(control ?c) (control ?c)] 'eshell-test-goto-func) | ||
| 163 | (local-set-key [(control ?c) (control ?r)] 'eshell-run-one-test) | ||
| 164 | (local-set-key [(control ?m)] 'eshell-test-goto-func) | ||
| 165 | (local-set-key [return] 'eshell-test-goto-func) | ||
| 166 | |||
| 167 | (insert "Testing Eshell under " (emacs-version)) | ||
| 168 | (switch-to-buffer test-buffer) | ||
| 169 | (delete-other-windows)) | ||
| 170 | (dolist (funcname (sort (all-completions "eshell-test--" | ||
| 171 | obarray 'functionp) | ||
| 172 | 'string-lessp)) | ||
| 173 | (with-current-buffer test-buffer | ||
| 174 | (insert "\n")) | ||
| 175 | (funcall (intern-soft funcname))) | ||
| 176 | (with-current-buffer test-buffer | ||
| 177 | (insert (format "\n\n--- %s --- (completed in %d seconds)\n" | ||
| 178 | (current-time-string) | ||
| 179 | (- (float-time) begin))) | ||
| 180 | (message "Eshell test suite completed: %s failure%s" | ||
| 181 | (if (> eshell-test-failures 0) | ||
| 182 | (number-to-string eshell-test-failures) | ||
| 183 | "No") | ||
| 184 | (if (= eshell-test-failures 1) "" "s")))) | ||
| 185 | (goto-char eshell-last-output-end) | ||
| 186 | (unless arg | ||
| 187 | (kill-buffer (current-buffer)))) | ||
| 188 | |||
| 189 | |||
| 190 | (defvar eshell-metric-before-command 0) | ||
| 191 | (defvar eshell-metric-after-command 0) | ||
| 192 | |||
| 193 | (defun eshell-show-usage-metrics () | ||
| 194 | "If run at Eshell mode startup, metrics are shown after each command." | ||
| 195 | (set (make-local-variable 'eshell-metric-before-command) | ||
| 196 | (if (eq eshell-show-usage-metrics t) | ||
| 197 | 0 | ||
| 198 | (current-time))) | ||
| 199 | (set (make-local-variable 'eshell-metric-after-command) | ||
| 200 | (if (eq eshell-show-usage-metrics t) | ||
| 201 | 0 | ||
| 202 | (current-time))) | ||
| 203 | |||
| 204 | (add-hook 'eshell-pre-command-hook | ||
| 205 | (function | ||
| 206 | (lambda () | ||
| 207 | (setq eshell-metric-before-command | ||
| 208 | (if (eq eshell-show-usage-metrics t) | ||
| 209 | (car (memory-use-counts)) | ||
| 210 | (current-time))))) nil t) | ||
| 211 | |||
| 212 | (add-hook 'eshell-post-command-hook | ||
| 213 | (function | ||
| 214 | (lambda () | ||
| 215 | (setq eshell-metric-after-command | ||
| 216 | (if (eq eshell-show-usage-metrics t) | ||
| 217 | (car (memory-use-counts)) | ||
| 218 | (current-time))) | ||
| 219 | (eshell-interactive-print | ||
| 220 | (concat | ||
| 221 | (int-to-string | ||
| 222 | (if (eq eshell-show-usage-metrics t) | ||
| 223 | (- eshell-metric-after-command | ||
| 224 | eshell-metric-before-command 7) | ||
| 225 | (- (float-time | ||
| 226 | eshell-metric-after-command) | ||
| 227 | (float-time | ||
| 228 | eshell-metric-before-command)))) | ||
| 229 | "\n")))) | ||
| 230 | nil t)) | ||
| 231 | |||
| 232 | |||
| 233 | ;;; The tests. | ||
| 234 | |||
| 235 | (defmacro eshell-deftest (module name label &rest forms) | ||
| 236 | (declare (indent 2)) | ||
| 237 | (if (and (fboundp 'cl-compiling-file) (cl-compiling-file)) | ||
| 238 | nil | ||
| 239 | (let ((fsym (intern (concat "eshell-test--" (symbol-name name))))) | ||
| 240 | `(eval-when-compile | ||
| 241 | (ignore | ||
| 242 | (defun ,fsym () ,label | ||
| 243 | (eshell-run-test (quote ,module) (quote ,fsym) ,label | ||
| 244 | (quote (progn ,@forms))))))))) | ||
| 245 | |||
| 246 | |||
| 247 | (eshell-deftest mode same-window-buffer-names | ||
| 248 | "`eshell-buffer-name' is a member of `same-window-buffer-names'" | ||
| 249 | (member eshell-buffer-name same-window-buffer-names)) | ||
| 250 | |||
| 251 | (eshell-deftest mode eshell-directory-exists | ||
| 252 | "`eshell-directory-name' exists and is writable" | ||
| 253 | (file-writable-p eshell-directory-name)) | ||
| 254 | |||
| 255 | (eshell-deftest mode eshell-directory-modes | ||
| 256 | "`eshell-directory-name' has correct access protections" | ||
| 257 | (or (eshell-under-windows-p) | ||
| 258 | (= (file-modes eshell-directory-name) | ||
| 259 | eshell-private-directory-modes))) | ||
| 260 | |||
| 261 | (eshell-deftest mode simple-command-result | ||
| 262 | "`eshell-command-result' works with a simple command." | ||
| 263 | (= (eshell-command-result "+ 1 2") 3)) | ||
| 264 | |||
| 265 | |||
| 266 | (require 'em-banner) | ||
| 267 | |||
| 268 | (eshell-deftest banner banner-displayed | ||
| 269 | "Startup banner is displayed at point-min" | ||
| 270 | (assert eshell-banner-message) | ||
| 271 | (let ((msg (eval eshell-banner-message))) | ||
| 272 | (assert msg) | ||
| 273 | (goto-char (point-min)) | ||
| 274 | (looking-at msg))) | ||
| 275 | |||
| 276 | |||
| 277 | (require 'esh-cmd) | ||
| 278 | |||
| 279 | (eshell-deftest var last-result-var | ||
| 280 | "\"last result\" variable" | ||
| 281 | (eshell-command-result-p "+ 1 2; + $$ 2" "3\n5\n")) | ||
| 282 | |||
| 283 | (eshell-deftest var last-result-var2 | ||
| 284 | "\"last result\" variable" | ||
| 285 | (eshell-command-result-p "+ 1 2; + $$ $$" "3\n6\n")) | ||
| 286 | |||
| 287 | (eshell-deftest var last-arg-var | ||
| 288 | "\"last arg\" variable" | ||
| 289 | (eshell-command-result-p "+ 1 2; + $_ 4" "3\n6\n")) | ||
| 290 | |||
| 291 | (eshell-deftest cmd lisp-command | ||
| 292 | "Evaluate Lisp command" | ||
| 293 | (eshell-command-result-p "(+ 1 2)" "3")) | ||
| 294 | |||
| 295 | (eshell-deftest cmd lisp-command-args | ||
| 296 | "Evaluate Lisp command (ignore args)" | ||
| 297 | (eshell-command-result-p "(+ 1 2) 3" "3")) | ||
| 298 | |||
| 299 | (eshell-deftest cmd subcommand | ||
| 300 | "Run subcommand" | ||
| 301 | (eshell-command-result-p "{+ 1 2}" "3\n")) | ||
| 302 | |||
| 303 | (eshell-deftest cmd subcommand-args | ||
| 304 | "Run subcommand (ignore args)" | ||
| 305 | (eshell-command-result-p "{+ 1 2} 3" "3\n")) | ||
| 306 | |||
| 307 | (eshell-deftest cmd subcommand-lisp | ||
| 308 | "Run subcommand + Lisp form" | ||
| 309 | (eshell-command-result-p "{(+ 1 2)}" "3\n")) | ||
| 310 | |||
| 311 | (eshell-deftest cmd named-command | ||
| 312 | "Execute named command" | ||
| 313 | (eshell-command-result-p "+ 1 2" "3\n")) | ||
| 314 | |||
| 315 | |||
| 316 | (require 'esh-mode) | ||
| 317 | |||
| 318 | (eshell-deftest mode major-mode | ||
| 319 | "Major mode is correct" | ||
| 320 | (eq major-mode 'eshell-mode)) | ||
| 321 | |||
| 322 | (eshell-deftest mode eshell-mode-variable | ||
| 323 | "`eshell-mode' is true" | ||
| 324 | (eq eshell-mode t)) | ||
| 325 | |||
| 326 | (eshell-deftest var window-height | ||
| 327 | "LINES equals window height" | ||
| 328 | (let ((eshell-stringify-t t)) | ||
| 329 | (eshell-command-result-p "= $LINES (window-height)" "t\n"))) | ||
| 330 | |||
| 331 | (eshell-deftest mode command-running-p | ||
| 332 | "Modeline shows no command running" | ||
| 333 | (or (featurep 'xemacs) | ||
| 334 | (not eshell-status-in-modeline) | ||
| 335 | (and (memq 'eshell-command-running-string mode-line-format) | ||
| 336 | (equal eshell-command-running-string "--")))) | ||
| 337 | |||
| 338 | (eshell-deftest arg forward-arg | ||
| 339 | "Move across command arguments" | ||
| 340 | (eshell-insert-command "echo $(+ 1 (- 4 3)) \"alpha beta\" file" 'ignore) | ||
| 341 | (let ((here (point)) begin valid) | ||
| 342 | (eshell-bol) | ||
| 343 | (setq begin (point)) | ||
| 344 | (eshell-forward-argument 4) | ||
| 345 | (setq valid (= here (point))) | ||
| 346 | (eshell-backward-argument 4) | ||
| 347 | (prog1 | ||
| 348 | (and valid (= begin (point))) | ||
| 349 | (eshell-bol) | ||
| 350 | (delete-region (point) (point-max))))) | ||
| 351 | |||
| 352 | (eshell-deftest mode queue-input | ||
| 353 | "Queue command input" | ||
| 354 | (eshell-insert-command "sleep 2") | ||
| 355 | (eshell-insert-command "echo alpha" 'eshell-queue-input) | ||
| 356 | (let ((count 10)) | ||
| 357 | (while (and eshell-current-command | ||
| 358 | (> count 0)) | ||
| 359 | (sit-for 1 0) | ||
| 360 | (setq count (1- count)))) | ||
| 361 | (eshell-match-result "alpha\n")) | ||
| 362 | |||
| 363 | ; (eshell-deftest proc send-to-subprocess | ||
| 364 | ; "Send input to a subprocess" | ||
| 365 | ; ;; jww (1999-12-06): what about when bc is unavailable? | ||
| 366 | ; (if (not (eshell-search-path "bc")) | ||
| 367 | ; t | ||
| 368 | ; (eshell-insert-command "bc") | ||
| 369 | ; (eshell-insert-command "1 + 2") | ||
| 370 | ; (sit-for 1 0) | ||
| 371 | ; (forward-line -1) | ||
| 372 | ; (prog1 | ||
| 373 | ; (looking-at "3\n") | ||
| 374 | ; (eshell-insert-command "quit") | ||
| 375 | ; (sit-for 1 0)))) | ||
| 376 | |||
| 377 | (eshell-deftest io flush-output | ||
| 378 | "Flush previous output" | ||
| 379 | (eshell-insert-command "echo alpha") | ||
| 380 | (eshell-kill-output) | ||
| 381 | (and (eshell-match-result (regexp-quote "*** output flushed ***\n")) | ||
| 382 | (forward-line) | ||
| 383 | (= (point) eshell-last-output-start))) | ||
| 384 | |||
| 385 | (eshell-deftest mode run-old-command | ||
| 386 | "Re-run an old command" | ||
| 387 | (eshell-insert-command "echo alpha") | ||
| 388 | (goto-char eshell-last-input-start) | ||
| 389 | (string= (eshell-get-old-input) "echo alpha")) | ||
| 390 | |||
| 391 | |||
| 392 | (require 'esh-var) | ||
| 393 | |||
| 394 | (eshell-deftest var interp-cmd | ||
| 395 | "Interpolate command result" | ||
| 396 | (eshell-command-result-p "+ ${+ 1 2} 3" "6\n")) | ||
| 397 | |||
| 398 | (eshell-deftest var interp-lisp | ||
| 399 | "Interpolate Lisp form evalution" | ||
| 400 | (eshell-command-result-p "+ $(+ 1 2) 3" "6\n")) | ||
| 401 | |||
| 402 | (eshell-deftest var interp-concat | ||
| 403 | "Interpolate and concat command" | ||
| 404 | (eshell-command-result-p "+ ${+ 1 2}3 3" "36\n")) | ||
| 405 | |||
| 406 | (eshell-deftest var interp-concat-lisp | ||
| 407 | "Interpolate and concat Lisp form" | ||
| 408 | (eshell-command-result-p "+ $(+ 1 2)3 3" "36\n")) | ||
| 409 | |||
| 410 | (eshell-deftest var interp-concat2 | ||
| 411 | "Interpolate and concat two commands" | ||
| 412 | (eshell-command-result-p "+ ${+ 1 2}${+ 1 2} 3" "36\n")) | ||
| 413 | |||
| 414 | (eshell-deftest var interp-concat-lisp2 | ||
| 415 | "Interpolate and concat two Lisp forms" | ||
| 416 | (eshell-command-result-p "+ $(+ 1 2)$(+ 1 2) 3" "36\n")) | ||
| 417 | |||
| 418 | |||
| 419 | (provide 'esh-test) | ||
| 420 | |||
| 421 | ;;; esh-test.el ends here | ||