Debian Codegraph @

testsuite/modules.70-maint/280-ml.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.70-maint/%M%
6 # Revision: %I%
7 # First Edition: 2019/11/28
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command:
14 # Modulefiles:
15 # Sub-Command:
16 #
17 # Comment: %C{
18 # Test 'ml' sub-command
19 # }C%
20 #
21 ##############################################################################
22
23 # ensure avail -t tests have implicit default enabled
24 setenv_var MODULES_IMPLICIT_DEFAULT 1
25
26 # ensure regular avail search match is set for these tests
27 setenv_var MODULES_SEARCH_MATCH starts_with
28
29 # ensure avail tests are made using in depth mode
30 setenv_var MODULES_AVAIL_INDEPTH 1
31
32 # ensure last matching element is returned when unloading modules
33 setenv_var MODULES_UNLOAD_MATCH_ORDER returnlast
34
35 set mp $modpath.2
36 set mpre [regsub -all "\(\[.+?\]\)" $mp {\\\1}]
37
38 # setup specific environment
39 setenv_path_var MODULEPATH $mp
40
41 set key_sym "\n\nKey:\n(symbolic-version)"
42
43 # call sub-cmd if first arg is a known sub-cmd
44 testouterr_cmd sh {ml path extdfl} [list [list text $mp/extdfl/1.3.1]] {}
45 testouterr_cmd sh {ml avail -t extdfl/1.3.1} OK "$mp:\nextdfl/1.3.1(default)"
46 testouterr_cmd sh {ml av -t extdfl/1.3.1} OK "$mp:\nextdfl/1.3.1(default)"
47
48 # try to load a module named load: sub-command call has higher priority
49 set ans [list]
50 lappend ans [list set __MODULES_LMALTNAME extdfl/1.3.1&extdfl/default&extdfl]
51 lappend ans [list set _LMFILES_ $mp/extdfl/1.3.1]
52 lappend ans [list set LOADEDMODULES extdfl/1.3.1]
53 testouterr_cmd sh {ml load extdfl} $ans {}
54 testouterr_cmd sh {ml lo extdfl} $ans {}
55
56 # default is 'list'
57 set tserr $no_loaded
58 testouterr_cmd sh {ml} OK $tserr
59
60 skip_if_quick_mode
61
62 # trigger usage message
63 set tserr "$vers_reportre\nUsage: ml .*See 'module --help' to get available commands and options."
64 testouterr_cmd_re sh {ml -h} OK $tserr
65 testouterr_cmd_re sh {ml --help} OK $tserr
66
67 # basic load test
68 testouterr_cmd sh {ml extdfl} $ans {}
69
70 # basic tests over a loaded module
71 setenv_loaded_module [list extdfl/1.3.1] [list $mp/extdfl/1.3.1]
72 setenv_var __MODULES_LMALTNAME extdfl/1.3.1&extdfl/default&extdfl
73 testouterr_cmd sh {ml} OK "$cur_loaded\n 1) extdfl/1.3.1(default)$key_sym"
74 testouterr_cmd sh {ml extdfl} OK {}
75 set ans [list]
76 lappend ans [list unset __MODULES_LMALTNAME]
77 lappend ans [list unset _LMFILES_]
78 lappend ans [list unset LOADEDMODULES]
79 testouterr_cmd sh {ml -extdfl} $ans {}
80 testouterr_cmd sh {ml -extdfl/1.3.1} $ans {}
81
82 # command line switches prevail over module to unload
83 testouterr_cmd sh {ml -t} OK "$cur_loaded\nextdfl/1.3.1"
84 testouterr_cmd sh {ml -t -f} OK "$cur_loaded\nextdfl/1.3.1"
85 testouterr_cmd sh {ml --terse} OK "$cur_loaded\nextdfl/1.3.1"
86 setenv_loaded_module [list t f] [list $mp/t $mp/f]
87 unsetenv_var __MODULES_LMALTNAME
88 set ans [list]
89 lappend ans [list set __MODULES_LMALTNAME extdfl/1.3.1&extdfl/default&extdfl]
90 lappend ans [list set _LMFILES_ $mp/t:$mp/f:$mp/extdfl/1.3.1]
91 lappend ans [list set LOADEDMODULES t:f:extdfl/1.3.1]
92 testouterr_cmd_re sh {ml extdfl -t} $ans {}
93 testouterr_cmd_re sh {ml -f extdfl -t} $ans {}
94 unsetenv_loaded_module
95
96 # abbreviated sub-command name should be consistent
97 set ans [list]
98 lappend ans [list set __MODULES_LMALTNAME extdfl/1.3.1&extdfl/default&extdfl]
99 lappend ans [list set _LMFILES_ $mp/extdfl/1.3.1]
100 lappend ans [list set LOADEDMODULES extdfl/1.3.1]
101 testouterr_cmd sh {ml lo extdfl} $ans {}
102 testouterr_cmd sh {ml loda extdfl} ERR $err_path'loda'
103
104 # module name whose start match command abbreviation
105 set ans [list]
106 lappend ans [list set _LMFILES_ $mp/loc]
107 lappend ans [list set LOADEDMODULES loc]
108 testouterr_cmd sh {ml loc} $ans {}
109 set ans [list]
110 lappend ans [list set _LMFILES_ $mp/unloc]
111 lappend ans [list set LOADEDMODULES unloc]
112 testouterr_cmd sh {ml unloc} $ans {}
113
114 # test version report
115 testouterr_cmd_re sh {ml -V} OK $vers_reportre
116 testouterr_cmd_re sh {ml --version} OK $vers_reportre
117
118 # empty args
119 set tserr $err_path'""'
120 testouterr_cmd sh {ml } ERR $err_emptymodname
121 testouterr_cmd sh {ml ""} ERR $tserr
122 testouterr_cmd sh {ml "" ""} ERR $tserr\n$tserr
123 testouterr_cmd sh {ml "" foo} ERR $tserr
124
125 # badly written commands
126 testouterr_cmd sh {ml -} ERR "$error_msgs: Invalid option '-'\n$err_typehelp"
127 testouterr_cmd sh {ml - foo} ERR "$error_msgs: Invalid option '-'\n$err_typehelp"
128 testouterr_cmd sh {ml --} ERR "$error_msgs: Invalid option '--'\n$err_typehelp"
129 testouterr_cmd sh {ml --bar} ERR "$error_msgs: Invalid option '--bar'\n$err_typehelp"
130
131 # enable advanced version spec for next tests
132 setenv_var MODULES_ADVANCED_VERSION_SPEC 1
133
134 # adv version spec
135 set ans [list]
136 lappend ans [list set __MODULES_LMALTNAME foo/2&as|foo/default&as|foo/latest]
137 lappend ans [list set _LMFILES_ $mp/foo/2]
138 lappend ans [list set LOADEDMODULES foo/2]
139 testouterr_cmd sh {ml foo@2:3 -bar@1:2} $ans {}
140 testouterr_cmd sh {ml foo @2} $ans {}
141 testouterr_cmd sh {ml -foo @2} OK {}
142 setenv_loaded_module [list foo/2] [list $mp/foo/2]
143 set ans [list]
144 lappend ans [list unset _LMFILES_]
145 lappend ans [list unset LOADEDMODULES]
146 testouterr_cmd sh {ml -foo @2} $ans {}
147 testouterr_cmd sh {ml -foo @1} OK {}
148 set ans [list]
149 lappend ans [list set __MODULES_LMALTNAME baz/2&as|baz/default&as|baz/latest]
150 lappend ans [list set _LMFILES_ $mp/foo/2:$mp/foo/1:$mp/baz/2]
151 lappend ans [list set LOADEDMODULES foo/2:foo/1:baz/2]
152 testouterr_cmd_re sh {ml foo @1 -bar@2 baz -qux @1:3} $ans {}
153 setenv_loaded_module [list foo/1 bar/2 qux/1] [list $mp/foo/1 $mp/bar/2 $mp/qux/1]
154 set ans [list]
155 lappend ans [list set __MODULES_LMALTNAME baz/2&as|baz/default&as|baz/latest]
156 lappend ans [list set _LMFILES_ $mp/foo/1:$mp/baz/2]
157 lappend ans [list set LOADEDMODULES foo/1:baz/2]
158 testouterr_cmd_re sh {ml foo @1 -bar@2 baz -qux @1:3} $ans {}
159 unsetenv_loaded_module
160
161 # badly written adv version spec
162 testouterr_cmd sh {ml foo [email protected]} ERR "$err_specmodname'[email protected]'"
163 testouterr_cmd sh {ml foo@3:2} ERR "$err_rangevers'3:2'"
164 testouterr_cmd sh {ml @3} ERR "$err_specmodname'@3'"
165 testouterr_cmd sh {ml @3 foo} ERR "$err_specmodname'@3'"
166 testouterr_cmd sh {ml foo@2,} ERR "$err_specvers'2,'"
167 testouterr_cmd sh {ml foo@2, bar} ERR "$err_specvers'2,'"
168 testouterr_cmd sh {ml } ERR $err_emptymodname
169 testouterr_cmd sh {ml bar} ERR $err_emptymodname
170
171 # disabled advanced version spec
172 setenv_var MODULES_ADVANCED_VERSION_SPEC 0
173 testouterr_cmd sh {ml foo@2:3 -bar@3:4} ERR "$err_path'foo@2:3'"
174 testouterr_cmd sh {ml foo @1.2} ERR "$err_path'@1.2'"
175
176 unsetenv_var MODULES_ADVANCED_VERSION_SPEC
177
178 # ml is not a modulefile command
179 testouterr_cmd sh {load mlinmod} ERR [msg_load mlinmod [msg_moderr "$msg_invcmdname \"ml\"" {ml extdfl -advvers} $mp/mlinmod 2]]
180
181 # load only command
182 set ans [list]
183 if {[is_conf_enabled advversspec]} {
184 lappend ans [list set __MODULES_LMALTNAME bar/2&as|bar/default&as|bar/latest]
185 }
186 lappend ans [list set _LMFILES_ $mp/bar/2]
187 lappend ans [list set LOADEDMODULES bar/2]
188 testouterr_cmd sh {ml -v bar} $ans [msg_load bar/2]
189 set ans [list]
190 if {[is_conf_enabled advversspec]} {
191 lappend ans [list set __MODULES_LMALTNAME bar/2&as|bar/default&as|bar/latest]
192 }
193 lappend ans [list set _LMFILES_ $mp/bar/2:$mp/foo/1]
194 lappend ans [list set LOADEDMODULES bar/2:foo/1]
195 testouterr_cmd_re sh {ml bar foo/1 -v} $ans [msg_load bar/2]\n[msg_load foo/1]
196
197 # unload only command
198 testouterr_cmd sh {ml -v -bar} OK {}
199 setenv_loaded_module [list foo/1 bar/2] [list $mp/foo/1 $mp/bar/2]
200 set ans [list]
201 lappend ans [list set _LMFILES_ $mp/foo/1]
202 lappend ans [list set LOADEDMODULES foo/1]
203 testouterr_cmd sh {ml -v -bar} $ans [msg_unload bar/2]
204 set ans [list]
205 lappend ans [list unset _LMFILES_]
206 lappend ans [list unset LOADEDMODULES]
207 testouterr_cmd sh {ml -bar -foo/1 -v} $ans [msg_unload bar/2]\n[msg_unload foo/1]
208
209 # mixed unload/load command: order matters among load and among unload
210 # but unloads are always treated prior loads
211 setenv_loaded_module [list foo/1] [list $mp/foo/1]
212 set ans [list]
213 if {[is_conf_enabled advversspec]} {
214 lappend ans [list set __MODULES_LMALTNAME bar/2&as|bar/default&as|bar/latest:baz/2&as|baz/default&as|baz/latest]
215 }
216 lappend ans [list set _LMFILES_ $mp/bar/2:$mp/baz/2]
217 lappend ans [list set LOADEDMODULES bar/2:baz/2]
218 testouterr_cmd_re sh {ml bar -foo/1 -v baz} $ans [msg_unload foo/1]\n[msg_load bar/2]\n[msg_load baz/2]
219 testouterr_cmd_re sh {ml -v -foo/1 bar baz} $ans [msg_unload foo/1]\n[msg_load bar/2]\n[msg_load baz/2]
220 testouterr_cmd_re sh {ml -v bar baz -foo/1} $ans [msg_unload foo/1]\n[msg_load bar/2]\n[msg_load baz/2]
221 set ans [list]
222 if {[is_conf_enabled advversspec]} {
223 lappend ans [list set __MODULES_LMALTNAME baz/2&as|baz/default&as|baz/latest:bar/2&as|bar/default&as|bar/latest]
224 }
225 lappend ans [list set _LMFILES_ $mp/baz/2:$mp/bar/2]
226 lappend ans [list set LOADEDMODULES baz/2:bar/2]
227 testouterr_cmd_re sh {ml -v baz bar -foo/1} $ans [msg_unload foo/1]\n[msg_load baz/2]\n[msg_load bar/2]
228 setenv_loaded_module [list foo/1 qux/2] [list $mp/foo/1 $mp/qux/2]
229 set ans [list]
230 if {[is_conf_enabled advversspec]} {
231 lappend ans [list set __MODULES_LMALTNAME bar/2&as|bar/default&as|bar/latest:baz/2&as|baz/default&as|baz/latest]
232 }
233 lappend ans [list set _LMFILES_ $mp/bar/2:$mp/baz/2]
234 lappend ans [list set LOADEDMODULES bar/2:baz/2]
235 testouterr_cmd_re sh {ml --verbose bar -qux baz -foo/1} $ans [msg_unload qux/2]\n[msg_unload foo/1]\n[msg_load bar/2]\n[msg_load baz/2]
236
237 # module not found error handling checks
238 setenv_loaded_module [list foo/1] [list $mp/foo/1]
239 testouterr_cmd sh {ml -foo/12} OK {}
240 set ans [list]
241 lappend ans [list unset _LMFILES_]
242 lappend ans [list unset LOADEDMODULES]
243 testouterr_cmd sh {ml -foo/12 -foo/1} $ans {}
244 testouterr_cmd sh {ml -foo/1 -foo/12} $ans {}
245 set ans [list]
246 if {[is_conf_enabled advversspec]} {
247 lappend ans [list set __MODULES_LMALTNAME bar/2&as|bar/default&as|bar/latest]
248 }
249 lappend ans [list set _LMFILES_ $mp/foo/1:$mp/bar/2]
250 lappend ans [list set LOADEDMODULES foo/1:bar/2]
251 testouterr_cmd_re sh {ml -foo/12 bar} $ans {}
252 testouterr_cmd sh {ml bar/12} ERR $err_path'bar/12'
253 testouterr_cmd sh {ml bar/12 bar/2} ERR $err_path'bar/12'
254 testouterr_cmd sh {ml bar/2 bar/12} ERR $err_path'bar/12'
255 testouterr_cmd sh {ml -foo/1 bar/12} ERR $err_path'bar/12'
256
257 # broken evaluation error handling checks
258 setenv_loaded_module [list foo/1 foo/0.1] [list $mp/foo/1 $mp/foo/0.1]
259 testall_cmd sh {ml -foo/0.1} ERR [msg_unload foo/0.1 $err_evalabort] 1
260 testouterr_cmd sh {ml -foo/0.1 -foo/1} ERR [msg_unload foo/0.1 $err_evalabort]
261 testouterr_cmd sh {ml -foo/0.1 bar/1} ERR [msg_unload foo/0.1 $err_evalabort]
262 testouterr_cmd sh {ml bar/0.1} ERR [msg_load bar/0.1 $err_evalabort]
263 testouterr_cmd sh {ml bar/0.1 bar/1} ERR [msg_load bar/0.1 $err_evalabort]
264 testouterr_cmd sh {ml bar/1 bar/0.1} ERR [msg_load bar/0.1 $err_evalabort]
265 testouterr_cmd sh {ml -foo/1 bar/0.1} ERR [msg_load bar/0.1 $err_evalabort]
266
267 # bad command error handling checks
268 setenv_loaded_module [list foo/0.2] [list $mp/foo/0.2]
269 set tserr [msg_moderr "$msg_invcmdname \"badcmd\"" {badcmd} $mp/foo/0.2 2]
270 testouterr_cmd sh {ml -foo/0.2} ERR [msg_unload foo/0.2 $tserr]
271 testouterr_cmd sh {ml -foo/0.2 -foo/1} ERR [msg_unload foo/0.2 $tserr]
272 testouterr_cmd sh {ml -foo/0.2 bar/1} ERR [msg_unload foo/0.2 $tserr]
273 set tserr [msg_moderr "$msg_invcmdname \"badcmd\"" {badcmd} $mp/bar/0.2 2]
274 testouterr_cmd sh {ml bar/0.2} ERR [msg_load bar/0.2 $tserr]
275 testouterr_cmd sh {ml bar/0.2 bar/1} ERR [msg_load bar/0.2 $tserr]
276 testouterr_cmd sh {ml bar/1 bar/0.2} ERR [msg_load bar/0.2 $tserr]
277 testouterr_cmd sh {ml -foo/1 bar/0.2} ERR [msg_load bar/0.2 $tserr]
278
279
280 # test clear sub-command
281 testinouterr_cmd sh {ml clear} no {} "$info_msgs: Modules runtime information were not cleared"
282
283 # only clear Modules-specific variables that are defined
284 set ans [list]
285 lappend ans [list unset _LMFILES_]
286 lappend ans [list unset LOADEDMODULES]
287 testinouterr_cmd sh {clear} y $ans {}
288
289 setenv_loaded_module [list extdfl/1.3.1] [list $mp/extdfl/1.3.1]
290 setenv_var __MODULES_LMALTNAME extdfl/1.3.1&extdfl/default&extdfl
291 set ans [list]
292 lappend ans [list unset __MODULES_LMALTNAME]
293 lappend ans [list unset _LMFILES_]
294 lappend ans [list unset LOADEDMODULES]
295 testinouterr_cmd sh {clear} y $ans {}
296
297
298 #
299 # Cleanup
300 #
301
302 reset_test_env