Debian Codegraph @

testsuite/modules.50-cmds/740-hook.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: 2026/08/05
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command: load, unload, avail
14 # Modulefiles: err, foo, puts, scan
15 # Sub-Command:
16 #
17 # Comment: %C{
18 # Test add-hook command and hook events
19 # }C%
20 #
21 ##############################################################################
22
23 skip_if_quick_mode
24
25 set mp $modpath.4
26 set mpre $modpathre.4
27 setenv_path_var MODULEPATH $mp
28
29 # no global RC file evaluation should interfere with hook checks below
30 unsetenv_var MODULERCFILE
31
32 # check expected siteconfig file is installed
33 set is_stderr_tty [siteconfig_isStderrTty]
34 if {$is_stderr_tty} {
35
36 # unknown hook event is a fatal siteconfig error
37 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK unknownevent
38 set tserr [escre "$error_msgs: Site configuration source failed
39 Unknown hook event 'not-an-event'"]
40 append tserr {(\n.*)*}
41 testouterr_cmd_re sh {avail foo} ERR $tserr
42 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
43
44
45 # before/after-modulefile-eval hooks fire with correct arguments on load
46 # and unload
47 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK modulefile
48
49 set tserr "HOOK before-modulefile-eval $mp/foo/2.0 foo/2.0 foo/2.0 foo/2.0\
50 load 1
51 HOOK after-modulefile-eval $mp/foo/2.0 foo/2.0 foo/2.0 foo/2.0 load 1 0"
52 set ans [list]
53 lappend ans [list set _LMFILES_ $mp/foo/2.0]
54 lappend ans [list set LOADEDMODULES foo/2.0]
55 testouterr_cmd sh {load foo/2.0} $ans $tserr
56
57 setenv_loaded_module [list foo/2.0] [list $mp/foo/2.0]
58 set tserr "HOOK before-modulefile-eval $mp/foo/2.0 foo/2.0 foo/2.0 foo/2.0\
59 unload 1
60 HOOK after-modulefile-eval $mp/foo/2.0 foo/2.0 foo/2.0 foo/2.0 unload 1 0"
61 set ans [list]
62 lappend ans [list unset _LMFILES_]
63 lappend ans [list unset LOADEDMODULES]
64 testouterr_cmd sh {unload foo/2.0} $ans $tserr
65 unsetenv_loaded_module
66
67 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
68
69
70 # before/after-modulerc-eval hooks fire with correct arguments, for both
71 # the modulepath root modulerc and the per-directory one
72 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK modulerc
73
74 set tserr "HOOK before-modulerc-eval $mp/.modulerc .modulerc
75 HOOK after-modulerc-eval $mp/.modulerc .modulerc 0
76 HOOK before-modulerc-eval $mp/puts/.modulerc puts/.modulerc
77 HOOK after-modulerc-eval $mp/puts/.modulerc puts/.modulerc 0"
78 set ans [list]
79 lappend ans [list set __MODULES_LMALTNAME puts/2&as|puts/default&as|puts/latest]
80 lappend ans [list set _LMFILES_ $mp/puts/2]
81 lappend ans [list set LOADEDMODULES puts/2]
82 testouterr_cmd sh {load puts/2} $ans $tserr
83
84 setenv_loaded_module [list puts/2] [list $mp/puts/2]
85 unsetenv_loaded_module
86 unsetenv_var __MODULES_LMALTNAME
87
88 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
89
90
91 # after-modulerc-eval hook reports a non-zero status when modulerc
92 # evaluation fails, and evaluation of the module continues afterward
93 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK modulerc
94 setenv_var TESTSUITE_PUTS log_rc_and_unk
95
96 set tserr [escre "HOOK before-modulerc-eval $mp/.modulerc .modulerc
97 HOOK after-modulerc-eval $mp/.modulerc .modulerc 0
98 HOOK before-modulerc-eval $mp/puts/.modulerc puts/.modulerc"]
99 append tserr {(\n.*)*}
100 append tserr [escre "HOOK after-modulerc-eval $mp/puts/.modulerc puts/.modulerc 1"]
101 set ans [list]
102 lappend ans [list set __MODULES_LMALTNAME puts/2&as|puts/default&as|puts/latest]
103 lappend ans [list set _LMFILES_ $mp/puts/2]
104 lappend ans [list set LOADEDMODULES puts/2]
105 testouterr_cmd_re sh {load puts/2} [shell_out sh $ans] $tserr
106
107 setenv_loaded_module [list puts/2] [list $mp/puts/2]
108 unsetenv_loaded_module
109 unsetenv_var __MODULES_LMALTNAME
110
111 unsetenv_var TESTSUITE_PUTS
112 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
113
114
115 # several procedures registered on the same event are called in their
116 # registration order
117 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK multiple
118 set tserr "HOOK1 foo/2.0
119 HOOK2 foo/2.0"
120 set ans [list]
121 lappend ans [list set _LMFILES_ $mp/foo/2.0]
122 lappend ans [list set LOADEDMODULES foo/2.0]
123 testouterr_cmd sh {load foo/2.0} $ans $tserr
124 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
125
126
127 # an error raised by a hook procedure is reported but does not prevent the
128 # other procedures registered on the same event from running, nor the
129 # wrapped modulefile evaluation from proceeding
130 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK error
131 set tserr [escre "HOOK survived after error for foo/2.0
132
133 Loading foo/2.0
134 ERROR: Hook procedure 'testsuite_hook_error' registered on<EXM>'before-modulefile-eval' event failed
135 hook failure for foo/2.0"]
136 append tserr {(\n.*)*}
137 set ans [list]
138 lappend ans [list set _LMFILES_ $mp/foo/2.0]
139 lappend ans [list set LOADEDMODULES foo/2.0]
140 lappend ans [list ERR]
141 testouterr_cmd_re sh {load foo/2.0} [shell_out sh $ans] $tserr
142 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
143
144
145 # a registered hook procedure declared with fewer arguments than the event
146 # provides is reported as a wrong-number-of-arguments error, non-fatally
147 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK arity_missing
148 set tserr [escre "Loading foo/2.0
149 ERROR: Hook procedure 'testsuite_hook_arity_missing' registered on<EXM>'before-modulefile-eval' event failed
150 wrong # args: should be \"testsuite_hook_arity_missing modfile\
151 modname\""]
152 append tserr {(\n.*)*}
153 set ans [list]
154 lappend ans [list set _LMFILES_ $mp/foo/2.0]
155 lappend ans [list set LOADEDMODULES foo/2.0]
156 lappend ans [list ERR]
157 testouterr_cmd_re sh {load foo/2.0} [shell_out sh $ans] $tserr
158 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
159
160
161 # a registered hook procedure declared with more (required) arguments than
162 # the event provides is reported as a wrong-number-of-arguments error,
163 # non-fatally
164 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK arity_extra
165 set tserr [escre "Loading foo/2.0
166 ERROR: Hook procedure 'testsuite_hook_arity_extra' registered on<EXM>'before-modulefile-eval' event failed
167 wrong # args: should be"]
168 append tserr {.*(\n.*)*}
169 set ans [list]
170 lappend ans [list set _LMFILES_ $mp/foo/2.0]
171 lappend ans [list set LOADEDMODULES foo/2.0]
172 lappend ans [list ERR]
173 testouterr_cmd_re sh {load foo/2.0} [shell_out sh $ans] $tserr
174 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
175
176
177 # a Tcl code issue (call to an undefined command) in a registered hook
178 # procedure is reported non-fatally, same as an explicit error
179 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK codeerror
180 set tserr [escre "Loading foo/2.0
181 ERROR: Hook procedure 'testsuite_hook_codeerror' registered on<EXM>'before-modulefile-eval' event failed
182 invalid command name \"testsuite_hook_undefined_command\""]
183 append tserr {(\n.*)*}
184 set ans [list]
185 lappend ans [list set _LMFILES_ $mp/foo/2.0]
186 lappend ans [list set LOADEDMODULES foo/2.0]
187 lappend ans [list ERR]
188 testouterr_cmd_re sh {load foo/2.0} [shell_out sh $ans] $tserr
189 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
190
191
192 # an error raised by the second registered procedure does not undo the
193 # result (its report output) already produced by the first registered
194 # procedure
195 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK error_second
196 set tserr [escre "HOOK1 ok for foo/2.0
197
198 Loading foo/2.0
199 ERROR: Hook procedure 'testsuite_hook_second_error' registered on<EXM>'before-modulefile-eval' event failed
200 second hook failure for foo/2.0"]
201 append tserr {(\n.*)*}
202 set ans [list]
203 lappend ans [list set _LMFILES_ $mp/foo/2.0]
204 lappend ans [list set LOADEDMODULES foo/2.0]
205 lappend ans [list ERR]
206 testouterr_cmd_re sh {load foo/2.0} [shell_out sh $ans] $tserr
207 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
208
209
210 #
211 # hooks fire with the correct 'mode' argument across the different module
212 # evaluation modes, on both a successful and a failing evaluation
213 #
214
215 set sepline [string repeat - 67]
216 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK modulefile
217
218 # help, successful evaluation (mode help, requested)
219 set tserr "$sepline
220 Module Specific Help for $mp/foo/2.0:
221
222 HOOK before-modulefile-eval $mp/foo/2.0 foo/2.0 foo/2.0 foo/2.0 help 1
223 WARNING: Unable to find ModulesHelp in $mp/foo/2.0.
224 HOOK after-modulefile-eval $mp/foo/2.0 foo/2.0 foo/2.0 foo/2.0 help 1 0
225 $sepline"
226 testouterr_cmd sh {help foo/2.0} OK $tserr
227
228 # display, successful evaluation (mode display, requested)
229 set tserr "$sepline
230 $mp/foo/2.0:
231
232 HOOK before-modulefile-eval $mp/foo/2.0 foo/2.0 foo/2.0 foo/2.0 display 1
233 HOOK after-modulefile-eval $mp/foo/2.0 foo/2.0 foo/2.0 foo/2.0 display 1 0
234 $sepline"
235 testouterr_cmd sh {display foo/2.0} OK $tserr
236
237 # show, successful evaluation (same as display, mode display, requested)
238 testouterr_cmd sh {show foo/2.0} OK $tserr
239
240 # whatis, successful evaluation (mode whatis, not requested)
241 set tserr "HOOK before-modulefile-eval $mp/foo/2.0 foo/2.0 foo/2.0 foo/2.0\
242 whatis 0
243 HOOK after-modulefile-eval $mp/foo/2.0 foo/2.0 foo/2.0 foo/2.0 whatis 0 0"
244 testouterr_cmd sh {whatis foo/2.0} OK $tserr
245
246 # search, successful evaluation (mode whatis, not requested); search
247 # evaluates every module in the modulepath so only check the lines
248 # relating to the targeted module are present, tolerating the rest
249 set tserr [escre "HOOK before-modulefile-eval $mp/foo/2.0 foo/2.0 foo/2.0\
250 foo/2.0 whatis 0
251 HOOK after-modulefile-eval $mp/foo/2.0 foo/2.0 foo/2.0 foo/2.0 whatis 0 0"]
252 testouterr_cmd_re sh {search foo/2.0} {.*} "(.*\n)*${tserr}(\n.*)*"
253
254 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
255
256
257 # for the failing evaluation checks below, only the before-hook line and
258 # the after-hook line with its status are matched exactly; the internal
259 # Tcl error text in between (whose formatting/indentation differs depending
260 # on whether the command holds its output for later display) is tolerated
261 # with a wildcard, as it is already covered by dedicated non-hook tests
262 # elsewhere in the testsuite
263
264 # help, failing evaluation (status 1, overall command fails)
265 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK modulefile
266 setenv_var TESTSUITE_ABORT_ON_ERROR error
267 set tserr [escre "$sepline
268 Module Specific Help for $mp/err/1.0:
269
270 HOOK before-modulefile-eval $mp/err/1.0 err/1.0 err/1.0 err/1.0 help 1"]
271 append tserr {.*(\n.*)*}
272 append tserr [escre "HOOK after-modulefile-eval $mp/err/1.0 err/1.0 err/1.0\
273 err/1.0 help 1 1
274 $sepline"]
275 testouterr_cmd_re sh {help err/1.0} ERR $tserr
276
277 # display, failing evaluation (status 1, overall command fails)
278 set tserr [escre "$sepline
279 $mp/err/1.0:
280
281 HOOK before-modulefile-eval $mp/err/1.0 err/1.0 err/1.0 err/1.0 display 1"]
282 append tserr {.*(\n.*)*}
283 append tserr [escre "HOOK after-modulefile-eval $mp/err/1.0 err/1.0 err/1.0\
284 err/1.0 display 1 1
285 $sepline"]
286 testouterr_cmd_re sh {display err/1.0} ERR $tserr
287
288 # show, failing evaluation (same as display)
289 testouterr_cmd_re sh {show err/1.0} ERR $tserr
290
291 # whatis, failing evaluation (status 1, but overall command still succeeds)
292 set tserr [escre\
293 "HOOK before-modulefile-eval $mp/err/1.0 err/1.0 err/1.0 err/1.0 whatis 0"]
294 append tserr {.*(\n.*)*}
295 append tserr [escre\
296 "HOOK after-modulefile-eval $mp/err/1.0 err/1.0 err/1.0 err/1.0 whatis 0\
297 1"]
298 testouterr_cmd_re sh {whatis err/1.0} {} $tserr
299
300 # search, failing evaluation (status 1, overall command still succeeds);
301 # only check the lines relating to the targeted module are present
302 set tserr [escre\
303 "HOOK before-modulefile-eval $mp/err/1.0 err/1.0 err/1.0 err/1.0 whatis 0"]
304 append tserr {.*(\n.*)*}
305 append tserr [escre\
306 "HOOK after-modulefile-eval $mp/err/1.0 err/1.0 err/1.0 err/1.0 whatis 0\
307 1"]
308 testouterr_cmd_re sh {search err/1.0} {.*} "(.*\n)*${tserr}(\n.*)*"
309
310 unsetenv_var TESTSUITE_ABORT_ON_ERROR
311 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
312
313
314 #
315 # scan mode: modulefiles evaluated during an extra-match search triggered
316 # by a variant-aware avail query
317 #
318
319 setenv_var MODULES_ADVANCED_VERSION_SPEC 1
320 setenv_var MODULES_AVAIL_INDEPTH 1
321 setenv_var MODULES_AVAIL_TERSE_OUTPUT alias:dirwsym:sym:tag:variant
322 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK modulefile
323
324 # avail listing itself is written to stderr, not stdout, like the hook
325 # messages, so both are checked together as anserr, in the order they are
326 # produced: hook messages first, then the listing
327 set listing "scan/1.0\nscan/1.1\nscan/2.0\{foo=val1,val2,val3\}\n"
328 append listing "scan/2.1\{foo=val1,val2,val3\}"
329
330 # successful scan evaluation (mode scan, not requested)
331 setenv_var TESTSUITE_SCAN hooktest
332 set tserr "HOOK before-modulefile-eval $mp/scan/1.0 scan/1.1 scan/1.1\
333 scan/1.1 scan 0
334 HOOK after-modulefile-eval $mp/scan/1.0 scan/1.1 scan/1.1 scan/1.1 scan 0 0
335 HOOK before-modulefile-eval $mp/scan/2.0 scan/2.0 scan/2.0 scan/2.0 scan 0
336 HOOK after-modulefile-eval $mp/scan/2.0 scan/2.0 scan/2.0 scan/2.0 scan 0 0
337 HOOK before-modulefile-eval $mp/scan/2.0 scan/2.1 scan/2.1 scan/2.1 scan 0
338 HOOK after-modulefile-eval $mp/scan/2.0 scan/2.1 scan/2.1 scan/2.1 scan 0 0
339 HOOK before-modulefile-eval $mp/scan/1.0 scan/1.0 scan/1.0 scan/1.0 scan 0
340 HOOK after-modulefile-eval $mp/scan/1.0 scan/1.0 scan/1.0 scan/1.0 scan 0 0
341 $listing"
342 testouterr_cmd sh {avail -t scan} {} $tserr
343 unsetenv_var TESTSUITE_SCAN
344
345 # failing scan evaluation (status 1, but errors are silently inhibited and
346 # overall command still succeeds, consistent with scan mode tolerating
347 # broken modulefiles during a background scan)
348 setenv_var TESTSUITE_SCAN unk1
349 set tserr "HOOK before-modulefile-eval $mp/scan/1.0 scan/1.1 scan/1.1\
350 scan/1.1 scan 0
351 HOOK after-modulefile-eval $mp/scan/1.0 scan/1.1 scan/1.1 scan/1.1 scan 0 1
352 HOOK before-modulefile-eval $mp/scan/2.0 scan/2.0 scan/2.0 scan/2.0 scan 0
353 HOOK after-modulefile-eval $mp/scan/2.0 scan/2.0 scan/2.0 scan/2.0 scan 0 0
354 HOOK before-modulefile-eval $mp/scan/2.0 scan/2.1 scan/2.1 scan/2.1 scan 0
355 HOOK after-modulefile-eval $mp/scan/2.0 scan/2.1 scan/2.1 scan/2.1 scan 0 0
356 HOOK before-modulefile-eval $mp/scan/1.0 scan/1.0 scan/1.0 scan/1.0 scan 0
357 HOOK after-modulefile-eval $mp/scan/1.0 scan/1.0 scan/1.0 scan/1.0 scan 0 1
358 $listing"
359 testouterr_cmd sh {avail -t scan} {} $tserr
360 unsetenv_var TESTSUITE_SCAN
361
362 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
363 unsetenv_var MODULES_ADVANCED_VERSION_SPEC
364 unsetenv_var MODULES_AVAIL_INDEPTH
365 unsetenv_var MODULES_AVAIL_TERSE_OUTPUT
366
367
368 # before/after-modulefile-eval hooks also fire for the global and user RC
369 # files sourced ahead of the requested module: these files are evaluated
370 # through execute-modulefile (mode load), not execute-modulerc, same as any
371 # other modulefile passed to the 'source' sub-command
372 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK modulefile
373 setenv_var MODULERCFILE "$env(TESTSUITEDIR)/etc/modulerc:$env(TESTSUITEDIR)/etc/rc"
374
375 set globalrc $env(TESTSUITEDIR)/etc/modulerc
376 set userrc $env(TESTSUITEDIR)/etc/rc
377 set tserr "HOOK before-modulefile-eval $globalrc $globalrc $globalrc\
378 $globalrc load 1
379 HOOK after-modulefile-eval $globalrc $globalrc $globalrc $globalrc load 1 0
380 HOOK before-modulefile-eval $userrc $userrc $userrc $userrc load 1
381 HOOK after-modulefile-eval $userrc $userrc $userrc $userrc load 1 0
382 HOOK before-modulefile-eval $mp/foo/2.0 foo/2.0 foo/2.0 foo/2.0 load 1
383 HOOK after-modulefile-eval $mp/foo/2.0 foo/2.0 foo/2.0 foo/2.0 load 1 0"
384 set ans [list]
385 lappend ans [list set _LMFILES_ $mp/foo/2.0]
386 lappend ans [list set LOADEDMODULES foo/2.0]
387 testouterr_cmd sh {load foo/2.0} $ans $tserr
388
389 unsetenv_var MODULERCFILE
390 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
391
392
393 # hooks fire with the resolved variant specification in modnamevr while
394 # modname stays the bare module name
395 set mp3 $modpath.3
396 setenv_path_var MODULEPATH $mp3
397 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK modulefile
398 setenv_var TESTSUITE_VARIANT_TAG default
399
400 set tserr "HOOK before-modulefile-eval $mp3/variant/8.0 variant/8.0\
401 variant/8.0 foo=val1 variant/8.0 foo=val1 load 1
402 HOOK after-modulefile-eval $mp3/variant/8.0 variant/8.0 variant/8.0\
403 foo=val1 variant/8.0 foo=val1 load 1 0"
404 set ans [list]
405 lappend ans [list set __MODULES_LMVARIANT\
406 variant/8.0&foo|val1|0|0&bar|2|0|2]
407 lappend ans [list set _LMFILES_ $mp3/variant/8.0]
408 lappend ans [list set LOADEDMODULES variant/8.0]
409 testouterr_cmd sh {load variant/8.0 foo=val1} $ans $tserr
410
411 unsetenv_var TESTSUITE_VARIANT_TAG
412 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
413 setenv_path_var MODULEPATH $mp
414
415
416 #
417 # validate the add-hook examples given in the module.rst documentation
418 #
419
420 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK docexamples
421
422 # auditRequestedLoad-equivalent example only reports on a directly
423 # requested load, and the hook_procedure-equivalent example successfully
424 # defines MYVAR through the modulefile interpreter, proving a
425 # before-modulefile-eval hook can now reach it (it fires after the
426 # interpreter has been created and reset)
427 set tserr {would audit: foo/2.0}
428 set ans [list]
429 lappend ans [list set _LMFILES_ $mp/foo/2.0]
430 lappend ans [list set LOADEDMODULES foo/2.0]
431 lappend ans [list set MYVAR value]
432 testouterr_cmd sh {load foo/2.0} $ans $tserr
433
434 # not a direct load request: neither example produces anything
435 testouterr_cmd sh {whatis foo/2.0} OK {}
436
437 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
438
439
440 # the "Advanced hooks" blockModule example rejects loading foo/1.0
441 # specifically, through a low-level trace add-hook cannot express, while
442 # leaving every other module -- including foo/1.0 itself in a listing --
443 # unaffected
444 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK blockmodule
445
446 set tserr [escre "Loading foo/1.0
447 ERROR: foo/1.0 is blocked by site policy"]
448 append tserr {(\n.*)*}
449 testouterr_cmd_re sh {load foo/1.0} ERR $tserr
450
451 set ans [list]
452 lappend ans [list set _LMFILES_ $mp/foo/2.0]
453 lappend ans [list set LOADEDMODULES foo/2.0]
454 testouterr_cmd sh {load foo/2.0} $ans {}
455
456 set ans "$mp:\nfoo/1.0\nfoo/2.0\nfoo/9.0"
457 testouterr_cmd sh {avail -t foo} OK $ans
458
459 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
460
461
462 # modulerc hooks do not fire for the global/user RC files sourced ahead of
463 # a requested module (see the before/after-modulefile-eval hooks test
464 # above, which shows those same files instead trigger the modulefile
465 # events): only the modulerc hooks for the real .modulerc files resolved
466 # under the modulepath are produced
467 setenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK modulerc
468 setenv_var MODULERCFILE "$env(TESTSUITEDIR)/etc/modulerc:$env(TESTSUITEDIR)/etc/rc"
469
470 set tserr "HOOK before-modulerc-eval $mp/.modulerc .modulerc
471 HOOK after-modulerc-eval $mp/.modulerc .modulerc 0
472 HOOK before-modulerc-eval $mp/puts/.modulerc puts/.modulerc
473 HOOK after-modulerc-eval $mp/puts/.modulerc puts/.modulerc 0"
474 set ans [list]
475 lappend ans [list set __MODULES_LMALTNAME puts/2&as|puts/default&as|puts/latest]
476 lappend ans [list set _LMFILES_ $mp/puts/2]
477 lappend ans [list set LOADEDMODULES puts/2]
478 testouterr_cmd sh {load puts/2} $ans $tserr
479
480 setenv_loaded_module [list puts/2] [list $mp/puts/2]
481 unsetenv_loaded_module
482 unsetenv_var __MODULES_LMALTNAME
483
484 unsetenv_var MODULERCFILE
485 unsetenv_var TESTSUITE_ENABLE_SITECONFIG_HOOK
486
487 } elseif {$verbose} {
488 send_user "\tSkip tests relying on an excepted siteconfig file installed\n"
489 }
490
491
492 #
493 # Cleanup
494 #
495
496 reset_test_env