YAML · 10044 bytes Raw Blame History
1 # History Tests
2 # Phase 3: History navigation, search, and expansion
3
4 metadata:
5 category: "History"
6 description: "Tests for command history navigation, search, and expansion"
7 phase: 3
8
9 tests:
10 # =============================================================
11 # HISTORY NAVIGATION - Arrow Keys
12 # =============================================================
13 - name: "Up arrow recalls previous command"
14 steps:
15 - send_line: "echo first"
16 - send_key: "Up"
17 - send_key: "Enter"
18 expect_output: "first"
19 match_type: "contains"
20
21 - name: "Multiple up arrows navigate history"
22 steps:
23 - send_line: "echo one"
24 - send_line: "echo two"
25 - send_line: "echo three"
26 - send_key: "Up"
27 - send_key: "Up"
28 - send_key: "Enter"
29 expect_output: "two"
30 match_type: "contains"
31
32 - name: "Down arrow navigates forward in history"
33 steps:
34 - send_line: "echo first"
35 - send_line: "echo second"
36 - send_key: "Up"
37 - send_key: "Up"
38 - send_key: "Down"
39 - send_key: "Enter"
40 expect_output: "second"
41 match_type: "contains"
42
43 - name: "Down arrow at end returns to empty line"
44 steps:
45 - send_line: "echo test"
46 - send_key: "Up"
47 - send_key: "Down"
48 - send: "echo new"
49 - send_key: "Enter"
50 expect_output: "new"
51 match_type: "contains"
52
53 - name: "Up arrow at beginning of history stops"
54 steps:
55 - send_line: "echo only"
56 - send_key: "Up"
57 - send_key: "Up"
58 - send_key: "Up"
59 - send_key: "Enter"
60 expect_output: "only"
61 match_type: "contains"
62
63 # =============================================================
64 # HISTORY NAVIGATION - Ctrl Keys
65 # =============================================================
66 - name: "Ctrl+P recalls previous command"
67 steps:
68 - send_line: "echo previous"
69 - send_key: "C-p"
70 - send_key: "Enter"
71 expect_output: "previous"
72 match_type: "contains"
73
74 - name: "Ctrl+N navigates forward in history"
75 steps:
76 - send_line: "echo one"
77 - send_line: "echo two"
78 - send_key: "C-p"
79 - send_key: "C-p"
80 - send_key: "C-n"
81 - send_key: "Enter"
82 expect_output: "two"
83 match_type: "contains"
84
85 - name: "Mixed Ctrl+P and Up arrow"
86 steps:
87 - send_line: "echo first"
88 - send_line: "echo second"
89 - send_key: "Up"
90 - send_key: "C-p"
91 - send_key: "Enter"
92 expect_output: "first"
93 match_type: "contains"
94
95 # =============================================================
96 # HISTORY EDITING
97 # =============================================================
98 - name: "Edit recalled command before executing"
99 steps:
100 - send_line: "echo original"
101 - send_key: "Up"
102 - send_key: "C-a"
103 - send_key: "M-f"
104 - send_key: "C-k"
105 - send: " modified"
106 - send_key: "Enter"
107 expect_output: "modified"
108 match_type: "contains"
109
110 - name: "Cancel history navigation with Ctrl+G"
111 steps:
112 - send_line: "echo first"
113 - send_key: "Up"
114 - send_key: "C-g"
115 - send: "echo second"
116 - send_key: "Enter"
117 expect_output: "second"
118 match_type: "contains"
119
120 # =============================================================
121 # HISTORY SEARCH - Ctrl+R
122 # =============================================================
123 - name: "Ctrl+R starts reverse search"
124 steps:
125 - send_line: "echo findme"
126 - send_line: "echo other"
127 - send_key: "C-r"
128 - send: "find"
129 - send_key: "Enter"
130 expect_output: "findme"
131 match_type: "contains"
132
133 - name: "Ctrl+R finds partial match"
134 steps:
135 - send_line: "echo hello world"
136 - send_line: "echo goodbye"
137 - send_key: "C-r"
138 - send: "hello"
139 - send_key: "Enter"
140 expect_output: "hello world"
141 match_type: "contains"
142
143 - name: "Ctrl+R multiple matches cycles backwards"
144 steps:
145 - send_line: "echo match1"
146 - send_line: "echo match2"
147 - send_line: "echo match3"
148 - send_key: "C-r"
149 - send: "match"
150 - send_key: "C-r"
151 - send_key: "Enter"
152 expect_output: "match2"
153 match_type: "contains"
154
155 - name: "Ctrl+G cancels search"
156 steps:
157 - send_line: "echo searchme"
158 - send_key: "C-r"
159 - send: "search"
160 - send_key: "C-g"
161 - send: "echo cancelled"
162 - send_key: "Enter"
163 expect_output: "cancelled"
164 match_type: "contains"
165
166 - name: "Enter executes found command"
167 steps:
168 - send_line: "echo execute"
169 - send_key: "C-r"
170 - send: "exec"
171 - send_key: "Enter"
172 expect_output: "execute"
173 match_type: "contains"
174
175 - name: "Right arrow exits search and edits"
176 steps:
177 - send_line: "echo editme"
178 - send_key: "C-r"
179 - send: "edit"
180 - send_key: "Right"
181 - send_key: "C-e"
182 - send: " added"
183 - send_key: "Enter"
184 expect_output: "editme added"
185 match_type: "contains"
186
187 # =============================================================
188 # HISTORY EXPANSION - Basic
189 # =============================================================
190 - name: "!! repeats last command"
191 steps:
192 - send_line: "echo repeat"
193 - send_line: "!!"
194 expect_output: "repeat"
195 match_type: "contains"
196
197 - name: "!-1 repeats last command"
198 steps:
199 - send_line: "echo minusone"
200 - send_line: "!-1"
201 expect_output: "minusone"
202 match_type: "contains"
203
204 - name: "!-2 repeats second to last"
205 steps:
206 - send_line: "echo first"
207 - send_line: "echo second"
208 - send_line: "!-2"
209 expect_output: "first"
210 match_type: "contains"
211
212 - name: "!string finds command starting with string"
213 steps:
214 - send_line: "echo hello"
215 - send_line: "pwd"
216 - send_line: "!echo"
217 expect_output: "hello"
218 match_type: "contains"
219
220 - name: "!?string finds command containing string"
221 steps:
222 - send_line: "echo findthis"
223 - send_line: "pwd"
224 - send_line: "!?find"
225 expect_output: "findthis"
226 match_type: "contains"
227
228 # =============================================================
229 # HISTORY EXPANSION - Substitution
230 # =============================================================
231 - name: "^old^new substitution"
232 steps:
233 - send_line: "echo old"
234 - send_line: "^old^new"
235 expect_output: "new"
236 match_type: "contains"
237
238 # DISABLED: History word modifiers (:s/old/new/) not yet implemented
239 # - name: "!!:s/old/new/ substitution"
240 # steps:
241 # - send_line: "echo oldvalue"
242 # - send_line: "!!:s/old/new/"
243 # expect_output: "newvalue"
244 # match_type: "contains"
245
246 # =============================================================
247 # HISTORY EXPANSION - Word Designators
248 # =============================================================
249 - name: "!!:0 gets command name"
250 steps:
251 - send_line: "echo one two three"
252 - send_line: "!!:0"
253 expect_output: "echo"
254 match_type: "contains"
255
256 - name: "!!:1 gets first argument"
257 steps:
258 - send_line: "echo first second third"
259 - send_line: "echo !!:1"
260 expect_output: "first"
261 match_type: "contains"
262
263 - name: "!!:$ gets last argument"
264 steps:
265 - send_line: "echo one two last"
266 - send_line: "echo !!:$"
267 expect_output: "last"
268 match_type: "contains"
269
270 - name: "!!:* gets all arguments"
271 steps:
272 - send_line: "echo a b c"
273 - send_line: "printf '%s\\n' !!:*"
274 expect_output: "a"
275 match_type: "contains"
276
277 - name: "!$ gets last argument of previous command"
278 steps:
279 - send_line: "echo one two three"
280 - send_line: "echo !$"
281 expect_output: "three"
282 match_type: "contains"
283
284 - name: "Alt+. inserts last argument"
285 steps:
286 - send_line: "echo lastarg"
287 - send: "echo "
288 - send_key: "M-."
289 - send_key: "Enter"
290 expect_output: "lastarg"
291 match_type: "contains"
292
293 # =============================================================
294 # HISTORY - Duplicates and Ignoring
295 # =============================================================
296 - name: "Duplicate commands in history"
297 steps:
298 - send_line: "echo dup"
299 - send_line: "echo dup"
300 - send_key: "Up"
301 - send_key: "Up"
302 - send_key: "Enter"
303 expect_output: "dup"
304 match_type: "contains"
305
306 - name: "Commands with leading space may be ignored"
307 steps:
308 - send_line: " echo secret"
309 - send_key: "Up"
310 - send_key: "Enter"
311 expect_output: "secret"
312 match_type: "contains"
313
314 # =============================================================
315 # HISTORY - Edge Cases
316 # =============================================================
317 - name: "Empty history navigation"
318 steps:
319 - send_key: "Up"
320 - send: "echo empty"
321 - send_key: "Enter"
322 expect_output: "empty"
323 match_type: "contains"
324
325 - name: "History with special characters"
326 steps:
327 - send_line: "echo 'special chars: $HOME'"
328 - send_key: "Up"
329 - send_key: "Enter"
330 expect_output: "special chars:"
331 match_type: "contains"
332
333 - name: "History with pipes"
334 steps:
335 - send_line: "echo hello | cat"
336 - send_key: "Up"
337 - send_key: "Enter"
338 expect_output: "hello"
339 match_type: "contains"
340
341 - name: "History with redirects"
342 steps:
343 - send_line: "echo test > /dev/null"
344 - send_key: "Up"
345 - send_key: "Enter"
346 expect_output: ""
347 match_type: "contains"
348
349 - name: "Long command in history"
350 steps:
351 - send_line: "echo aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
352 - send_key: "Up"
353 - send_key: "Enter"
354 expect_output: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
355 match_type: "contains"
356
357 # =============================================================
358 # HISTORY - Multiline
359 # =============================================================
360 - name: "History preserves multiline commands"
361 steps:
362 - send_line: "for i in 1 2; do echo $i; done"
363 - send_key: "Up"
364 - send_key: "Enter"
365 expect_output: "1"
366 match_type: "contains"
367