File tree Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,23 @@ test_gitcomp ()
105
105
test_cmp expected out
106
106
}
107
107
108
+ # Test __gitcomp_nl
109
+ # Arguments are:
110
+ # 1: current word (cur)
111
+ # -: the rest are passed to __gitcomp_nl
112
+ test_gitcomp_nl ()
113
+ {
114
+ local -a COMPREPLY &&
115
+ sed -e ' s/Z$//' > expected &&
116
+ cur=" $1 " &&
117
+ shift &&
118
+ __gitcomp_nl " $@ " &&
119
+ print_comp &&
120
+ test_cmp expected out
121
+ }
122
+
123
+ invalid_variable_name=' ${foo.bar}'
124
+
108
125
test_expect_success ' __gitcomp - trailing space - options' '
109
126
test_gitcomp "--re" "--dry-run --reuse-message= --reedit-message=
110
127
--reset-author" <<-EOF
@@ -148,6 +165,49 @@ test_expect_success '__gitcomp - suffix' '
148
165
EOF
149
166
'
150
167
168
+ test_expect_failure ' __gitcomp - doesnt fail because of invalid variable name' '
169
+ __gitcomp "$invalid_variable_name"
170
+ '
171
+
172
+ read -r -d " " refs << -\EOF
173
+ maint
174
+ master
175
+ next
176
+ pu
177
+ EOF
178
+
179
+ test_expect_success ' __gitcomp_nl - trailing space' '
180
+ test_gitcomp_nl "m" "$refs" <<-EOF
181
+ maint Z
182
+ master Z
183
+ EOF
184
+ '
185
+
186
+ test_expect_success ' __gitcomp_nl - prefix' '
187
+ test_gitcomp_nl "--fixup=m" "$refs" "--fixup=" "m" <<-EOF
188
+ --fixup=maint Z
189
+ --fixup=master Z
190
+ EOF
191
+ '
192
+
193
+ test_expect_success ' __gitcomp_nl - suffix' '
194
+ test_gitcomp_nl "branch.ma" "$refs" "branch." "ma" "." <<-\EOF
195
+ branch.maint.Z
196
+ branch.master.Z
197
+ EOF
198
+ '
199
+
200
+ test_expect_success ' __gitcomp_nl - no suffix' '
201
+ test_gitcomp_nl "ma" "$refs" "" "ma" "" <<-\EOF
202
+ maintZ
203
+ masterZ
204
+ EOF
205
+ '
206
+
207
+ test_expect_failure ' __gitcomp_nl - doesnt fail because of invalid variable name' '
208
+ __gitcomp_nl "$invalid_variable_name"
209
+ '
210
+
151
211
test_expect_success ' basic' '
152
212
run_completion "git " &&
153
213
# built-in
You can’t perform that action at this time.
0 commit comments