Debian Codegraph @

testsuite/modules.50-cmds/540-complete.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.50-cmds/%M%
6 # Revision: %I%
7 # First Edition: 2022/01/31
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command: load, unload, display, help, test, whatis, refresh, avail
14 # Modulefiles: complete
15 # Sub-Command:
16 #
17 # Comment: %C{
18 # Test complete modulefile command
19 # }C%
20 #
21 ##############################################################################
22
23 set mp $modpath.3
24 set mpre $modpathre.3
25 setenv_path_var MODULEPATH $mp
26
27 set mod complete/1.0
28 set modname complete
29 set modfile $mp/$mod
30 set modfilere $mpre/$mod
31
32
33 #
34 # bad specifications
35 #
36
37 setenv_var TESTSUITE_COMPLETE compbad1
38
39 # load
40 set tserr [escre [msg_load $mod [msg_moderr {wrong # args: should be "complete shell name body"} {complete<EXM>} $modfile 5 {} {} {} {} {invoked from within}]]]
41 testouterr_cmd_re bash "load $mod" ERR $tserr
42
43 setenv_loaded_module [list $mod] [list $modfile]
44 setenv_var __MODULES_LMREFRESH $mod
45
46 # unload
47 set tserr [escre [msg_unload $mod [msg_moderr {wrong # args: should be "complete shell name body"} {complete<EXM>} $modfile 5 {} {} {} {} {invoked from within}]]]
48 testouterr_cmd_re bash "unload $mod" ERR $tserr
49
50 # refresh
51 set tserr [escre [msg_refresh $mod [msg_moderr {wrong # args: should be "complete shell name body"} {complete<EXM>} $modfile 5 {} {} {} {} {invoked from within}]]]
52 testouterr_cmd_re bash "refresh" ERR $tserr
53
54 unsetenv_loaded_module
55 unsetenv_var __MODULES_LMREFRESH
56
57 # whatis
58 set tserr "$modlin $mpre $modlin
59 \\s*$mod: $mod"
60 testouterr_cmd_re bash "whatis $mod" OK $tserr
61
62 # display
63 set tserr "$modlin
64 $mpre/$mod:
65
66 module-whatis\t$mod
67 complete\t
68 $modlin"
69 testouterr_cmd_re bash "display $mod" OK $tserr
70
71 # help
72 set tserr "$modlin
73 Module Specific Help for $mpre/$mod:
74
75 $warn_msgs: Unable to find ModulesHelp in $modfilere.
76 $modlin"
77 testouterr_cmd_re bash "help $mod" OK $tserr
78
79 # test
80 set tserr "$modlin
81 Module Specific Test for $mpre/$mod:
82
83 $warn_msgs: Unable to find ModulesTest in $modfilere.
84 $modlin"
85 testouterr_cmd_re bash "test $mod" OK $tserr
86
87
88 setenv_var TESTSUITE_COMPLETE compbad2
89 set tserr [escre [msg_load $mod [msg_moderr {wrong # args: should be "complete shell name body"} {complete bash<EXM>} $modfile 5 {} {} {} {} {invoked from within}]]]
90 testouterr_cmd_re bash "load $mod" ERR $tserr
91
92 setenv_loaded_module [list $mod] [list $modfile]
93 set tserr [escre [msg_unload $mod [msg_moderr {wrong # args: should be "complete shell name body"} {complete bash<EXM>} $modfile 5 {} {} {} {} {invoked from within}]]]
94 testouterr_cmd_re bash "unload $mod" ERR $tserr
95 unsetenv_loaded_module
96
97
98 setenv_var TESTSUITE_COMPLETE compbad3
99 set tserr [escre [msg_load $mod [msg_moderr {wrong # args: should be "complete shell name body"} {complete bash cmd<EXM>} $modfile 5 {} {} {} {} {invoked from within}]]]
100 testouterr_cmd_re bash "load $mod" ERR $tserr
101
102 setenv_loaded_module [list $mod] [list $modfile]
103 set tserr [escre [msg_unload $mod [msg_moderr {wrong # args: should be "complete shell name body"} {complete bash cmd<EXM>} $modfile 5 {} {} {} {} {invoked from within}]]]
104 testouterr_cmd_re bash "unload $mod" ERR $tserr
105 unsetenv_loaded_module
106
107 setenv_var TESTSUITE_COMPLETE compbad4
108 set tserr [escre [msg_load $mod [msg_moderr {Invalid command name ''} {complete bash {} {-o default -F _cmd}<EXM>} $modfile 5]]]
109 testouterr_cmd_re bash "load $mod" ERR $tserr
110
111 setenv_loaded_module [list $mod] [list $modfile]
112 set tserr [escre [msg_unload $mod [msg_moderr {Invalid command name ''} {complete bash {} {-o default -F _cmd}<EXM>} $modfile 5]]]
113 testouterr_cmd_re bash "unload $mod" ERR $tserr
114 unsetenv_loaded_module
115
116
117 #
118 # regular specifications
119 #
120
121 setenv_var TESTSUITE_COMPLETE comp1
122
123 # load
124 foreach shell $supported_shells {
125 set ans [list]
126 lappend ans [list set __MODULES_LMREFRESH $mod]
127 lappend ans [list set _LMFILES_ $modfile]
128 lappend ans [list set LOADEDMODULES $mod]
129 switch -- $shell {
130 bash {
131 lappend ans [list out {complete -o default -F _cmd cmd;}]
132 }
133 tcsh {
134 lappend ans [list out {complete cmd some arg list for tcsh;}]
135 }
136 fish {
137 lappend ans [list out {complete -e -c cmd;}]
138 lappend ans [list out {complete -c cmd some arg list for fish;}]
139 lappend ans [list out {complete -c cmd other arg list for fish;}]
140 }
141 pwsh {
142 lappend ans [list out {Register-ArgumentCompleter -CommandName cmd\
143 -ScriptBlock { some arg list for pwsh }}]
144 }
145 }
146 testouterr_cmd $shell "load $mod" $ans {}
147 }
148
149 setenv_loaded_module [list $mod] [list $modfile]
150 setenv_var __MODULES_LMREFRESH $mod
151
152 # unload
153 foreach shell $supported_shells {
154 set ans [list]
155 lappend ans [list unset _LMFILES_]
156 lappend ans [list unset LOADEDMODULES]
157 lappend ans [list unset __MODULES_LMREFRESH]
158 switch -- $shell {
159 bash {
160 lappend ans [list out {complete -r cmd;}]
161 }
162 tcsh {
163 lappend ans [list out {uncomplete cmd;}]
164 }
165 fish {
166 lappend ans [list out {complete -e -c cmd;}]
167 }
168 pwsh {
169 lappend ans [list out {Unregister-ArgumentCompleter -CommandName cmd}]
170 }
171 }
172 testouterr_cmd $shell "unload $mod" $ans {}
173 }
174
175 # refresh
176 foreach shell $supported_shells {
177 switch -- $shell {
178 bash {
179 set ans [list]
180 lappend ans [list out {complete -o default -F _cmd cmd;}]
181 }
182 tcsh {
183 set ans [list]
184 lappend ans [list out {complete cmd some arg list for tcsh;}]
185 }
186 fish {
187 set ans [list]
188 lappend ans [list out {complete -e -c cmd;}]
189 lappend ans [list out {complete -c cmd some arg list for fish;}]
190 lappend ans [list out {complete -c cmd other arg list for fish;}]
191 }
192 pwsh {
193 set ans [list]
194 lappend ans [list out {Register-ArgumentCompleter -CommandName cmd\
195 -ScriptBlock { some arg list for pwsh }}]
196 }
197 default {
198 set ans [list [list OK nop]]
199 }
200 }
201 testouterr_cmd $shell "refresh" $ans {}
202 }
203
204
205 unsetenv_loaded_module
206 unsetenv_var __MODULES_LMREFRESH
207
208 # whatis
209 set tserr "$modlin $mpre $modlin
210 \\s*$mod: $mod"
211 testouterr_cmd_re bash "whatis $mod" OK $tserr
212 testouterr_cmd_re sh "whatis $mod" OK $tserr
213
214 # display
215 set tserr "$modlin
216 $mpre/$mod:
217
218 module-whatis\t$mod
219 complete\tbash cmd {-o default -F _cmd}
220 complete\ttcsh cmd {some arg list for tcsh}
221 complete\tfish cmd {some arg list for fish}
222 complete\tfish cmd {other arg list for fish}
223 complete\tzsh cmd {some arg list for zsh}
224 complete\tunksh cmd {some arg list for unksh}
225 complete\tpwsh cmd {some arg list for pwsh}
226 $modlin"
227 testouterr_cmd_re bash "display $mod" OK $tserr
228 testouterr_cmd_re sh "display $mod" OK $tserr
229
230 # help
231 set tserr "$modlin
232 Module Specific Help for $mpre/$mod:
233
234 $warn_msgs: Unable to find ModulesHelp in $modfilere.
235 $modlin"
236 testouterr_cmd_re bash "help $mod" OK $tserr
237 testouterr_cmd_re sh "help $mod" OK $tserr
238
239 # test
240 set tserr "$modlin
241 Module Specific Test for $mpre/$mod:
242
243 $warn_msgs: Unable to find ModulesTest in $modfilere.
244 $modlin"
245 testouterr_cmd_re bash "test $mod" OK $tserr
246 testouterr_cmd_re sh "test $mod" OK $tserr
247
248
249 setenv_var TESTSUITE_COMPLETE comp2
250 foreach shell $supported_shells {
251 set ans [list]
252 lappend ans [list set __MODULES_LMREFRESH $mod]
253 lappend ans [list set _LMFILES_ $modfile]
254 lappend ans [list set LOADEDMODULES $mod]
255 switch -- $shell {
256 bash {
257 lappend ans [list out {complete some arg list for shell cmd;}]
258 lappend ans [list out {complete other arg list for shell cmd;}]
259 }
260 tcsh {
261 lappend ans [list out {complete cmd some arg list for shell;}]
262 lappend ans [list out {complete cmd other arg list for shell;}]
263 }
264 fish {
265 lappend ans [list out {complete -e -c cmd;}]
266 lappend ans [list out {complete -c cmd some arg list for shell;}]
267 lappend ans [list out {complete -c cmd other arg list for shell;}]
268 }
269 pwsh {
270 lappend ans [list out {Register-ArgumentCompleter -CommandName cmd\
271 -ScriptBlock { some arg list for shell }}]
272 lappend ans [list out {Register-ArgumentCompleter -CommandName cmd\
273 -ScriptBlock { other arg list for shell }}]
274 }
275 }
276 testouterr_cmd $shell "load $mod" $ans {}
277 }
278
279
280 #
281 # break/restore evaluations
282 #
283
284 setenv_var TESTSUITE_COMPLETE compbreak1
285 set ans [list]
286 lappend ans [list set __MODULES_LMREFRESH $modname/1.2]
287 lappend ans [list set _LMFILES_ $mp/$modname/1.2]
288 lappend ans [list set LOADEDMODULES $modname/1.2]
289 lappend ans [list out {complete -o default -F _othercmd othercmd;}]
290 lappend ans [list ERR]
291 set tserr [msg_load $mod $err_evalabort]
292 testouterr_cmd_re bash "load $mod $modname/1.2" $ans $tserr
293
294 setenv_var TESTSUITE_COMPLETE compbreak2
295 set ans [list]
296 lappend ans [list set _LMFILES_ $mp/$modname/1.2]
297 lappend ans [list set LOADEDMODULES $modname/1.2]
298 lappend ans [list ERR]
299 set tserr [msg_load $mod $err_evalabort]
300 testouterr_cmd_re bash "load $mod $modname/1.2" $ans $tserr
301
302
303 #
304 # combined evaluations
305 #
306
307 setenv_var TESTSUITE_COMPLETE compcomb1
308 set ans [list]
309 lappend ans [list set __MODULES_LMREFRESH $mod]
310 lappend ans [list set _LMFILES_ $modfile:$mp/$modname/1.2]
311 lappend ans [list set LOADEDMODULES $mod:$modname/1.2]
312 lappend ans [list out {complete -r cmd;}]
313 testouterr_cmd_re bash "load $mod $modname/1.2" $ans {}
314
315
316 #
317 # usage attempt from modulerc
318 #
319
320 setenv_var TESTSUITE_COMPLETE comprc1
321
322 set ans [list]
323 lappend ans [list set _LMFILES_ $modfile]
324 lappend ans [list set LOADEDMODULES $mod]
325 lappend ans [list ERR]
326 set ln [expr {[cmpversion $tclsh_version 8.6] == -1 ? 3 : 6}]
327 set tserr [escre [msg_moderr {invalid command name "complete"} {complete bash cmd {-o default -F _cmd}<EXM>} $mp/complete/.modulerc $ln { }]]
328 testouterr_cmd_re bash "load $mod" $ans $tserr
329
330 set tserr $mp:\n$mod
331 testouterr_cmd bash "avail -t $mod" OK $tserr
332
333 set tserr "$modlin $mpre $modlin
334 \\s*$mod: $mod"
335 testouterr_cmd_re bash "whatis $mod" OK $tserr
336
337
338 #
339 # Cleanup
340 #
341
342 reset_test_env