diff options
| author | Glenn Morris | 2011-03-05 12:07:27 -0800 |
|---|---|---|
| committer | Glenn Morris | 2011-03-05 12:07:27 -0800 |
| commit | 81fb60b2aa8bbd8699660588f56e15142aa91227 (patch) | |
| tree | ad11239e7633c540541f94f145478f83c89b64ad /lisp/eshell | |
| parent | c5f09daf79627a37d3eba0ec8c4cc0841007624d (diff) | |
| download | emacs-81fb60b2aa8bbd8699660588f56e15142aa91227.tar.gz emacs-81fb60b2aa8bbd8699660588f56e15142aa91227.zip | |
Move eshell's self-tests to the test/ directory.
* lisp/eshell/esh-var.el: Don't require esh-test when compiling.
* lisp/eshell/em-banner.el, lisp/eshell/esh-cmd.el, lisp/eshell/esh-mode.el:
* lisp/eshell/esh-var.el, lisp/eshell/eshell.el: Move tests to esh-test.
* lisp/eshell/esh-test.el: Move to ../../test/eshell.el
* test/eshell.el: Move here from lisp/eshell/esh-test.el.
Diffstat (limited to 'lisp/eshell')
| -rw-r--r-- | lisp/eshell/em-banner.el | 8 | ||||
| -rw-r--r-- | lisp/eshell/esh-cmd.el | 36 | ||||
| -rw-r--r-- | lisp/eshell/esh-mode.el | 73 | ||||
| -rw-r--r-- | lisp/eshell/esh-test.el | 233 | ||||
| -rw-r--r-- | lisp/eshell/esh-util.el | 12 | ||||
| -rw-r--r-- | lisp/eshell/esh-var.el | 25 | ||||
| -rw-r--r-- | lisp/eshell/eshell.el | 18 |
7 files changed, 0 insertions, 405 deletions
diff --git a/lisp/eshell/em-banner.el b/lisp/eshell/em-banner.el index c3e5a8b3d55..ce987f132e3 100644 --- a/lisp/eshell/em-banner.el +++ b/lisp/eshell/em-banner.el | |||
| @@ -82,14 +82,6 @@ This can be any sexp, and should end with at least two newlines." | |||
| 82 | (assert msg) | 82 | (assert msg) |
| 83 | (eshell-interactive-print msg)))) | 83 | (eshell-interactive-print msg)))) |
| 84 | 84 | ||
| 85 | (eshell-deftest banner banner-displayed | ||
| 86 | "Startup banner is displayed at point-min" | ||
| 87 | (assert eshell-banner-message) | ||
| 88 | (let ((msg (eval eshell-banner-message))) | ||
| 89 | (assert msg) | ||
| 90 | (goto-char (point-min)) | ||
| 91 | (looking-at msg))) | ||
| 92 | |||
| 93 | (provide 'em-banner) | 85 | (provide 'em-banner) |
| 94 | 86 | ||
| 95 | ;; Local Variables: | 87 | ;; Local Variables: |
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 62c14f38025..bdcdc453272 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el | |||
| @@ -320,18 +320,6 @@ otherwise t.") | |||
| 320 | (add-hook 'pcomplete-try-first-hook | 320 | (add-hook 'pcomplete-try-first-hook |
| 321 | 'eshell-complete-lisp-symbols nil t))) | 321 | 'eshell-complete-lisp-symbols nil t))) |
| 322 | 322 | ||
| 323 | (eshell-deftest var last-result-var | ||
| 324 | "\"last result\" variable" | ||
| 325 | (eshell-command-result-p "+ 1 2; + $$ 2" "3\n5\n")) | ||
| 326 | |||
| 327 | (eshell-deftest var last-result-var2 | ||
| 328 | "\"last result\" variable" | ||
| 329 | (eshell-command-result-p "+ 1 2; + $$ $$" "3\n6\n")) | ||
| 330 | |||
| 331 | (eshell-deftest var last-arg-var | ||
| 332 | "\"last arg\" variable" | ||
| 333 | (eshell-command-result-p "+ 1 2; + $_ 4" "3\n6\n")) | ||
| 334 | |||
| 335 | (defun eshell-complete-lisp-symbols () | 323 | (defun eshell-complete-lisp-symbols () |
| 336 | "If there is a user reference, complete it." | 324 | "If there is a user reference, complete it." |
| 337 | (let ((arg (pcomplete-actual-arg))) | 325 | (let ((arg (pcomplete-actual-arg))) |
| @@ -441,32 +429,12 @@ hooks should be run before and after the command." | |||
| 441 | (eq (caar terms) 'eshell-command-to-value)) | 429 | (eq (caar terms) 'eshell-command-to-value)) |
| 442 | (car (cdar terms)))) | 430 | (car (cdar terms)))) |
| 443 | 431 | ||
| 444 | (eshell-deftest cmd lisp-command | ||
| 445 | "Evaluate Lisp command" | ||
| 446 | (eshell-command-result-p "(+ 1 2)" "3")) | ||
| 447 | |||
| 448 | (eshell-deftest cmd lisp-command-args | ||
| 449 | "Evaluate Lisp command (ignore args)" | ||
| 450 | (eshell-command-result-p "(+ 1 2) 3" "3")) | ||
| 451 | |||
| 452 | (defun eshell-rewrite-initial-subcommand (terms) | 432 | (defun eshell-rewrite-initial-subcommand (terms) |
| 453 | "Rewrite a subcommand in initial position, such as '{+ 1 2}'." | 433 | "Rewrite a subcommand in initial position, such as '{+ 1 2}'." |
| 454 | (if (and (listp (car terms)) | 434 | (if (and (listp (car terms)) |
| 455 | (eq (caar terms) 'eshell-as-subcommand)) | 435 | (eq (caar terms) 'eshell-as-subcommand)) |
| 456 | (car terms))) | 436 | (car terms))) |
| 457 | 437 | ||
| 458 | (eshell-deftest cmd subcommand | ||
| 459 | "Run subcommand" | ||
| 460 | (eshell-command-result-p "{+ 1 2}" "3\n")) | ||
| 461 | |||
| 462 | (eshell-deftest cmd subcommand-args | ||
| 463 | "Run subcommand (ignore args)" | ||
| 464 | (eshell-command-result-p "{+ 1 2} 3" "3\n")) | ||
| 465 | |||
| 466 | (eshell-deftest cmd subcommand-lisp | ||
| 467 | "Run subcommand + Lisp form" | ||
| 468 | (eshell-command-result-p "{(+ 1 2)}" "3\n")) | ||
| 469 | |||
| 470 | (defun eshell-rewrite-named-command (terms) | 438 | (defun eshell-rewrite-named-command (terms) |
| 471 | "If no other rewriting rule transforms TERMS, assume a named command." | 439 | "If no other rewriting rule transforms TERMS, assume a named command." |
| 472 | (let ((sym (if eshell-in-pipeline-p | 440 | (let ((sym (if eshell-in-pipeline-p |
| @@ -478,10 +446,6 @@ hooks should be run before and after the command." | |||
| 478 | (list sym cmd (append (list 'list) (cdr terms))) | 446 | (list sym cmd (append (list 'list) (cdr terms))) |
| 479 | (list sym cmd)))) | 447 | (list sym cmd)))) |
| 480 | 448 | ||
| 481 | (eshell-deftest cmd named-command | ||
| 482 | "Execute named command" | ||
| 483 | (eshell-command-result-p "+ 1 2" "3\n")) | ||
| 484 | |||
| 485 | (defvar eshell-command-body) | 449 | (defvar eshell-command-body) |
| 486 | (defvar eshell-test-body) | 450 | (defvar eshell-test-body) |
| 487 | 451 | ||
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index f7c727aa36f..10623dba8e3 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el | |||
| @@ -447,19 +447,6 @@ and the hook `eshell-exit-hook'." | |||
| 447 | 447 | ||
| 448 | (put 'eshell-mode 'mode-class 'special) | 448 | (put 'eshell-mode 'mode-class 'special) |
| 449 | 449 | ||
| 450 | (eshell-deftest mode major-mode | ||
| 451 | "Major mode is correct" | ||
| 452 | (eq major-mode 'eshell-mode)) | ||
| 453 | |||
| 454 | (eshell-deftest mode eshell-mode-variable | ||
| 455 | "`eshell-mode' is true" | ||
| 456 | (eq eshell-mode t)) | ||
| 457 | |||
| 458 | (eshell-deftest var window-height | ||
| 459 | "LINES equals window height" | ||
| 460 | (let ((eshell-stringify-t t)) | ||
| 461 | (eshell-command-result-p "= $LINES (window-height)" "t\n"))) | ||
| 462 | |||
| 463 | (defun eshell-command-started () | 450 | (defun eshell-command-started () |
| 464 | "Indicate in the modeline that a command has started." | 451 | "Indicate in the modeline that a command has started." |
| 465 | (setq eshell-command-running-string "**") | 452 | (setq eshell-command-running-string "**") |
| @@ -470,13 +457,6 @@ and the hook `eshell-exit-hook'." | |||
| 470 | (setq eshell-command-running-string "--") | 457 | (setq eshell-command-running-string "--") |
| 471 | (force-mode-line-update)) | 458 | (force-mode-line-update)) |
| 472 | 459 | ||
| 473 | (eshell-deftest mode command-running-p | ||
| 474 | "Modeline shows no command running" | ||
| 475 | (or (featurep 'xemacs) | ||
| 476 | (not eshell-status-in-modeline) | ||
| 477 | (and (memq 'eshell-command-running-string mode-line-format) | ||
| 478 | (equal eshell-command-running-string "--")))) | ||
| 479 | |||
| 480 | ;;; Internal Functions: | 460 | ;;; Internal Functions: |
| 481 | 461 | ||
| 482 | (defun eshell-toggle-direct-send () | 462 | (defun eshell-toggle-direct-send () |
| @@ -546,20 +526,6 @@ and the hook `eshell-exit-hook'." | |||
| 546 | (= (1+ pos) limit)) | 526 | (= (1+ pos) limit)) |
| 547 | (forward-char 1)))) | 527 | (forward-char 1)))) |
| 548 | 528 | ||
| 549 | (eshell-deftest arg forward-arg | ||
| 550 | "Move across command arguments" | ||
| 551 | (eshell-insert-command "echo $(+ 1 (- 4 3)) \"alpha beta\" file" 'ignore) | ||
| 552 | (let ((here (point)) begin valid) | ||
| 553 | (eshell-bol) | ||
| 554 | (setq begin (point)) | ||
| 555 | (eshell-forward-argument 4) | ||
| 556 | (setq valid (= here (point))) | ||
| 557 | (eshell-backward-argument 4) | ||
| 558 | (prog1 | ||
| 559 | (and valid (= begin (point))) | ||
| 560 | (eshell-bol) | ||
| 561 | (delete-region (point) (point-max))))) | ||
| 562 | |||
| 563 | (defun eshell-forward-argument (&optional arg) | 529 | (defun eshell-forward-argument (&optional arg) |
| 564 | "Move forward ARG arguments." | 530 | "Move forward ARG arguments." |
| 565 | (interactive "p") | 531 | (interactive "p") |
| @@ -659,17 +625,6 @@ waiting for input." | |||
| 659 | (interactive "P") | 625 | (interactive "P") |
| 660 | (eshell-send-input use-region t)) | 626 | (eshell-send-input use-region t)) |
| 661 | 627 | ||
| 662 | (eshell-deftest mode queue-input | ||
| 663 | "Queue command input" | ||
| 664 | (eshell-insert-command "sleep 2") | ||
| 665 | (eshell-insert-command "echo alpha" 'eshell-queue-input) | ||
| 666 | (let ((count 10)) | ||
| 667 | (while (and eshell-current-command | ||
| 668 | (> count 0)) | ||
| 669 | (sit-for 1 0) | ||
| 670 | (setq count (1- count)))) | ||
| 671 | (eshell-match-result "alpha\n")) | ||
| 672 | |||
| 673 | (defun eshell-send-input (&optional use-region queue-p no-newline) | 628 | (defun eshell-send-input (&optional use-region queue-p no-newline) |
| 674 | "Send the input received to Eshell for parsing and processing. | 629 | "Send the input received to Eshell for parsing and processing. |
| 675 | After `eshell-last-output-end', sends all text from that marker to | 630 | After `eshell-last-output-end', sends all text from that marker to |
| @@ -748,20 +703,6 @@ newline." | |||
| 748 | (run-hooks 'eshell-post-command-hook) | 703 | (run-hooks 'eshell-post-command-hook) |
| 749 | (insert-and-inherit input))))))))) | 704 | (insert-and-inherit input))))))))) |
| 750 | 705 | ||
| 751 | ; (eshell-deftest proc send-to-subprocess | ||
| 752 | ; "Send input to a subprocess" | ||
| 753 | ; ;; jww (1999-12-06): what about when bc is unavailable? | ||
| 754 | ; (if (not (eshell-search-path "bc")) | ||
| 755 | ; t | ||
| 756 | ; (eshell-insert-command "bc") | ||
| 757 | ; (eshell-insert-command "1 + 2") | ||
| 758 | ; (sit-for 1 0) | ||
| 759 | ; (forward-line -1) | ||
| 760 | ; (prog1 | ||
| 761 | ; (looking-at "3\n") | ||
| 762 | ; (eshell-insert-command "quit") | ||
| 763 | ; (sit-for 1 0)))) | ||
| 764 | |||
| 765 | (defsubst eshell-kill-new () | 706 | (defsubst eshell-kill-new () |
| 766 | "Add the last input text to the kill ring." | 707 | "Add the last input text to the kill ring." |
| 767 | (kill-ring-save eshell-last-input-start eshell-last-input-end)) | 708 | (kill-ring-save eshell-last-input-start eshell-last-input-end)) |
| @@ -907,14 +848,6 @@ Does not delete the prompt." | |||
| 907 | (insert "*** output flushed ***\n") | 848 | (insert "*** output flushed ***\n") |
| 908 | (delete-region (point) (eshell-end-of-output)))) | 849 | (delete-region (point) (eshell-end-of-output)))) |
| 909 | 850 | ||
| 910 | (eshell-deftest io flush-output | ||
| 911 | "Flush previous output" | ||
| 912 | (eshell-insert-command "echo alpha") | ||
| 913 | (eshell-kill-output) | ||
| 914 | (and (eshell-match-result (regexp-quote "*** output flushed ***\n")) | ||
| 915 | (forward-line) | ||
| 916 | (= (point) eshell-last-output-start))) | ||
| 917 | |||
| 918 | (defun eshell-show-output (&optional arg) | 851 | (defun eshell-show-output (&optional arg) |
| 919 | "Display start of this batch of interpreter output at top of window. | 852 | "Display start of this batch of interpreter output at top of window. |
| 920 | Sets mark to the value of point when this command is run. | 853 | Sets mark to the value of point when this command is run. |
| @@ -975,12 +908,6 @@ When run interactively, widen the buffer first." | |||
| 975 | (goto-char eshell-last-output-end) | 908 | (goto-char eshell-last-output-end) |
| 976 | (insert-and-inherit input))) | 909 | (insert-and-inherit input))) |
| 977 | 910 | ||
| 978 | (eshell-deftest mode run-old-command | ||
| 979 | "Re-run an old command" | ||
| 980 | (eshell-insert-command "echo alpha") | ||
| 981 | (goto-char eshell-last-input-start) | ||
| 982 | (string= (eshell-get-old-input) "echo alpha")) | ||
| 983 | |||
| 984 | (defun eshell/exit () | 911 | (defun eshell/exit () |
| 985 | "Leave or kill the Eshell buffer, depending on `eshell-kill-on-exit'." | 912 | "Leave or kill the Eshell buffer, depending on `eshell-kill-on-exit'." |
| 986 | (throw 'eshell-terminal t)) | 913 | (throw 'eshell-terminal t)) |
diff --git a/lisp/eshell/esh-test.el b/lisp/eshell/esh-test.el deleted file mode 100644 index 73ba16116c0..00000000000 --- a/lisp/eshell/esh-test.el +++ /dev/null | |||
| @@ -1,233 +0,0 @@ | |||
| 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 'eshell) | ||
| 32 | (require 'esh-util)) | ||
| 33 | (require 'esh-mode) | ||
| 34 | |||
| 35 | (defgroup eshell-test nil | ||
| 36 | "This module is meant to ensure that Eshell is working correctly." | ||
| 37 | :tag "Eshell test suite" | ||
| 38 | :group 'eshell) | ||
| 39 | |||
| 40 | ;;; User Variables: | ||
| 41 | |||
| 42 | (defface eshell-test-ok | ||
| 43 | '((((class color) (background light)) (:foreground "Green" :bold t)) | ||
| 44 | (((class color) (background dark)) (:foreground "Green" :bold t))) | ||
| 45 | "The face used to highlight OK result strings." | ||
| 46 | :group 'eshell-test) | ||
| 47 | (define-obsolete-face-alias 'eshell-test-ok-face 'eshell-test-ok "22.1") | ||
| 48 | |||
| 49 | (defface eshell-test-failed | ||
| 50 | '((((class color) (background light)) (:foreground "OrangeRed" :bold t)) | ||
| 51 | (((class color) (background dark)) (:foreground "OrangeRed" :bold t)) | ||
| 52 | (t (:bold t))) | ||
| 53 | "The face used to highlight FAILED result strings." | ||
| 54 | :group 'eshell-test) | ||
| 55 | (define-obsolete-face-alias 'eshell-test-failed-face 'eshell-test-failed "22.1") | ||
| 56 | |||
| 57 | (defcustom eshell-show-usage-metrics nil | ||
| 58 | "If non-nil, display different usage metrics for each Eshell command." | ||
| 59 | :set (lambda (symbol value) | ||
| 60 | (if value | ||
| 61 | (add-hook 'eshell-mode-hook 'eshell-show-usage-metrics) | ||
| 62 | (remove-hook 'eshell-mode-hook 'eshell-show-usage-metrics)) | ||
| 63 | (set symbol value)) | ||
| 64 | :type '(choice (const :tag "No metrics" nil) | ||
| 65 | (const :tag "Cons cells consumed" t) | ||
| 66 | (const :tag "Time elapsed" 0)) | ||
| 67 | :group 'eshell-test) | ||
| 68 | |||
| 69 | ;;; Code: | ||
| 70 | |||
| 71 | (defvar test-buffer) | ||
| 72 | |||
| 73 | (defun eshell-insert-command (text &optional func) | ||
| 74 | "Insert a command at the end of the buffer." | ||
| 75 | (goto-char eshell-last-output-end) | ||
| 76 | (insert-and-inherit text) | ||
| 77 | (funcall (or func 'eshell-send-input))) | ||
| 78 | |||
| 79 | (defun eshell-match-result (regexp) | ||
| 80 | "Insert a command at the end of the buffer." | ||
| 81 | (goto-char eshell-last-input-end) | ||
| 82 | (looking-at regexp)) | ||
| 83 | |||
| 84 | (defun eshell-command-result-p (text regexp &optional func) | ||
| 85 | "Insert a command at the end of the buffer." | ||
| 86 | (eshell-insert-command text func) | ||
| 87 | (eshell-match-result regexp)) | ||
| 88 | |||
| 89 | (defvar eshell-test-failures nil) | ||
| 90 | |||
| 91 | (defun eshell-run-test (module funcsym label command) | ||
| 92 | "Test whether FORM evaluates to a non-nil value." | ||
| 93 | (when (let ((sym (intern-soft (concat "eshell-" (symbol-name module))))) | ||
| 94 | (or (memq sym (eshell-subgroups 'eshell)) | ||
| 95 | (eshell-using-module sym))) | ||
| 96 | (with-current-buffer test-buffer | ||
| 97 | (insert-before-markers | ||
| 98 | (format "%-70s " (substring label 0 (min 70 (length label))))) | ||
| 99 | (insert-before-markers " ....") | ||
| 100 | (eshell-redisplay)) | ||
| 101 | (let ((truth (eval command))) | ||
| 102 | (with-current-buffer test-buffer | ||
| 103 | (delete-char -6) | ||
| 104 | (insert-before-markers | ||
| 105 | "[" (let (str) | ||
| 106 | (if truth | ||
| 107 | (progn | ||
| 108 | (setq str " OK ") | ||
| 109 | (put-text-property 0 6 'face 'eshell-test-ok str)) | ||
| 110 | (setq str "FAILED") | ||
| 111 | (setq eshell-test-failures (1+ eshell-test-failures)) | ||
| 112 | (put-text-property 0 6 'face 'eshell-test-failed str)) | ||
| 113 | str) "]") | ||
| 114 | (add-text-properties (line-beginning-position) (point) | ||
| 115 | (list 'test-func funcsym)) | ||
| 116 | (eshell-redisplay))))) | ||
| 117 | |||
| 118 | (defun eshell-test-goto-func () | ||
| 119 | "Jump to the function that defines a particular test." | ||
| 120 | (interactive) | ||
| 121 | (let ((fsym (get-text-property (point) 'test-func))) | ||
| 122 | (when fsym | ||
| 123 | (let* ((def (symbol-function fsym)) | ||
| 124 | (library (locate-library (symbol-file fsym 'defun))) | ||
| 125 | (name (substring (symbol-name fsym) | ||
| 126 | (length "eshell-test--"))) | ||
| 127 | (inhibit-redisplay t)) | ||
| 128 | (find-file library) | ||
| 129 | (goto-char (point-min)) | ||
| 130 | (re-search-forward (concat "^(eshell-deftest\\s-+\\w+\\s-+" | ||
| 131 | name)) | ||
| 132 | (beginning-of-line))))) | ||
| 133 | |||
| 134 | (defun eshell-run-one-test (&optional arg) | ||
| 135 | "Jump to the function that defines a particular test." | ||
| 136 | (interactive "P") | ||
| 137 | (let ((fsym (get-text-property (point) 'test-func))) | ||
| 138 | (when fsym | ||
| 139 | (beginning-of-line) | ||
| 140 | (delete-region (point) (line-end-position)) | ||
| 141 | (let ((test-buffer (current-buffer))) | ||
| 142 | (set-buffer (let ((inhibit-redisplay t)) | ||
| 143 | (save-window-excursion (eshell t)))) | ||
| 144 | (funcall fsym) | ||
| 145 | (unless arg | ||
| 146 | (kill-buffer (current-buffer))))))) | ||
| 147 | |||
| 148 | ;;;###autoload | ||
| 149 | (defun eshell-test (&optional arg) | ||
| 150 | "Test Eshell to verify that it works as expected." | ||
| 151 | (interactive "P") | ||
| 152 | (let* ((begin (float-time)) | ||
| 153 | (test-buffer (get-buffer-create "*eshell test*"))) | ||
| 154 | (set-buffer (let ((inhibit-redisplay t)) | ||
| 155 | (save-window-excursion (eshell t)))) | ||
| 156 | (with-current-buffer test-buffer | ||
| 157 | (erase-buffer) | ||
| 158 | (setq major-mode 'eshell-test-mode) | ||
| 159 | (setq mode-name "EShell Test") | ||
| 160 | (set (make-local-variable 'eshell-test-failures) 0) | ||
| 161 | (local-set-key [(control ?c) (control ?c)] 'eshell-test-goto-func) | ||
| 162 | (local-set-key [(control ?c) (control ?r)] 'eshell-run-one-test) | ||
| 163 | (local-set-key [(control ?m)] 'eshell-test-goto-func) | ||
| 164 | (local-set-key [return] 'eshell-test-goto-func) | ||
| 165 | |||
| 166 | (insert "Testing Eshell under " (emacs-version)) | ||
| 167 | (switch-to-buffer test-buffer) | ||
| 168 | (delete-other-windows)) | ||
| 169 | (dolist (funcname (sort (all-completions "eshell-test--" | ||
| 170 | obarray 'functionp) | ||
| 171 | 'string-lessp)) | ||
| 172 | (with-current-buffer test-buffer | ||
| 173 | (insert "\n")) | ||
| 174 | (funcall (intern-soft funcname))) | ||
| 175 | (with-current-buffer test-buffer | ||
| 176 | (insert (format "\n\n--- %s --- (completed in %d seconds)\n" | ||
| 177 | (current-time-string) | ||
| 178 | (- (float-time) begin))) | ||
| 179 | (message "Eshell test suite completed: %s failure%s" | ||
| 180 | (if (> eshell-test-failures 0) | ||
| 181 | (number-to-string eshell-test-failures) | ||
| 182 | "No") | ||
| 183 | (if (= eshell-test-failures 1) "" "s")))) | ||
| 184 | (goto-char eshell-last-output-end) | ||
| 185 | (unless arg | ||
| 186 | (kill-buffer (current-buffer)))) | ||
| 187 | |||
| 188 | |||
| 189 | (defvar eshell-metric-before-command 0) | ||
| 190 | (defvar eshell-metric-after-command 0) | ||
| 191 | |||
| 192 | (defun eshell-show-usage-metrics () | ||
| 193 | "If run at Eshell mode startup, metrics are shown after each command." | ||
| 194 | (set (make-local-variable 'eshell-metric-before-command) | ||
| 195 | (if (eq eshell-show-usage-metrics t) | ||
| 196 | 0 | ||
| 197 | (current-time))) | ||
| 198 | (set (make-local-variable 'eshell-metric-after-command) | ||
| 199 | (if (eq eshell-show-usage-metrics t) | ||
| 200 | 0 | ||
| 201 | (current-time))) | ||
| 202 | |||
| 203 | (add-hook 'eshell-pre-command-hook | ||
| 204 | (function | ||
| 205 | (lambda () | ||
| 206 | (setq eshell-metric-before-command | ||
| 207 | (if (eq eshell-show-usage-metrics t) | ||
| 208 | (car (memory-use-counts)) | ||
| 209 | (current-time))))) nil t) | ||
| 210 | |||
| 211 | (add-hook 'eshell-post-command-hook | ||
| 212 | (function | ||
| 213 | (lambda () | ||
| 214 | (setq eshell-metric-after-command | ||
| 215 | (if (eq eshell-show-usage-metrics t) | ||
| 216 | (car (memory-use-counts)) | ||
| 217 | (current-time))) | ||
| 218 | (eshell-interactive-print | ||
| 219 | (concat | ||
| 220 | (int-to-string | ||
| 221 | (if (eq eshell-show-usage-metrics t) | ||
| 222 | (- eshell-metric-after-command | ||
| 223 | eshell-metric-before-command 7) | ||
| 224 | (- (float-time | ||
| 225 | eshell-metric-after-command) | ||
| 226 | (float-time | ||
| 227 | eshell-metric-before-command)))) | ||
| 228 | "\n")))) | ||
| 229 | nil t)) | ||
| 230 | |||
| 231 | (provide 'esh-test) | ||
| 232 | |||
| 233 | ;;; esh-test.el ends here | ||
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el index 8b62b04a8ea..dbe4f824deb 100644 --- a/lisp/eshell/esh-util.el +++ b/lisp/eshell/esh-util.el | |||
| @@ -147,18 +147,6 @@ function `string-to-number'." | |||
| 147 | 147 | ||
| 148 | (put 'eshell-condition-case 'lisp-indent-function 2) | 148 | (put 'eshell-condition-case 'lisp-indent-function 2) |
| 149 | 149 | ||
| 150 | (defmacro eshell-deftest (module name label &rest forms) | ||
| 151 | (if (and (fboundp 'cl-compiling-file) (cl-compiling-file)) | ||
| 152 | nil | ||
| 153 | (let ((fsym (intern (concat "eshell-test--" (symbol-name name))))) | ||
| 154 | `(eval-when-compile | ||
| 155 | (ignore | ||
| 156 | (defun ,fsym () ,label | ||
| 157 | (eshell-run-test (quote ,module) (quote ,fsym) ,label | ||
| 158 | (quote (progn ,@forms))))))))) | ||
| 159 | |||
| 160 | (put 'eshell-deftest 'lisp-indent-function 2) | ||
| 161 | |||
| 162 | (defun eshell-find-delimiter | 150 | (defun eshell-find-delimiter |
| 163 | (open close &optional bound reverse-p backslash-p) | 151 | (open close &optional bound reverse-p backslash-p) |
| 164 | "From point, find the CLOSE delimiter corresponding to OPEN. | 152 | "From point, find the CLOSE delimiter corresponding to OPEN. |
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el index ae87215a767..69004a841f1 100644 --- a/lisp/eshell/esh-var.el +++ b/lisp/eshell/esh-var.el | |||
| @@ -109,7 +109,6 @@ | |||
| 109 | 109 | ||
| 110 | (eval-when-compile | 110 | (eval-when-compile |
| 111 | (require 'pcomplete) | 111 | (require 'pcomplete) |
| 112 | (require 'esh-test) | ||
| 113 | (require 'esh-util) | 112 | (require 'esh-util) |
| 114 | (require 'esh-opt) | 113 | (require 'esh-opt) |
| 115 | (require 'esh-mode)) | 114 | (require 'esh-mode)) |
| @@ -477,30 +476,6 @@ Possible options are: | |||
| 477 | (t | 476 | (t |
| 478 | (error "Invalid variable reference"))))) | 477 | (error "Invalid variable reference"))))) |
| 479 | 478 | ||
| 480 | (eshell-deftest var interp-cmd | ||
| 481 | "Interpolate command result" | ||
| 482 | (eshell-command-result-p "+ ${+ 1 2} 3" "6\n")) | ||
| 483 | |||
| 484 | (eshell-deftest var interp-lisp | ||
| 485 | "Interpolate Lisp form evalution" | ||
| 486 | (eshell-command-result-p "+ $(+ 1 2) 3" "6\n")) | ||
| 487 | |||
| 488 | (eshell-deftest var interp-concat | ||
| 489 | "Interpolate and concat command" | ||
| 490 | (eshell-command-result-p "+ ${+ 1 2}3 3" "36\n")) | ||
| 491 | |||
| 492 | (eshell-deftest var interp-concat-lisp | ||
| 493 | "Interpolate and concat Lisp form" | ||
| 494 | (eshell-command-result-p "+ $(+ 1 2)3 3" "36\n")) | ||
| 495 | |||
| 496 | (eshell-deftest var interp-concat2 | ||
| 497 | "Interpolate and concat two commands" | ||
| 498 | (eshell-command-result-p "+ ${+ 1 2}${+ 1 2} 3" "36\n")) | ||
| 499 | |||
| 500 | (eshell-deftest var interp-concat-lisp2 | ||
| 501 | "Interpolate and concat two Lisp forms" | ||
| 502 | (eshell-command-result-p "+ $(+ 1 2)$(+ 1 2) 3" "36\n")) | ||
| 503 | |||
| 504 | (defun eshell-parse-indices () | 479 | (defun eshell-parse-indices () |
| 505 | "Parse and return a list of list of indices." | 480 | "Parse and return a list of list of indices." |
| 506 | (let (indices) | 481 | (let (indices) |
diff --git a/lisp/eshell/eshell.el b/lisp/eshell/eshell.el index cda1eea2c55..1a9d7c97b83 100644 --- a/lisp/eshell/eshell.el +++ b/lisp/eshell/eshell.el | |||
| @@ -280,26 +280,12 @@ shells such as bash, zsh, rc, 4dos." | |||
| 280 | :type 'string | 280 | :type 'string |
| 281 | :group 'eshell) | 281 | :group 'eshell) |
| 282 | 282 | ||
| 283 | (eshell-deftest mode same-window-buffer-names | ||
| 284 | "`eshell-buffer-name' is a member of `same-window-buffer-names'" | ||
| 285 | (member eshell-buffer-name same-window-buffer-names)) | ||
| 286 | |||
| 287 | (defcustom eshell-directory-name | 283 | (defcustom eshell-directory-name |
| 288 | (locate-user-emacs-file "eshell/" ".eshell/") | 284 | (locate-user-emacs-file "eshell/" ".eshell/") |
| 289 | "The directory where Eshell control files should be kept." | 285 | "The directory where Eshell control files should be kept." |
| 290 | :type 'directory | 286 | :type 'directory |
| 291 | :group 'eshell) | 287 | :group 'eshell) |
| 292 | 288 | ||
| 293 | (eshell-deftest mode eshell-directory-exists | ||
| 294 | "`eshell-directory-name' exists and is writable" | ||
| 295 | (file-writable-p eshell-directory-name)) | ||
| 296 | |||
| 297 | (eshell-deftest mode eshell-directory-modes | ||
| 298 | "`eshell-directory-name' has correct access protections" | ||
| 299 | (or (eshell-under-windows-p) | ||
| 300 | (= (file-modes eshell-directory-name) | ||
| 301 | eshell-private-directory-modes))) | ||
| 302 | |||
| 303 | ;;;_* Running Eshell | 289 | ;;;_* Running Eshell |
| 304 | ;; | 290 | ;; |
| 305 | ;; There are only three commands used to invoke Eshell. The first two | 291 | ;; There are only three commands used to invoke Eshell. The first two |
| @@ -450,10 +436,6 @@ corresponding to a successful execution." | |||
| 450 | (set status-var eshell-last-command-status)) | 436 | (set status-var eshell-last-command-status)) |
| 451 | (cadr result)))))) | 437 | (cadr result)))))) |
| 452 | 438 | ||
| 453 | (eshell-deftest mode simple-command-result | ||
| 454 | "`eshell-command-result' works with a simple command." | ||
| 455 | (= (eshell-command-result "+ 1 2") 3)) | ||
| 456 | |||
| 457 | ;;;_* Reporting bugs | 439 | ;;;_* Reporting bugs |
| 458 | ;; | 440 | ;; |
| 459 | ;; If you do encounter a bug, on any system, please report | 441 | ;; If you do encounter a bug, on any system, please report |