Commit 81fb60b2 authored by Glenn Morris's avatar Glenn Morris
Browse files

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.
parent c5f09daf
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
......
......@@ -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:
......
......@@ -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)
......
......@@ -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))
......
......@@ -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.
......
......@@ -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)
......
......@@ -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
......
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):
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment