aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Porter2022-02-27 18:34:22 -0800
committerLars Ingebrigtsen2022-03-03 14:59:33 +0100
commit7c7a4c26cbabe2d84d008e193b7db8ae106e9e47 (patch)
treec1776c40ff6ce867137876f8b22bf3176cd53f69
parentca8f4ebc492c470ec041e11f5d5b005c6d0d44e6 (diff)
downloademacs-7c7a4c26cbabe2d84d008e193b7db8ae106e9e47.tar.gz
emacs-7c7a4c26cbabe2d84d008e193b7db8ae106e9e47.zip
Move Eshell variable interpolation tests to their own file
* test/lisp/eshell/eshell-tests.el (eshell-test/interp-cmd) (eshell-test/interp-lisp, eshell-test/interp-temp-cmd) (eshell-test/interp-concat, eshell-test/interp-concat-lisp) (eshell-test/interp-concat2, eshell-test/interp-concat-lisp2) (eshell-test/interp-cmd-external) (eshell-test/interp-cmd-external-concat, eshell-test/window-height) (eshell-test/window-width, eshell-test/last-result-var) (eshell-test/last-result-var2, eshell-test/last-arg-var): Move from here... * test/lisp/eshell/esh-var-test.el (esh-var-test/interp-lisp) (esh-var-test/interp-cmd, esh-var-test/interp-cmd-external) (esh-var-test/interp-temp-cmd, esh-var-test/interp-concat-lisp) (esh-var-test/interp-concat-lisp2, esh-var-test/interp-concat-cmd) (esh-var-test/interp-concat-cmd2) (esh-var-test/interp-concat-cmd-external, esh-var-test/window-height) (esh-var-test/window-width, esh-var-test/last-result-var) (esh-var-test/last-result-var2, esh-var-test/last-arg-var): ... to here.
-rw-r--r--test/lisp/eshell/esh-var-tests.el111
-rw-r--r--test/lisp/eshell/eshell-tests.el68
2 files changed, 111 insertions, 68 deletions
diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el
new file mode 100644
index 00000000000..8d803e5ca49
--- /dev/null
+++ b/test/lisp/eshell/esh-var-tests.el
@@ -0,0 +1,111 @@
1;;; esh-var-tests.el --- esh-var test suite -*- lexical-binding:t -*-
2
3;; Copyright (C) 2022 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19
20;;; Commentary:
21
22;; Tests for Eshell's variable handling.
23
24;;; Code:
25
26(require 'ert)
27(require 'esh-mode)
28(require 'eshell)
29
30(require 'eshell-tests-helpers
31 (expand-file-name "eshell-tests-helpers"
32 (file-name-directory (or load-file-name
33 default-directory))))
34
35;;; Tests:
36
37
38;; Variable interpolation
39
40(ert-deftest esh-var-test/interp-lisp ()
41 "Interpolate Lisp form evaluation"
42 (should (equal (eshell-test-command-result "+ $(+ 1 2) 3") 6)))
43
44(ert-deftest esh-var-test/interp-cmd ()
45 "Interpolate command result"
46 (should (equal (eshell-test-command-result "+ ${+ 1 2} 3") 6)))
47
48(ert-deftest esh-var-test/interp-cmd-external ()
49 "Interpolate command result from external command"
50 (skip-unless (executable-find "echo"))
51 (with-temp-eshell
52 (eshell-command-result-p "echo ${*echo hi}"
53 "hi\n")))
54
55(ert-deftest esh-var-test/interp-temp-cmd ()
56 "Interpolate command result redirected to temp file"
57 (should (equal (eshell-test-command-result "cat $<echo hi>") "hi")))
58
59(ert-deftest esh-var-test/interp-concat-lisp ()
60 "Interpolate and concat Lisp form"
61 (should (equal (eshell-test-command-result "+ $(+ 1 2)3 3") 36)))
62
63(ert-deftest esh-var-test/interp-concat-lisp2 ()
64 "Interpolate and concat two Lisp forms"
65 (should (equal (eshell-test-command-result "+ $(+ 1 2)$(+ 1 2) 3") 36)))
66
67(ert-deftest esh-var-test/interp-concat-cmd ()
68 "Interpolate and concat command"
69 (should (equal (eshell-test-command-result "+ ${+ 1 2}3 3") 36)))
70
71(ert-deftest esh-var-test/interp-concat-cmd2 ()
72 "Interpolate and concat two commands"
73 (should (equal (eshell-test-command-result "+ ${+ 1 2}${+ 1 2} 3") 36)))
74
75(ert-deftest esh-var-test/interp-concat-cmd-external ()
76 "Interpolate command result from external command with concatenation"
77 (skip-unless (executable-find "echo"))
78 (with-temp-eshell
79 (eshell-command-result-p "echo ${echo hi}-${*echo there}"
80 "hi-there\n")))
81
82
83;; Built-in variables
84
85(ert-deftest esh-var-test/window-height ()
86 "$LINES should equal (window-height)"
87 (should (eshell-test-command-result "= $LINES (window-height)")))
88
89(ert-deftest esh-var-test/window-width ()
90 "$COLUMNS should equal (window-width)"
91 (should (eshell-test-command-result "= $COLUMNS (window-width)")))
92
93(ert-deftest esh-var-test/last-result-var ()
94 "Test using the \"last result\" ($$) variable"
95 (with-temp-eshell
96 (eshell-command-result-p "+ 1 2; + $$ 2"
97 "3\n5\n")))
98
99(ert-deftest esh-var-test/last-result-var2 ()
100 "Test using the \"last result\" ($$) variable twice"
101 (with-temp-eshell
102 (eshell-command-result-p "+ 1 2; + $$ $$"
103 "3\n6\n")))
104
105(ert-deftest esh-var-test/last-arg-var ()
106 "Test using the \"last arg\" ($_) variable"
107 (with-temp-eshell
108 (eshell-command-result-p "+ 1 2; + $_ 4"
109 "3\n6\n")))
110
111;; esh-var-tests.el ends here
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el
index eff4edd62c7..e31db07c619 100644
--- a/test/lisp/eshell/eshell-tests.el
+++ b/test/lisp/eshell/eshell-tests.el
@@ -85,48 +85,6 @@ Test that trailing arguments outside the subcommand are ignored.
85e.g. \"{(+ 1 2)} 3\" => 3" 85e.g. \"{(+ 1 2)} 3\" => 3"
86 (should (equal (eshell-test-command-result "{(+ 1 2)} 3") 3))) 86 (should (equal (eshell-test-command-result "{(+ 1 2)} 3") 3)))
87 87
88(ert-deftest eshell-test/interp-cmd ()
89 "Interpolate command result"
90 (should (equal (eshell-test-command-result "+ ${+ 1 2} 3") 6)))
91
92(ert-deftest eshell-test/interp-lisp ()
93 "Interpolate Lisp form evaluation"
94 (should (equal (eshell-test-command-result "+ $(+ 1 2) 3") 6)))
95
96(ert-deftest eshell-test/interp-temp-cmd ()
97 "Interpolate command result redirected to temp file"
98 (should (equal (eshell-test-command-result "cat $<echo hi>") "hi")))
99
100(ert-deftest eshell-test/interp-concat ()
101 "Interpolate and concat command"
102 (should (equal (eshell-test-command-result "+ ${+ 1 2}3 3") 36)))
103
104(ert-deftest eshell-test/interp-concat-lisp ()
105 "Interpolate and concat Lisp form"
106 (should (equal (eshell-test-command-result "+ $(+ 1 2)3 3") 36)))
107
108(ert-deftest eshell-test/interp-concat2 ()
109 "Interpolate and concat two commands"
110 (should (equal (eshell-test-command-result "+ ${+ 1 2}${+ 1 2} 3") 36)))
111
112(ert-deftest eshell-test/interp-concat-lisp2 ()
113 "Interpolate and concat two Lisp forms"
114 (should (equal (eshell-test-command-result "+ $(+ 1 2)$(+ 1 2) 3") 36)))
115
116(ert-deftest eshell-test/interp-cmd-external ()
117 "Interpolate command result from external command"
118 (skip-unless (executable-find "echo"))
119 (with-temp-eshell
120 (eshell-command-result-p "echo ${*echo hi}"
121 "hi\n")))
122
123(ert-deftest eshell-test/interp-cmd-external-concat ()
124 "Interpolate command result from external command with concatenation"
125 (skip-unless (executable-find "echo"))
126 (with-temp-eshell
127 (eshell-command-result-p "echo ${echo hi}-${*echo there}"
128 "hi-there\n")))
129
130(ert-deftest eshell-test/pipe-headproc () 88(ert-deftest eshell-test/pipe-headproc ()
131 "Check that piping a non-process to a process command waits for the process" 89 "Check that piping a non-process to a process command waits for the process"
132 (skip-unless (executable-find "cat")) 90 (skip-unless (executable-find "cat"))
@@ -152,32 +110,6 @@ e.g. \"{(+ 1 2)} 3\" => 3"
152 (eshell-wait-for-subprocess) 110 (eshell-wait-for-subprocess)
153 (eshell-match-result "OLLEH\n"))) 111 (eshell-match-result "OLLEH\n")))
154 112
155(ert-deftest eshell-test/window-height ()
156 "$LINES should equal (window-height)"
157 (should (eshell-test-command-result "= $LINES (window-height)")))
158
159(ert-deftest eshell-test/window-width ()
160 "$COLUMNS should equal (window-width)"
161 (should (eshell-test-command-result "= $COLUMNS (window-width)")))
162
163(ert-deftest eshell-test/last-result-var ()
164 "Test using the \"last result\" ($$) variable"
165 (with-temp-eshell
166 (eshell-command-result-p "+ 1 2; + $$ 2"
167 "3\n5\n")))
168
169(ert-deftest eshell-test/last-result-var2 ()
170 "Test using the \"last result\" ($$) variable twice"
171 (with-temp-eshell
172 (eshell-command-result-p "+ 1 2; + $$ $$"
173 "3\n6\n")))
174
175(ert-deftest eshell-test/last-arg-var ()
176 "Test using the \"last arg\" ($_) variable"
177 (with-temp-eshell
178 (eshell-command-result-p "+ 1 2; + $_ 4"
179 "3\n6\n")))
180
181(ert-deftest eshell-test/inside-emacs-var () 113(ert-deftest eshell-test/inside-emacs-var ()
182 "Test presence of \"INSIDE_EMACS\" in subprocesses" 114 "Test presence of \"INSIDE_EMACS\" in subprocesses"
183 (with-temp-eshell 115 (with-temp-eshell