diff options
author | Glenn Morris <rgm@gnu.org> | 2011-03-05 12:07:27 -0800 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2011-03-05 12:07:27 -0800 |
commit | 81fb60b2aa8bbd8699660588f56e15142aa91227 (patch) | |
tree | ad11239e7633c540541f94f145478f83c89b64ad | |
parent | c5f09daf79627a37d3eba0ec8c4cc0841007624d (diff) | |
download | emacs-81fb60b2aa8bbd8699660588f56e15142aa91227.tar.gz |
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.
-rw-r--r-- | lisp/ChangeLog | 7 | ||||
-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-util.el | 12 | ||||
-rw-r--r-- | lisp/eshell/esh-var.el | 25 | ||||
-rw-r--r-- | lisp/eshell/eshell.el | 18 | ||||
-rw-r--r-- | test/ChangeLog | 4 | ||||
-rw-r--r-- | test/eshell.el (renamed from lisp/eshell/esh-test.el) | 188 |
9 files changed, 199 insertions, 172 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e0cdeae84af..33aa29ea41b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2011-03-05 Glenn Morris <rgm@gnu.org> + + * eshell/esh-var.el: Don't require esh-test when compiling. + * eshell/em-banner.el, eshell/esh-cmd.el, eshell/esh-mode.el: + * eshell/esh-var.el, eshell/eshell.el: Move tests to esh-test. + * eshell/esh-test.el: Move to ../../test/eshell.el + 2011-03-05 David Engster <deng@randomsample.de> * files.el (save-some-buffers): Report the names of buffers saved 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." (assert msg) (eshell-interactive-print msg)))) -(eshell-deftest banner banner-displayed - "Startup banner is displayed at point-min" - (assert eshell-banner-message) - (let ((msg (eval eshell-banner-message))) - (assert msg) - (goto-char (point-min)) - (looking-at msg))) - (provide 'em-banner) ;; 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.") (add-hook 'pcomplete-try-first-hook 'eshell-complete-lisp-symbols nil t))) -(eshell-deftest var last-result-var - "\"last result\" variable" - (eshell-command-result-p "+ 1 2; + $$ 2" "3\n5\n")) - -(eshell-deftest var last-result-var2 - "\"last result\" variable" - (eshell-command-result-p "+ 1 2; + $$ $$" "3\n6\n")) - -(eshell-deftest var last-arg-var - "\"last arg\" variable" - (eshell-command-result-p "+ 1 2; + $_ 4" "3\n6\n")) - (defun eshell-complete-lisp-symbols () "If there is a user reference, complete it." (let ((arg (pcomplete-actual-arg))) @@ -441,32 +429,12 @@ hooks should be run before and after the command." (eq (caar terms) 'eshell-command-to-value)) (car (cdar terms)))) -(eshell-deftest cmd lisp-command - "Evaluate Lisp command" - (eshell-command-result-p "(+ 1 2)" "3")) - -(eshell-deftest cmd lisp-command-args - "Evaluate Lisp command (ignore args)" - (eshell-command-result-p "(+ 1 2) 3" "3")) - (defun eshell-rewrite-initial-subcommand (terms) "Rewrite a subcommand in initial position, such as '{+ 1 2}'." (if (and (listp (car terms)) (eq (caar terms) 'eshell-as-subcommand)) (car terms))) -(eshell-deftest cmd subcommand - "Run subcommand" - (eshell-command-result-p "{+ 1 2}" "3\n")) - -(eshell-deftest cmd subcommand-args - "Run subcommand (ignore args)" - (eshell-command-result-p "{+ 1 2} 3" "3\n")) - -(eshell-deftest cmd subcommand-lisp - "Run subcommand + Lisp form" - (eshell-command-result-p "{(+ 1 2)}" "3\n")) - (defun eshell-rewrite-named-command (terms) "If no other rewriting rule transforms TERMS, assume a named command." (let ((sym (if eshell-in-pipeline-p @@ -478,10 +446,6 @@ hooks should be run before and after the command." (list sym cmd (append (list 'list) (cdr terms))) (list sym cmd)))) -(eshell-deftest cmd named-command - "Execute named command" - (eshell-command-result-p "+ 1 2" "3\n")) - (defvar eshell-command-body) (defvar eshell-test-body) 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'." (put 'eshell-mode 'mode-class 'special) -(eshell-deftest mode major-mode - "Major mode is correct" - (eq major-mode 'eshell-mode)) - -(eshell-deftest mode eshell-mode-variable - "`eshell-mode' is true" - (eq eshell-mode t)) - -(eshell-deftest var window-height - "LINES equals window height" - (let ((eshell-stringify-t t)) - (eshell-command-result-p "= $LINES (window-height)" "t\n"))) - (defun eshell-command-started () "Indicate in the modeline that a command has started." (setq eshell-command-running-string "**") @@ -470,13 +457,6 @@ and the hook `eshell-exit-hook'." (setq eshell-command-running-string "--") (force-mode-line-update)) -(eshell-deftest mode command-running-p - "Modeline shows no command running" - (or (featurep 'xemacs) - (not eshell-status-in-modeline) - (and (memq 'eshell-command-running-string mode-line-format) - (equal eshell-command-running-string "--")))) - ;;; Internal Functions: (defun eshell-toggle-direct-send () @@ -546,20 +526,6 @@ and the hook `eshell-exit-hook'." (= (1+ pos) limit)) (forward-char 1)))) -(eshell-deftest arg forward-arg - "Move across command arguments" - (eshell-insert-command "echo $(+ 1 (- 4 3)) \"alpha beta\" file" 'ignore) - (let ((here (point)) begin valid) - (eshell-bol) - (setq begin (point)) - (eshell-forward-argument 4) - (setq valid (= here (point))) - (eshell-backward-argument 4) - (prog1 - (and valid (= begin (point))) - (eshell-bol) - (delete-region (point) (point-max))))) - (defun eshell-forward-argument (&optional arg) "Move forward ARG arguments." (interactive "p") @@ -659,17 +625,6 @@ waiting for input." (interactive "P") (eshell-send-input use-region t)) -(eshell-deftest mode queue-input - "Queue command input" - (eshell-insert-command "sleep 2") - (eshell-insert-command "echo alpha" 'eshell-queue-input) - (let ((count 10)) - (while (and eshell-current-command - (> count 0)) - (sit-for 1 0) - (setq count (1- count)))) - (eshell-match-result "alpha\n")) - (defun eshell-send-input (&optional use-region queue-p no-newline) "Send the input received to Eshell for parsing and processing. After `eshell-last-output-end', sends all text from that marker to @@ -748,20 +703,6 @@ newline." (run-hooks 'eshell-post-command-hook) (insert-and-inherit input))))))))) -; (eshell-deftest proc send-to-subprocess -; "Send input to a subprocess" -; ;; jww (1999-12-06): what about when bc is unavailable? -; (if (not (eshell-search-path "bc")) -; t -; (eshell-insert-command "bc") -; (eshell-insert-command "1 + 2") -; (sit-for 1 0) -; (forward-line -1) -; (prog1 -; (looking-at "3\n") -; (eshell-insert-command "quit") -; (sit-for 1 0)))) - (defsubst eshell-kill-new () "Add the last input text to the kill ring." (kill-ring-save eshell-last-input-start eshell-last-input-end)) @@ -907,14 +848,6 @@ Does not delete the prompt." (insert "*** output flushed ***\n") (delete-region (point) (eshell-end-of-output)))) -(eshell-deftest io flush-output - "Flush previous output" - (eshell-insert-command "echo alpha") - (eshell-kill-output) - (and (eshell-match-result (regexp-quote "*** output flushed ***\n")) - (forward-line) - (= (point) eshell-last-output-start))) - (defun eshell-show-output (&optional arg) "Display start of this batch of interpreter output at top of window. Sets mark to the value of point when this command is run. @@ -975,12 +908,6 @@ When run interactively, widen the buffer first." (goto-char eshell-last-output-end) (insert-and-inherit input))) -(eshell-deftest mode run-old-command - "Re-run an old command" - (eshell-insert-command "echo alpha") - (goto-char eshell-last-input-start) - (string= (eshell-get-old-input) "echo alpha")) - (defun eshell/exit () "Leave or kill the Eshell buffer, depending on `eshell-kill-on-exit'." (throw 'eshell-terminal t)) 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'." (put 'eshell-condition-case 'lisp-indent-function 2) -(defmacro eshell-deftest (module name label &rest forms) - (if (and (fboundp 'cl-compiling-file) (cl-compiling-file)) - nil - (let ((fsym (intern (concat "eshell-test--" (symbol-name name))))) - `(eval-when-compile - (ignore - (defun ,fsym () ,label - (eshell-run-test (quote ,module) (quote ,fsym) ,label - (quote (progn ,@forms))))))))) - -(put 'eshell-deftest 'lisp-indent-function 2) - (defun eshell-find-delimiter (open close &optional bound reverse-p backslash-p) "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 @@ (eval-when-compile (require 'pcomplete) - (require 'esh-test) (require 'esh-util) (require 'esh-opt) (require 'esh-mode)) @@ -477,30 +476,6 @@ Possible options are: (t (error "Invalid variable reference"))))) -(eshell-deftest var interp-cmd - "Interpolate command result" - (eshell-command-result-p "+ ${+ 1 2} 3" "6\n")) - -(eshell-deftest var interp-lisp - "Interpolate Lisp form evalution" - (eshell-command-result-p "+ $(+ 1 2) 3" "6\n")) - -(eshell-deftest var interp-concat - "Interpolate and concat command" - (eshell-command-result-p "+ ${+ 1 2}3 3" "36\n")) - -(eshell-deftest var interp-concat-lisp - "Interpolate and concat Lisp form" - (eshell-command-result-p "+ $(+ 1 2)3 3" "36\n")) - -(eshell-deftest var interp-concat2 - "Interpolate and concat two commands" - (eshell-command-result-p "+ ${+ 1 2}${+ 1 2} 3" "36\n")) - -(eshell-deftest var interp-concat-lisp2 - "Interpolate and concat two Lisp forms" - (eshell-command-result-p "+ $(+ 1 2)$(+ 1 2) 3" "36\n")) - (defun eshell-parse-indices () "Parse and return a list of list of indices." (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." :type 'string :group 'eshell) -(eshell-deftest mode same-window-buffer-names - "`eshell-buffer-name' is a member of `same-window-buffer-names'" - (member eshell-buffer-name same-window-buffer-names)) - (defcustom eshell-directory-name (locate-user-emacs-file "eshell/" ".eshell/") "The directory where Eshell control files should be kept." :type 'directory :group 'eshell) -(eshell-deftest mode eshell-directory-exists - "`eshell-directory-name' exists and is writable" - (file-writable-p eshell-directory-name)) - -(eshell-deftest mode eshell-directory-modes - "`eshell-directory-name' has correct access protections" - (or (eshell-under-windows-p) - (= (file-modes eshell-directory-name) - eshell-private-directory-modes))) - ;;;_* Running Eshell ;; ;; There are only three commands used to invoke Eshell. The first two @@ -450,10 +436,6 @@ corresponding to a successful execution." (set status-var eshell-last-command-status)) (cadr result)))))) -(eshell-deftest mode simple-command-result - "`eshell-command-result' works with a simple command." - (= (eshell-command-result "+ 1 2") 3)) - ;;;_* Reporting bugs ;; ;; If you do encounter a bug, on any system, please report diff --git a/test/ChangeLog b/test/ChangeLog index 8b7feaddf62..b247b88bc94 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2011-03-05 Glenn Morris <rgm@gnu.org> + + * eshell.el: Move here from lisp/eshell/esh-test.el. + 2011-03-03 Christian Ohler <ohler@gnu.org> * automated/ert-tests.el (ert-test-explain-not-equal-keymaps): diff --git a/lisp/eshell/esh-test.el b/test/eshell.el index 73ba16116c0..3b392e84c24 100644 --- a/lisp/eshell/esh-test.el +++ b/test/eshell.el @@ -28,6 +28,7 @@ ;;; Code: (eval-when-compile + (require 'cl) ; assert (require 'eshell) (require 'esh-util)) (require 'esh-mode) @@ -228,6 +229,193 @@ "\n")))) nil t)) + +;;; The tests. + +(defmacro eshell-deftest (module name label &rest forms) + (declare (indent 2)) + (if (and (fboundp 'cl-compiling-file) (cl-compiling-file)) + nil + (let ((fsym (intern (concat "eshell-test--" (symbol-name name))))) + `(eval-when-compile + (ignore + (defun ,fsym () ,label + (eshell-run-test (quote ,module) (quote ,fsym) ,label + (quote (progn ,@forms))))))))) + + +(eshell-deftest mode same-window-buffer-names + "`eshell-buffer-name' is a member of `same-window-buffer-names'" + (member eshell-buffer-name same-window-buffer-names)) + +(eshell-deftest mode eshell-directory-exists + "`eshell-directory-name' exists and is writable" + (file-writable-p eshell-directory-name)) + +(eshell-deftest mode eshell-directory-modes + "`eshell-directory-name' has correct access protections" + (or (eshell-under-windows-p) + (= (file-modes eshell-directory-name) + eshell-private-directory-modes))) + +(eshell-deftest mode simple-command-result + "`eshell-command-result' works with a simple command." + (= (eshell-command-result "+ 1 2") 3)) + + +(require 'em-banner) + +(eshell-deftest banner banner-displayed + "Startup banner is displayed at point-min" + (assert eshell-banner-message) + (let ((msg (eval eshell-banner-message))) + (assert msg) + (goto-char (point-min)) + (looking-at msg))) + + +(require 'esh-cmd) + +(eshell-deftest var last-result-var + "\"last result\" variable" + (eshell-command-result-p "+ 1 2; + $$ 2" "3\n5\n")) + +(eshell-deftest var last-result-var2 + "\"last result\" variable" + (eshell-command-result-p "+ 1 2; + $$ $$" "3\n6\n")) + +(eshell-deftest var last-arg-var + "\"last arg\" variable" + (eshell-command-result-p "+ 1 2; + $_ 4" "3\n6\n")) + +(eshell-deftest cmd lisp-command + "Evaluate Lisp command" + (eshell-command-result-p "(+ 1 2)" "3")) + +(eshell-deftest cmd lisp-command-args + "Evaluate Lisp command (ignore args)" + (eshell-command-result-p "(+ 1 2) 3" "3")) + +(eshell-deftest cmd subcommand + "Run subcommand" + (eshell-command-result-p "{+ 1 2}" "3\n")) + +(eshell-deftest cmd subcommand-args + "Run subcommand (ignore args)" + (eshell-command-result-p "{+ 1 2} 3" "3\n")) + +(eshell-deftest cmd subcommand-lisp + "Run subcommand + Lisp form" + (eshell-command-result-p "{(+ 1 2)}" "3\n")) + +(eshell-deftest cmd named-command + "Execute named command" + (eshell-command-result-p "+ 1 2" "3\n")) + + +(require 'esh-mode) + +(eshell-deftest mode major-mode + "Major mode is correct" + (eq major-mode 'eshell-mode)) + +(eshell-deftest mode eshell-mode-variable + "`eshell-mode' is true" + (eq eshell-mode t)) + +(eshell-deftest var window-height + "LINES equals window height" + (let ((eshell-stringify-t t)) + (eshell-command-result-p "= $LINES (window-height)" "t\n"))) + +(eshell-deftest mode command-running-p + "Modeline shows no command running" + (or (featurep 'xemacs) + (not eshell-status-in-modeline) + (and (memq 'eshell-command-running-string mode-line-format) + (equal eshell-command-running-string "--")))) + +(eshell-deftest arg forward-arg + "Move across command arguments" + (eshell-insert-command "echo $(+ 1 (- 4 3)) \"alpha beta\" file" 'ignore) + (let ((here (point)) begin valid) + (eshell-bol) + (setq begin (point)) + (eshell-forward-argument 4) + (setq valid (= here (point))) + (eshell-backward-argument 4) + (prog1 + (and valid (= begin (point))) + (eshell-bol) + (delete-region (point) (point-max))))) + +(eshell-deftest mode queue-input + "Queue command input" + (eshell-insert-command "sleep 2") + (eshell-insert-command "echo alpha" 'eshell-queue-input) + (let ((count 10)) + (while (and eshell-current-command + (> count 0)) + (sit-for 1 0) + (setq count (1- count)))) + (eshell-match-result "alpha\n")) + +; (eshell-deftest proc send-to-subprocess +; "Send input to a subprocess" +; ;; jww (1999-12-06): what about when bc is unavailable? +; (if (not (eshell-search-path "bc")) +; t +; (eshell-insert-command "bc") +; (eshell-insert-command "1 + 2") +; (sit-for 1 0) +; (forward-line -1) +; (prog1 +; (looking-at "3\n") +; (eshell-insert-command "quit") +; (sit-for 1 0)))) + +(eshell-deftest io flush-output + "Flush previous output" + (eshell-insert-command "echo alpha") + (eshell-kill-output) + (and (eshell-match-result (regexp-quote "*** output flushed ***\n")) + (forward-line) + (= (point) eshell-last-output-start))) + +(eshell-deftest mode run-old-command + "Re-run an old command" + (eshell-insert-command "echo alpha") + (goto-char eshell-last-input-start) + (string= (eshell-get-old-input) "echo alpha")) + + +(require 'esh-var) + +(eshell-deftest var interp-cmd + "Interpolate command result" + (eshell-command-result-p "+ ${+ 1 2} 3" "6\n")) + +(eshell-deftest var interp-lisp + "Interpolate Lisp form evalution" + (eshell-command-result-p "+ $(+ 1 2) 3" "6\n")) + +(eshell-deftest var interp-concat + "Interpolate and concat command" + (eshell-command-result-p "+ ${+ 1 2}3 3" "36\n")) + +(eshell-deftest var interp-concat-lisp + "Interpolate and concat Lisp form" + (eshell-command-result-p "+ $(+ 1 2)3 3" "36\n")) + +(eshell-deftest var interp-concat2 + "Interpolate and concat two commands" + (eshell-command-result-p "+ ${+ 1 2}${+ 1 2} 3" "36\n")) + +(eshell-deftest var interp-concat-lisp2 + "Interpolate and concat two Lisp forms" + (eshell-command-result-p "+ $(+ 1 2)$(+ 1 2) 3" "36\n")) + + (provide 'esh-test) ;;; esh-test.el ends here |