fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

NahorAdd tests to exercise all builtin error messages99d63c21f

master
7.1 KiB212 linesraw
1#RUN: %fish %s
2
3set -g fish (status fish-path)
4
5commandline --input "echo foo | bar" --is-valid
6and echo Valid
7# CHECK: Valid
8
9commandline --input "echo foo | " --is-valid
10or echo Invalid $status
11# CHECK: Invalid 2
12
13# TODO: This seems a bit awkward?
14# The empty commandline is an error, not incomplete?
15commandline --input '' --is-valid
16or echo Invalid $status
17# CHECK: Invalid 1
18
19commandline --input 'echo $$' --is-valid
20or echo Invalid $status
21# CHECK: Invalid 1
22
23commandline --help &>/dev/null
24echo Help $status
25# CHECK: Help 0
26
27commandline -pC 0 --input "test | test"
28echo $status
29# CHECK: 0
30
31commandline --insert-smart '$ echo 123' --current-token
32# CHECKERR: commandline: --insert-smart --current-token: options cannot be used together
33# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
34# CHECKERR: commandline --insert-smart '$ echo 123' --current-token
35# CHECKERR: ^
36# CHECKERR: (Type 'help commandline' for related documentation)
37
38commandline --input "echo {arg1,arg2} <in >out" --tokens-expanded
39# CHECK: echo
40# CHECK: arg1
41# CHECK: arg2
42
43commandline --input "echo <" --tokens-expanded
44# CHECK: echo
45commandline --input "echo >" --tokens-expanded
46# CHECK: echo
47commandline --input "echo > > arg" --tokens-expanded
48# CHECK: echo
49commandline --input "echo > {a,b}" --tokens-expanded
50# CHECK: echo
51
52commandline --input "echo {arg1,arg2} <in >out" --tokens-raw
53# CHECK: echo
54# CHECK: {arg1,arg2}
55
56$fish -ic '
57    commandline hello
58    commandline
59    commandline -i world
60    commandline
61    commandline --cursor 5
62    commandline -i " "
63    commandline
64'
65# CHECK: hello
66# CHECK: helloworld
67# CHECK: hello world
68
69$fish -c 'commandline foo'
70# CHECKERR: commandline: Can not set commandline in non-interactive mode
71# CHECKERR: Standard input (line 1):
72# CHECKERR: commandline foo
73# CHECKERR: ^
74# CHECKERR: (Type 'help commandline' for related documentation)
75
76commandline --tokens-expanded --tokens-raw
77# CHECKERR: commandline: invalid option combination, --tokens options are mutually exclusive
78# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
79# CHECKERR: commandline --tokens-expanded --tokens-raw
80# CHECKERR: ^
81# CHECKERR: (Type 'help commandline' for related documentation)
82
83commandline --tokens-expanded --tokenize
84# CHECKERR: commandline: invalid option combination, --tokens options are mutually exclusive
85# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
86# CHECKERR: commandline --tokens-expanded --tokenize
87# CHECKERR: ^
88# CHECKERR: (Type 'help commandline' for related documentation)
89
90commandline --function --current-buffer
91# CHECKERR: commandline: invalid option combination
92# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
93# CHECKERR: commandline --function --current-buffer
94# CHECKERR: ^
95# CHECKERR: (Type 'help commandline' for related documentation)
96
97commandline --function foo
98# CHECKERR: commandline: Unknown input function 'foo'
99# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
100# CHECKERR: commandline --function foo
101# CHECKERR: ^
102# CHECKERR: (Type 'help commandline' for related documentation)
103
104commandline --selection-start foo
105# CHECKERR: commandline: too many arguments
106# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
107# CHECKERR: commandline --selection-start foo
108# CHECKERR: ^
109# CHECKERR: (Type 'help commandline' for related documentation)
110commandline --selection-end foo
111# CHECKERR: commandline: too many arguments
112# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
113# CHECKERR: commandline --selection-end foo
114# CHECKERR: ^
115# CHECKERR: (Type 'help commandline' for related documentation)
116
117commandline --line 1 2
118# CHECKERR: commandline: too many arguments
119# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
120# CHECKERR: commandline --line 1 2
121# CHECKERR: ^
122# CHECKERR: (Type 'help commandline' for related documentation)
123
124commandline --cut-at-cursor --cursor
125# CHECKERR: commandline: invalid option combination
126# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
127# CHECKERR: commandline --cut-at-cursor --cursor
128# CHECKERR: ^
129# CHECKERR: (Type 'help commandline' for related documentation)
130
131commandline --cut-at-cursor --tokens-expanded abc
132# CHECKERR: commandline: invalid option combination, --cut-at-cursor and token options can not be used when setting the commandline
133# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
134# CHECKERR: commandline --cut-at-cursor --tokens-expanded abc
135# CHECKERR: ^
136# CHECKERR: (Type 'help commandline' for related documentation)
137
138commandline --search-field --tokens-expanded
139# CHECKERR: commandline: invalid option combination
140# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
141# CHECKERR: commandline --search-field --tokens-expanded
142# CHECKERR: ^
143# CHECKERR: (Type 'help commandline' for related documentation)
144
145commandline --insert-smart 0 --search-field
146# CHECKERR: commandline: --insert-smart --search-field: options cannot be used together
147# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
148# CHECKERR: commandline --insert-smart 0 --search-field
149# CHECKERR: ^
150# CHECKERR: (Type 'help commandline' for related documentation)
151
152commandline --insert-smart 0 --current-token
153# CHECKERR: commandline: --insert-smart --current-token: options cannot be used together
154# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
155# CHECKERR: commandline --insert-smart 0 --current-token
156# CHECKERR: ^
157# CHECKERR: (Type 'help commandline' for related documentation)
158
159commandline --line abc
160# CHECKERR: commandline: abc: invalid integer
161# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
162# CHECKERR: commandline --line abc
163# CHECKERR: ^
164# CHECKERR: (Type 'help commandline' for related documentation)
165commandline --line 0
166# CHECKERR: commandline: line/column index starts at 1
167# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
168# CHECKERR: commandline --line 0
169# CHECKERR: ^
170# CHECKERR: (Type 'help commandline' for related documentation)
171commandline --line 1
172# OK
173commandline --line 2
174# CHECKERR: commandline: there is no line 2
175# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
176# CHECKERR: commandline --line 2
177# CHECKERR: ^
178# CHECKERR: (Type 'help commandline' for related documentation)
179commandline --line 3
180# CHECKERR: commandline: there is no line 3
181# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
182# CHECKERR: commandline --line 3
183# CHECKERR: ^
184# CHECKERR: (Type 'help commandline' for related documentation)
185
186commandline --column abc
187# CHECKERR: commandline: abc: invalid integer
188# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
189# CHECKERR: commandline --column abc
190# CHECKERR: ^
191# CHECKERR: (Type 'help commandline' for related documentation)
192commandline --column 0
193# CHECKERR: commandline: line/column index starts at 1
194# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
195# CHECKERR: commandline --column 0
196# CHECKERR: ^
197# CHECKERR: (Type 'help commandline' for related documentation)
198commandline --column 1
199# OK
200commandline --column 2
201# CHECKERR: commandline: column 2 exceeds line length
202# CHECKERR: {{.*}}/commandline.fish (line {{\d+}}):
203# CHECKERR: commandline --column 2
204# CHECKERR: ^
205# CHECKERR: (Type 'help commandline' for related documentation)
206
207$fish -ic "commandline --cursor abc"
208# CHECKERR: commandline: abc: invalid integer
209# CHECKERR: Standard input (line 1):
210# CHECKERR: commandline --cursor abc
211# CHECKERR: ^
212# CHECKERR: (Type 'help commandline' for related documentation)