2
2
3
3
load ' util/init.sh'
4
4
5
- @test " does not fail if there are no binaries " {
5
+ @test " does not fail if there are no completions " {
6
6
local pkg=' username/package'
7
7
8
8
test_util.setup_pkg " $pkg " ; {
@@ -15,6 +15,9 @@ load 'util/init.sh'
15
15
assert_success
16
16
}
17
17
18
+
19
+ # # BASH ##
20
+
18
21
@test " adds bash completions determined from package.sh" {
19
22
local pkg=' username/package'
20
23
@@ -75,7 +78,7 @@ load 'util/init.sh'
75
78
! [ -f " $BPM_INSTALL_COMPLETIONS /bash/prof.bash" ]
76
79
}
77
80
78
- @test " adds bash completions determined with heuristics ./?(contrib/)completion?(s)" {
81
+ @test " adds bash completions determined with heuristics ( ./?(contrib/)completion?(s) )" {
79
82
local pkg=" username/package$i "
80
83
81
84
test_util.setup_pkg " $pkg " ; {
@@ -99,116 +102,180 @@ load 'util/init.sh'
99
102
@test " adds bash completions determined from heuristics when when ZSH_COMPLETIONS is specified in package.sh" {
100
103
local pkg=" username/package"
101
104
102
- test_util.setup_pkg " $pkg " ; {'
103
- echo " ZSH_COMPLETIONS="' > ' package.sh'
105
+ test_util.setup_pkg " $pkg " ; {
106
+ echo ' ZSH_COMPLETIONS=" "' > ' package.sh'
104
107
mkdir ' completion'
105
108
touch " completion/prog.bash"
106
109
}; test_util.finish_pkg
107
110
test_util.fake_install " $pkg "
108
111
109
- run do-plumbing-link-completions " $package "
112
+ run do-plumbing-link-completions " $pkg "
110
113
111
114
[ -f " $BPM_INSTALL_COMPLETIONS /bash/prog.bash" ]
112
115
}
113
116
114
- @test " links zsh compsys completions to prefix/completions " {
115
- local package =" username/package"
117
+ @test " do not add bash completions from heuristics when BASH_COMPLETIONS is specified in package.sh " {
118
+ local pkg =" username/package"
116
119
117
- create_package username/package
118
- create_zsh_compsys_completions username/package _exec
119
- test_util.fake_clone " $package "
120
+ test_util.setup_pkg " $pkg " ; {
121
+ echo ' BASH_COMPLETIONS=""' > ' package.sh'
122
+ mkdir ' completion'
123
+ touch " completion/prog.bash"
124
+ }; test_util.finish_pkg
125
+ test_util.fake_install " $pkg "
120
126
121
- run do-plumbing-link-completions username/package
127
+ run do-plumbing-link-completions " $pkg "
122
128
123
- assert_success
124
- assert [ " $( readlink $BPM_INSTALL_COMPLETIONS /zsh/compsys/_exec) " = " $BPM_PACKAGES_PATH /username/package/completions/_exec" ]
129
+ [ ! -f " $BPM_INSTALL_COMPLETIONS /bash/prog.bash" ]
125
130
}
126
131
127
- @test " links zsh compctl completions to prefix/completions " {
128
- local package =" username/package"
132
+ @test " do not add bash completions from heuristics when completionDirs is specified in bpm.toml " {
133
+ local pkg =" username/package"
129
134
130
- create_package username/package
131
- create_zsh_compctl_completions username/package exec
132
- test_util.fake_clone " $package "
135
+ test_util.setup_pkg " $pkg " ; {
136
+ echo ' completionDirs = [ "dirr" ]' > ' bpm.toml'
137
+ mkdir ' completion'
138
+ touch " completion/prog.bash"
139
+ }; test_util.finish_pkg
140
+ test_util.fake_install " $pkg "
133
141
134
- run do-plumbing-link-completions username/package
142
+ run do-plumbing-link-completions " $pkg "
135
143
136
- assert_success
137
- assert [ " $( readlink $BPM_INSTALL_COMPLETIONS /zsh/compctl/exec ) " = " $BPM_PACKAGES_PATH /username/package/completions/exec " ]
144
+ assert [ ! -f " $BPM_INSTALL_COMPLETIONS /bash/prog.bash " ]
145
+ assert [ ! -f " $BPM_INSTALL_COMPLETIONS /bash/prog.bash " ]
138
146
}
139
147
140
- @test " links zsh completions from ./?(contrib/)completion?(s)" {
141
- local -i i=1
142
- for completion_dir in completion completions contrib/completion contrib/completions; do
143
- local package=" username/package$i "
148
+ # # ZSH ##
144
149
145
- create_package " $package "
146
- cd " $BPM_ORIGIN_DIR /$package "
147
- mkdir -p " $completion_dir "
148
- touch " $completion_dir /c.zsh"
149
- echo " #compdef" > | " $completion_dir /c2.zsh"
150
- git add .
151
- git commit -m " Add completions"
152
- cd " $BPM_CWD "
153
- test_util.fake_clone " $package "
150
+ @test " adds zsh compsys completions determined from package.sh" {
151
+ local pkg=" username/package"
154
152
155
- run do-plumbing-link-completions " $package "
153
+ test_util.setup_pkg " $pkg " ; {
154
+ echo ' ZSH_COMPLETIONS="dirr/_exec"' > ' package.sh'
155
+ mkdir ' dirr'
156
+ echo ' #compdef' > " dirr/_exec"
157
+ }; test_util.finish_pkg
158
+ test_util.fake_install " $pkg "
156
159
157
- assert_success
158
- assert [ " $( readlink " $BPM_INSTALL_COMPLETIONS /zsh/compsys/c2.zsh" ) " = " $BPM_PACKAGES_PATH /$package /$completion_dir /c2.zsh" ]
159
- assert [ " $( readlink " $BPM_INSTALL_COMPLETIONS /zsh/compctl/c.zsh" ) " = " $BPM_PACKAGES_PATH /$package /$completion_dir /c.zsh" ]
160
+ run do-plumbing-link-completions " $pkg "
160
161
161
- (( ++ i ))
162
- done
162
+ assert_success
163
+ assert [ " $( readlink " $BPM_INSTALL_COMPLETIONS /zsh/compsys/_exec " ) " = " $BPM_PACKAGES_PATH / $pkg /dirr/_exec " ]
163
164
}
164
165
165
- @test " don't link bash from './?(contrib/)completion?(s)' when ZSH_COMPLETIONS is specified in package.sh" {
166
- local package=" username/package"
166
+ @test " adds zsh compctl completions determined from pacakge.sh" {
167
+ local pkg=" username/package"
168
+
169
+ test_util.setup_pkg " $pkg " ; {
170
+ echo ' ZSH_COMPLETIONS="dirr/exec"' > ' package.sh'
171
+ mkdir ' dirr'
172
+ touch " dirr/exec"
173
+ }; test_util.finish_pkg
174
+ test_util.fake_install " $pkg "
167
175
168
- create_package " $package "
169
- cd " $BPM_ORIGIN_DIR /$package "
170
- mkdir completions
171
- touch completions/prog.zsh
172
- echo " ZSH_COMPLETIONS=" > | package.sh
173
- git add .
174
- git commit -m ' Add package.sh'
175
- cd " $BPM_CWD "
176
- test_util.fake_clone " $package "
176
+ run do-plumbing-link-completions " $pkg "
177
+
178
+ assert_success
179
+ assert [ " $( readlink " $BPM_INSTALL_COMPLETIONS /zsh/compctl/exec" ) " = " $BPM_PACKAGES_PATH /$pkg /dirr/exec" ]
180
+ }
181
+
182
+ @test " adds zsh compsys completions determined from bpm.toml" {
183
+ local pkg=" username/package"
184
+
185
+ test_util.setup_pkg " $pkg " ; {
186
+ echo ' completionDirs = [ "dirr" ]' > ' bpm.toml'
187
+ mkdir ' dirr'
188
+ echo ' #compdef' > " dirr/_exec.zsh"
189
+ }; test_util.finish_pkg
190
+ test_util.fake_install " $pkg "
177
191
178
- run do-plumbing-link-completions " $package "
192
+ run do-plumbing-link-completions " $pkg "
179
193
180
194
assert_success
181
- ! [ -f " $BPM_INSTALL_COMPLETIONS /zsh/compctl/prof.zsh" ]
182
- ! [ -f " $BPM_INSTALL_COMPLETIONS /zsh/compsys/prof.zsh" ]
195
+ assert [ " $( readlink " $BPM_INSTALL_COMPLETIONS /zsh/compsys/_exec.zsh" ) " = " $BPM_PACKAGES_PATH /$pkg /dirr/_exec.zsh" ]
183
196
}
184
197
185
- @test " do link zsh from './?(contrib/)completion?(s)' when BASH_COMPLETIONS is specified in package.sh " {
186
- local package =" username/package"
198
+ @test " adds zsh compctl completions determined from bpm.toml " {
199
+ local pkg =" username/package"
187
200
188
- create_package " $package "
189
- cd " $BPM_ORIGIN_DIR /$package "
190
- mkdir completions
191
- touch completions/prog.zsh
192
- echo " BASH_COMPLETIONS=" > | package.sh
193
- git add .
194
- git commit -m ' Add package.sh'
195
- cd " $BPM_CWD "
196
- test_util.fake_clone " $package "
201
+ test_util.setup_pkg " $pkg " ; {
202
+ echo ' completionDirs = [ "dirr" ]' > ' bpm.toml'
203
+ mkdir ' dirr'
204
+ touch " dirr/exec.zsh"
205
+ }; test_util.finish_pkg
206
+ test_util.fake_install " $pkg "
197
207
198
- run do-plumbing-link-completions " $package "
208
+ run do-plumbing-link-completions " $pkg "
199
209
200
210
assert_success
201
- [ -f " $BPM_INSTALL_COMPLETIONS /zsh/compctl/prog .zsh" ]
211
+ assert [ " $( readlink " $BPM_INSTALL_COMPLETIONS /zsh/compctl/exec.zsh " ) " = " $BPM_PACKAGES_PATH / $pkg /dirr/exec .zsh" ]
202
212
}
203
213
214
+ @test " adds zsh completions determined with heuristics (./?(contrib/)completion?(s))" {
215
+ local pkg=" username/package"
216
+
217
+ test_util.setup_pkg " $pkg " ; {
218
+ mkdir -p ./{contrib/,}completion{,s}
219
+ touch " completion/c1.zsh"
220
+ echo ' #compdef' > " completions/c2.zsh"
221
+ touch " contrib/completion/c3.zsh"
222
+ echo ' #compdef' > " contrib/completions/c4.zsh"
223
+ }; test_util.finish_pkg
224
+ test_util.fake_install " $pkg "
225
+
226
+ assert_success
227
+ assert [ " $( readlink " $BPM_INSTALL_COMPLETIONS /zsh/compctl/c1.zsh" ) " = " $BPM_PACKAGES_PATH /$pkg /completion/c1.zsh" ]
228
+ assert [ " $( readlink " $BPM_INSTALL_COMPLETIONS /zsh/compsys//c2.zsh" ) " = " $BPM_PACKAGES_PATH /$pkg /completions/c2.zsh" ]
229
+ assert [ " $( readlink " $BPM_INSTALL_COMPLETIONS /zsh/compctl/c3.zsh" ) " = " $BPM_PACKAGES_PATH /$pkg /contrib/completion/c3.zsh" ]
230
+ assert [ " $( readlink " $BPM_INSTALL_COMPLETIONS /zsh/compsys//c4.zsh" ) " = " $BPM_PACKAGES_PATH /$pkg /contrib/completions/c4.zsh" ]
231
+ }
204
232
205
- @test " does not fail if package doesn't have any completions " {
206
- local package =" username/package"
233
+ @test " adds zsh completions determined from heuristics when when BASH_COMPLETIONS is specified in package.sh " {
234
+ local pkg =" username/package"
207
235
208
- create_package username/package
209
- test_util.fake_clone " $package "
236
+ test_util.setup_pkg " $pkg " ; {
237
+ echo ' BASH_COMPLETIONS=""' > ' package.sh'
238
+ mkdir completion{,s}
239
+ touch " completion/c1.zsh"
240
+ echo ' #compdef' > " completions/c2.zsh"
241
+ }; test_util.finish_pkg
242
+ test_util.fake_install " $pkg "
210
243
211
- run do-plumbing-link-completions username/package
244
+ run do-plumbing-link-completions " $pkg "
212
245
213
246
assert_success
247
+ assert [ " $( readlink " $BPM_INSTALL_COMPLETIONS /zsh/compctl/c1.zsh" ) " = " $BPM_PACKAGES_PATH /$pkg /completion/c1.zsh" ]
248
+ assert [ " $( readlink " $BPM_INSTALL_COMPLETIONS /zsh/compsys//c2.zsh" ) " = " $BPM_PACKAGES_PATH /$pkg /completions/c2.zsh" ]
249
+ }
250
+
251
+ @test " do not add zsh completions from heuristics when ZSH_COMPLETIONS is specified in package.sh" {
252
+ local pkg=" username/package"
253
+
254
+ test_util.setup_pkg " $pkg " ; {
255
+ echo ' ZSH_COMPLETIONS=""' > ' package.sh'
256
+ mkdir ' completion'
257
+ touch " completion/prog.zsh"
258
+ }; test_util.finish_pkg
259
+ test_util.fake_install " $pkg "
260
+
261
+ run do-plumbing-link-completions " $pkg "
262
+
263
+ assert [ ! -f " $BPM_INSTALL_COMPLETIONS /zsh/compctl/prog.zsh" ]
264
+ assert [ ! -f " $BPM_INSTALL_COMPLETIONS /zsh/compsys/prog.zsh" ]
265
+ }
266
+
267
+ @test " do not add zsh completions from heuristics when completionDirs is specified in bpm.toml" {
268
+ local pkg=" username/package"
269
+
270
+ test_util.setup_pkg " $pkg " ; {
271
+ echo ' completionDirs = [ "dirr" ]' > ' bpm.toml'
272
+ mkdir ' completion'
273
+ touch " completion/prog.zsh"
274
+ }; test_util.finish_pkg
275
+ test_util.fake_install " $pkg "
276
+
277
+ run do-plumbing-link-completions " $pkg "
278
+
279
+ assert [ ! -f " $BPM_INSTALL_COMPLETIONS /zsh/compctl/prog.zsh" ]
280
+ assert [ ! -f " $BPM_INSTALL_COMPLETIONS /zsh/compsys/prog.zsh" ]
214
281
}
0 commit comments