Debian Codegraph @

testsuite/modules.50-cmds/190-load.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: 2001/11/05
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: R.K. Owen, <[email protected]>
11 #
12 # Description: Testuite testsequence
13 # Command: load
14 # Modulefiles: loc_dv1/1.0,
15 # loc_dv2/1.0,
16 # loc_dv3/1.0, bad
17 # Sub-Command:
18 #
19 # Comment: %C{
20 # Load a modulefile giving the full path.
21 # }C%
22 #
23 ##############################################################################
24
25 set mod1name "loc_dv1"
26 set mod11 "loc_dv1/1.0"
27 set mod12 "loc_dv1/2.0"
28 set mod21 "loc_dv2/1.0"
29 set mod31 "loc_dv3/1.0"
30
31 set mod11p "$modpath/$mod11"
32 set mod11pd "$reldmodpath/$mod11"
33 set mod11pdd "$relddmodpath/$mod11"
34 set mod12p "$modpath/$mod12"
35 set mod21p "$modpath/$mod21"
36 set mod31p "$modpath/$mod31"
37
38 set oth11 "version"
39 set oth11p "$modpath.2/1.1/version"
40 set oth11pd "$reldmodpath.2/1.1/version"
41 set oth11pdd "$relddmodpath.2/1.1/version"
42
43 #
44 # set up an empty environment
45 #
46 set module ""
47 set modulefile ""
48 setenv_loaded_module $module $modulefile
49
50 #
51 # load
52 # For the different shells ...
53 #
54 set module "$mod31"
55 set modulefile "$mod31p"
56
57 lappend ans [list set _LMFILES_ $modulefile]
58 lappend ans [list set LOADEDMODULES $module]
59
60 #
61 # The tests
62 #
63 test_cmd_re "ALL" "load $mod31" $ans
64
65 # command nickname tests
66 test_cmd_re "sh" "lo $mod31" $ans
67 test_cmd_re "sh" "add $mod31" $ans
68
69 skip_if_quick_mode
70
71
72 #
73 # set up a single environment
74 #
75 set module "$mod11"
76 set modulefile "$mod11p"
77 setenv_loaded_module $module $modulefile
78
79 #
80 # load
81 # For the different shells ...
82 #
83 set module "$mod11:$mod31"
84 set modulefile "$mod11p:$mod31p"
85
86 set ans [list]
87 lappend ans [list set _LMFILES_ $modulefile]
88 lappend ans [list set LOADEDMODULES $module]
89
90 #
91 # The tests
92 #
93 test_cmd_re "ALL" "load $mod31" $ans
94
95 #
96 # set up a double environment
97 #
98 set module "$mod11:$mod21"
99 set modulefile "$mod11p:$mod21p"
100 setenv_loaded_module $module $modulefile
101
102 #
103 # load
104 # For the different shells ...
105 #
106 set module "$mod11:$mod21:$mod31"
107 set modulefile "$mod11p:$mod21p:$mod31p"
108
109 set ans [list]
110 lappend ans [list set _LMFILES_ $modulefile]
111 lappend ans [list set LOADEDMODULES $module]
112
113 #
114 # The tests
115 #
116 test_cmd_re "ALL" "load $mod31" $ans
117
118 # setup MODULEPATH with a trailing slash and an empty dir element
119 setenv_path_var MODULEPATH {} "$modpath/"
120 test_cmd_re "sh" "load $mod31" $ans
121
122 # restore MODULEPATH
123 setenv_path_var MODULEPATH $modpath
124
125
126 # setup LOADEDMODULES/_LMFILES_ with an empty element
127 setenv_loaded_module [list {} $mod11 $mod21] [list {} $mod11p $mod21p]
128
129 set ans [list]
130 # empty elements are ignored but stick to the variable, they should be removed
131 lappend ans [list set _LMFILES_ ":$modulefile"]
132 lappend ans [list set LOADEDMODULES ":$module"]
133 test_cmd_re "sh" "load $mod31" $ans
134
135 # restore LOADEDMODULES/_LMFILES_
136 setenv_loaded_module [list $mod11 $mod21] [list $mod11p $mod21p]
137
138
139 #
140 # load already loaded module
141 # no environment modification, exit 0
142 #
143
144 test_cmd "ALL" "load $mod11" "OK"
145
146 # setup MODULEPATH with a trailing slash and an empty dir element
147 setenv_path_var MODULEPATH {} "$modpath/"
148 test_cmd "sh" "load $mod11" "OK"
149
150 # restore MODULEPATH
151 setenv_path_var MODULEPATH $modpath
152
153
154 # setup LOADEDMODULES/_LMFILES_ with an empty element
155 setenv_loaded_module [list {} $mod11 $mod21] [list {} $mod11p $mod21p]
156
157 set ans [list]
158 test_cmd "sh" "load $mod11" "OK"
159
160 # restore LOADEDMODULES/_LMFILES_
161 setenv_loaded_module [list $mod11 $mod21] [list $mod11p $mod21p]
162
163
164 #
165 # reference a module not in the path
166 #
167 set module "$mod11:$mod21"
168 set modulefile "$mod11p:$mod21p"
169 setenv_loaded_module $module $modulefile
170
171 #
172 # load
173 # For the different shells ...
174 #
175 # different behavior than C-version: on Tcl-version when a module not in the
176 # path is loaded, its module name is equal to its modulefile path since in
177 # this case module name and version cannot be distinguished from the path
178 set module "$mod11:$mod21:$oth11p"
179 set modulefile "$mod11p:$mod21p:$oth11p"
180
181 set ans [list]
182 lappend ans [list set _LMFILES_ $modulefile]
183 lappend ans [list set LOADEDMODULES $module]
184 lappend ans [list set TESTSUITE "1.1"]
185
186 #
187 # The tests
188 #
189 test_cmd_re "ALL" "load $oth11p" $ans
190
191 # try with other full path name forms (./ and ../)
192 test_cmd_re "sh" "load $oth11pd" $ans
193 test_cmd_re "sh" "load $oth11pdd" $ans
194
195 #
196 # error when loading non existent module
197 #
198 set unknown "XYZ"
199
200 testouterr_cmd "ALL" "load $unknown" "ERR" "$err_path\'$unknown\'"
201
202 #
203 # error when loading non existent module given as full path
204 #
205 set unknown "$env(TESTSUITEDIR)/XYZ"
206
207 testouterr_cmd "ALL" "load $unknown" "ERR" "$err_file'$unknown'"
208
209 # try with other full path name forms (./ and ../)
210 set unknown "$reldmodpath/XYZ"
211 set out_interr "$err_file'$modpath/XYZ'"
212 testouterr_cmd "sh" "load $unknown" "ERR" $out_interr
213 set unknown "$relddmodpath/XYZ"
214 testouterr_cmd "sh" "load $unknown" "ERR" $out_interr
215
216 #
217 # test with erroneous modulefile
218 #
219 set badmod "bad"
220 set out_interr [msg_moderr "$msg_invcmdname \"bad-command\"" {bad-command} $modpath/$badmod/.modulerc 28 { }]
221 append out_interr \n\n[msg_load $badmod/before [msg_moderr "$msg_invcmdname \"bad-command\"" {bad-command} $modpath/$badmod/before 26]]
222
223 # ensure load tests have implicit default enabled
224 # skip tests if implicit_default option could not be overridden
225 if {![is_config_locked implicit_default] || $install_implicitdefault eq {y}} {
226 setenv_var MODULES_IMPLICIT_DEFAULT 1
227 testall_cmd "ALL" "load $badmod" "ERR2" "$out_interr" 1
228 unsetenv_var MODULES_IMPLICIT_DEFAULT
229 }
230
231 # try with other full path name forms (./ and ../)
232 set badmod "$reldmodpath/bad/before"
233 set out_interr [msg_load $modpath/bad/before [msg_moderr "$msg_invcmdname \"bad-command\"" {bad-command} $modpath/bad/before 26]]
234 testouterr_cmd "sh" "load $badmod" "ERR" $out_interr
235 set badmod "$relddmodpath/bad/before"
236 testouterr_cmd "sh" "load $badmod" "ERR" $out_interr
237
238 #
239 # test with file given as full path which is not a modulefile
240 #
241 set badmod "$env(TESTSUITEDIR)/modulefiles/README"
242 set out_interr "$err_magic'$badmod'\n$err_contact"
243 testall_cmd "ALL" "load $badmod" "ERR" $out_interr 1
244
245 # try with other full path name forms (./ and ../)
246 set badmod "$reldmodpath/README"
247 testouterr_cmd "sh" "load $badmod" "ERR" $out_interr
248 set badmod "$relddmodpath/README"
249 testouterr_cmd "sh" "load $badmod" "ERR" $out_interr
250
251
252 #
253 # test full path modulefile already loaded
254 #
255 setenv_loaded_module $module $modulefile
256
257 test_cmd_re "ALL" "load $oth11p" "OK"
258 test_cmd_re "sh" "load $oth11pd" "OK"
259 test_cmd_re "sh" "load $oth11pdd" "OK"
260
261
262 #
263 # test module already loaded as full path, try to load again with short name
264 # and modpath used
265 #
266 setenv_path_var MODULEPATH "$modpath.2" $modpath
267 setenv_loaded_module $mod12p $mod12p
268 # ensure load tests have implicit default enabled
269 if {![is_config_locked implicit_default] || $install_implicitdefault eq {y}} {
270 setenv_var MODULES_IMPLICIT_DEFAULT 1
271 test_cmd_re "sh" "load $mod12" "OK"
272 test_cmd_re "sh" "load $mod1name" "OK"
273 unsetenv_var MODULES_IMPLICIT_DEFAULT
274 }
275
276 #
277 # test to load full path a modulefile already loaded with short name
278 #
279 setenv_loaded_module $mod11 $mod11p
280
281 test_cmd_re "sh" "load $mod11p" "OK"
282 test_cmd_re "sh" "load $mod11pd" "OK"
283 test_cmd_re "sh" "load $mod11pdd" "OK"
284
285 # unset MODULEPATH
286 unsetenv_path_var MODULEPATH
287
288 test_cmd_re "sh" "load $mod11p" "OK"
289 test_cmd_re "sh" "load $mod11pd" "OK"
290 test_cmd_re "sh" "load $mod11pdd" "OK"
291
292
293 #
294 # test module already loaded as full path, try to load again with short name
295 # no modpath set
296 #
297 setenv_loaded_module $mod12p $mod12p
298
299 testouterr_cmd_re "sh" "load $mod12" "ERR" $err_nomodpath
300 testouterr_cmd_re "sh" "load $mod1name" "ERR" $err_nomodpath
301
302
303 #
304 # load when loaded environment is inconsistent
305 #
306
307 setenv_loaded_module [list foo bar] "/path/to/foo"
308 setenv_path_var MODULEPATH $modpath
309
310 testouterr_cmd_re "sh" "load $mod12" "ERR" "$err_loinconsist\n LOADEDMODULES=foo bar\n _LMFILES_=/path/to/foo"
311
312
313 #
314 # Cleanup
315 #
316
317 reset_test_env