Debian Codegraph @

testsuite/modules.00-init/005-init_ts.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.00-init/%M%
6 # Revision: %I%
7 # First Edition: 95/12/06
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Jens Hamisch, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command:
14 # Sub-Command:
15 #
16 # Comment: %C{
17 # This module defines all patterns used further in the
18 # testsuite
19 # }C%
20 #
21 ##############################################################################
22
23 #
24 # Check setup
25 #
26
27 send_user "\tInitializing the testsuite ...\n"
28
29 # excepted information to run the testsuite
30 set TCLSH $env(TCLSH)
31 send_user "\tTCLSH is '$TCLSH'\n"
32 set MODULECMD $env(MODULECMD)
33 send_user "\tMODULECMD is '$MODULECMD'\n"
34
35
36 # Modules release number
37 set major_minor_rel [join [lrange [split $install_version .] 0 1] .]
38
39 set cache_mcookie_version 5.3
40
41 # test kind of sh-shell we have
42 if {[file type /bin/sh] eq {link}} {
43 set sh_kind [file readlink /bin/sh]
44 } else {
45 set sh_kind sh
46 }
47
48 # extract and format os name
49 set os_name [string tolower [lindex [split $tcl_platform(os) _] 0]]
50
51 # get current terminal width
52 proc getTtyCols {} {
53 set nbcols {}
54
55 switch -- $::os_name {
56 {sunos} {
57 catch {regexp {columns = (\d+);} [exec stty] match nbcols} errMsg
58 }
59 default {
60 catch {set nbcols [lindex [exec stty size] 1]} errMsg
61 }
62 }
63 return $nbcols
64 }
65 set nbcols [getTtyCols]
66 if {$nbcols ne {} && $nbcols ne {0}} {
67 set term_cols $nbcols
68 set msg_disp_cols $nbcols
69 send_user "\tTerminal has $msg_disp_cols columns\n"
70 } else {
71 send_user "\tFail to detect terminal column number.\n"
72 if {[catch {exec stty rows 60 cols 120} errMsg]} {
73 send_user "\tFail to set specific terminal size: $errMsg\n"
74 set msg_disp_cols 80
75 send_user "\tFallback to $msg_disp_cols columns\n"
76 } else {
77 set term_cols 120
78 set msg_disp_cols 120
79 send_user "\tSuccessfully set terminal to 120 columns.\n"
80 }
81 }
82 unset nbcols
83
84 proc find_bin {name} {
85 set path {}
86
87 if {[info exists ::env(PATH)]} {
88 foreach dir [split $::env(PATH) ":"] {
89 if {[file executable "$dir/$name"]} {
90 set path "$dir/$name"
91 break
92 }
93 }
94 }
95
96 return $path
97 }
98
99 # check SIP is enabled or not on OS X
100 if {$os_name eq "darwin"} {
101 catch {
102 regexp {System Integrity Protection status: enabled.} [exec csrutil status] csrutil_enabled
103 } errMsg
104 }
105 if {[info exists csrutil_enabled]} {
106 set sip_enabled 1
107 unset csrutil_enabled
108 } else {
109 set sip_enabled 0
110 }
111
112 # grab fish shell version to check if greater or equal to 3.1
113 if {[set fishbin [lindex [auto_execok fish] 0]] ne {}} {
114 regexp {version (.+)$} [exec $fishbin --version] match fish_version
115 set fish_version_ge31 [expr {[lindex [lsort -dictionary [list $fish_version 3.1.0]] 0] eq {3.1.0}}]
116 set fish_version_ge32 [expr {[lindex [lsort -dictionary [list $fish_version 3.2.0]] 0] eq {3.2.0}}]
117 set fish_version_ge40 [expr {[lindex [lsort -dictionary [list $fish_version 4.0.0]] 0] eq {4.0.0}}]
118 }
119
120 # find ksh flavor
121 if {[set kshbin [lindex [auto_execok ksh] 0]] ne {}} {
122 set ksh_is_mksh [expr {[string first MIRBSD [exec -ignorestderr $kshbin -c "echo \$KSH_VERSION"]] != -1}]
123 } else {
124 set ksh_is_mksh 0
125 }
126
127 # is FPATH set during autoinit for zsh shell
128 set install_setzshfpath [expr {$install_zshcompletiondir eq {} ? {y} : {n}}]
129 if {$install_setzshfpath eq {y}} {
130 set install_zshcompletiondir $install_initdir/zsh-functions
131 }
132
133 # env_modules python module is installed in initdir if no specific location
134 if {$install_pythondir eq {}} {
135 set install_pythondir $install_initdir
136 }
137
138 # locate siteconfig file
139 set siteconfig_file "$install_etcdir/siteconfig.tcl"
140 set siteconfig_filere [regsub -all "\(\[.+?\]\)" $siteconfig_file {\\\1}]
141
142 # determine if siteconfig forces stderr terminal attachment state
143 proc siteconfig_isStderrTty {} {
144 interp create _siteconfig
145 interp eval _siteconfig set ::siteconfig_file "{$::siteconfig_file}"
146 set is_stderr_tty [interp eval _siteconfig {
147 set is_stderr_tty 0
148 if {[file readable $::siteconfig_file]} {
149 # evaluate siteconfig file to check initStateIsStderrTty procedure
150 catch {
151 source $::siteconfig_file
152 if {[info procs initStateIsStderrTty] eq "initStateIsStderrTty"} {
153 set is_stderr_tty [initStateIsStderrTty]
154 }
155 } errorMsg
156 }
157 return $is_stderr_tty
158 }]
159 interp delete _siteconfig
160 return $is_stderr_tty
161 }
162
163 # determine if stdin is attached to a tty
164 set is_stdin_tty [expr {![catch {fconfigure stdin -mode}]}]
165
166 # locate Modules Tcl extension library used during testsuite
167 if {$install_libtclenvmodules eq {y}} {
168 set tclextlib_file lib/libtclenvmodules$install_shlib_suffix
169 set closedirlib_file lib/libtestutil-closedir$install_shlib_suffix
170 set getpwuidlib_file lib/libtestutil-getpwuid$install_shlib_suffix
171 set getgroupslib_file lib/libtestutil-getgroups$install_shlib_suffix
172 set 0getgroupslib_file lib/libtestutil-0getgroups$install_shlib_suffix
173 set dupgetgroupslib_file lib/libtestutil-dupgetgroups$install_shlib_suffix
174 set timelib_file lib/libtestutil-time$install_shlib_suffix
175 set mktimelib_file lib/libtestutil-mktime$install_shlib_suffix
176 set tcl_loadfilelib_file lib/libtestutil-tcl_loadfile$install_shlib_suffix
177 }
178
179 # check file permission capabilities
180 set test_perms_dir "$env(TESTSUITEDIR)/etc"
181 set test_perms_file "$test_perms_dir/modulerc"
182 set orig_perms [file attributes $test_perms_dir -permissions]
183 catch {file attributes $test_perms_dir -permissions "ugo-rx"}
184 set new_perms [file attributes $test_perms_dir -permissions]
185 if {$new_perms eq $orig_perms} {
186 set is_file_perms_editable 0
187 } else {
188 set is_file_perms_editable 1
189
190 # check if file is readable in a locked directory
191 if {[catch {
192 set fid [open $test_perms_file r]
193 close $fid
194 }]} {
195 set is_locked_dir_file_readable 0
196 } else {
197 set is_locked_dir_file_readable 1
198 }
199 file attributes $test_perms_dir -permissions $orig_perms
200
201 # check if file is still readable if locked
202 set orig_perms [file attributes $test_perms_file -permissions]
203 file attributes $test_perms_file -permissions "ugo-rx"
204 if {[catch {
205 set fid [open $test_perms_file r]
206 close $fid
207 }]} {
208 set is_locked_file_readable 0
209 } else {
210 set is_locked_file_readable 1
211 }
212 file attributes $test_perms_file -permissions $orig_perms
213 }
214 unset test_perms_dir
215 unset test_perms_file
216 unset orig_perms
217 unset new_perms
218
219 # check if module command is defined prior running tests
220 set is_modules_defined [expr {![catch {exec $env(TESTSUITEDIR)/is_func_defined module}]}]
221 set is_modules_defined_fish [expr {![catch {exec $env(TESTSUITEDIR)/is_func_defined.fish module}]}]
222 send_user "\tModules is defined in SH env prior tests: $is_modules_defined\n"
223 send_user "\tModules is defined in FISH env prior tests: $is_modules_defined_fish\n"
224 set is_mogui_defined [expr {![catch {exec $env(TESTSUITEDIR)/is_func_defined mogui}]}]
225 set is_mogui_defined_fish [expr {![catch {exec $env(TESTSUITEDIR)/is_func_defined.fish mogui}]}]
226 send_user "\tMoGui is defined in SH env prior tests: $is_mogui_defined\n"
227 send_user "\tMoGui is defined in FISH env prior tests: $is_mogui_defined_fish\n"
228
229 # check if symbolic link registered in git repository have been effectively
230 # created as symbolic link to determine if they are supported on filesystem
231 set is_symlink_supported [file isdirectory $env(TESTSUITEDIR)/modulefiles/symlink]
232
233 # check if underlying filesystem is case-insensitive
234 set is_filesystem_icase [file exists $env(TESTSUITEDIR)/modulefiles.2/ICASE/prereq]
235
236 set is_global_rc_file [file isfile $install_etcdir/rc]
237 send_user "\tGlobal RC file is [expr {$is_global_rc_file ? {present} : {absent}}]\n"
238
239 # check x11 capabilities
240 # check where to find the 'xrdb' binary on this system
241 set xrdb_notfound_msg {Command 'xrdb' cannot be found}
242 set xrdb [auto_execok xrdb]
243 if {![string length $xrdb]} {
244 set is_xrdb_avail 0
245 set xrdb_issue_msg $xrdb_notfound_msg
246 } elseif {[catch {exec $xrdb -query} errMsg]} {
247 set is_xrdb_avail 0
248 set xrdb_issue_msg $errMsg
249 } else {
250 set is_xrdb_avail 1
251 set xrdb_issue_msg $xrdb_notfound_msg
252 }
253 send_user "\tX11 setup is [expr {$is_xrdb_avail ? {KO} : {OK}}]\n"
254
255 # check if domainname binary is available on this system
256 set domainname [auto_execok $install_domainname]
257
258 # ensure id command is run with POSIX locale to correctly parse it
259 if {[info exists ::env(LANG)]} {
260 set ORIG_LANG $::env(LANG)
261 }
262 set ::env(LANG) C
263 set idoutput [exec id]
264 if {[info exists ORIG_LANG]} {
265 set ::env(LANG) $ORIG_LANG
266 } else {
267 unset ::env(LANG)
268 }
269 send_user "\tid output is '$idoutput'\n"
270
271 # get current working directory
272 set ORIG_CWD [pwd]
273
274 # get current username and groups
275 set username [exec id -u -n]
276 set userid [exec id -u]
277 send_user "\tCurrent username is '$username'\n"
278
279 # generic group retrieval as -z option is not supported by id in some environment
280 # and using "-G -n" will produce an error in case the group name cannot be resolved
281 # here we parse the standard global output of id command
282 set usergroups {}
283 set id_out_grp_start [expr {[string first {groups=} $idoutput] + 7}]
284 set id_out_next_start [string first = $idoutput $id_out_grp_start]
285 if {$id_out_next_start > -1} {
286 set id_out_grp_end [expr {[string last { } $idoutput $id_out_next_start] - 1}]
287 } else {
288 set id_out_grp_end end
289 }
290 set id_grp_output [string range $idoutput $id_out_grp_start $id_out_grp_end]
291 foreach grp_info [split $id_grp_output ,] {
292 if {[set idx [string first ( $grp_info]] != -1} {
293 set grp [string range $grp_info $idx+1 end-1]
294 } else {
295 set grp $grp_info
296 }
297 lappend usergroups $grp
298 }
299 set usergroups [lsort $usergroups]
300 send_user "\tGroups of current user are '$usergroups'\n"
301 set userfgroup [lindex $usergroups 0]
302
303 set sudo [auto_execok sudo]
304 set is_sudo_supported 0
305 if {[string length $sudo]} {
306 if {![catch {exec $sudo -n -E true} errMsg]} {
307 set is_sudo_supported 1
308 }
309 }
310 send_user "\tCall to sudo command is [expr {$is_sudo_supported ? { } : {not }}]supported\n"
311
312 set setpriv [auto_execok setpriv]
313 set setpriv_call {}
314 if {[string length $setpriv]} {
315 if {$tcl_platform(user) eq {root}} {
316 set setpriv_call [list $setpriv]
317 } elseif {$is_sudo_supported} {
318 set setpriv_call [list $sudo -n -E $setpriv]
319 }
320 }
321 send_user "\tCall setpriv command with '$setpriv_call'\n"
322
323
324 set is_mogui_avail [string length [lindex [auto_execok mogui-cmd] 0]]
325
326 # Dictionary-style string comparison
327 # Use dictionary sort of lsort proc to compare two strings in the "string
328 # compare" fashion (returning -1, 0 or 1). Tcl dictionary-style comparison
329 # enables to compare software versions (ex: "1.10" is greater than "1.8")
330 proc cmpversion {str1 str2} {
331 if {$str1 eq $str2} {
332 return 0
333 # put both strings in a list, then lsort it and get first element
334 } elseif {[lindex [lsort -dictionary [list $str1 $str2]] 0] eq $str1} {
335 return -1
336 } else {
337 return 1
338 }
339 }
340
341 # report current system information
342 send_user "\tMachine hardware name is '$tcl_platform(machine)'\n"
343 send_user "\tOS code name is '$tcl_platform(os)'\n"
344 send_user "\tOS cleaned name is '$os_name'\n"
345 send_user "\tOS version is '$tcl_platform(osVersion)'\n"
346 send_user "\tPlatform name is '$tcl_platform(platform)'\n"
347
348 # report LSB information
349 set lsb_cmd [auto_execok lsb_release]
350 if {![string length $lsb_cmd]} {
351 send_user "\tNo 'lsb_release' command available\n"
352 set lsb_id {}
353 set lsb_codename {}
354 set lsb_release {}
355 } else {
356 set lsb_id [exec $lsb_cmd -s -i]
357 set lsb_codename [exec $lsb_cmd -s -c]
358 set lsb_release [exec $lsb_cmd -s -r]
359 send_user "\tLSB id is '$lsb_id'\n"
360 send_user "\tLSB release is '$lsb_release'\n"
361 send_user "\tLSB codename is '$lsb_codename'\n"
362 }
363
364 # fetch tclsh version used to adapt tests producing different output depending on this version
365 catch {set tclsh_version [exec $TCLSH << {puts [info tclversion]}]} errMsg
366 if {[info exists tclsh_version]} {
367 send_user "\ttclsh version is $tclsh_version\n"
368 } else {
369 set tclsh_version 8.6
370 send_user "\tFail to detect tclsh version. Fallback to $tclsh_version version\n$errMsg"
371 }
372
373 # does configured pager tool allow for pagination
374 set pager_dfl_use [expr {[file tail $install_pager] ni {{} cat}}]
375
376
377 #
378 # Regular expressions matching error and warning outputs
379 #
380
381 set messages "(\[^(\]+)\[(\]\[0-9\]+\[)\]"
382 set error_msgs "ERROR"
383 set warn_msgs "WARNING"
384 set prob_msgs "$messages:PROB:\[0-9\]+"
385 set verb_msgs "$messages:VERB:\[0-9\]+"
386 set moderr_msgs "Module $error_msgs"
387 set modwarn_msgs "Module $warn_msgs"
388 set cacheerr_msgs "Cache $error_msgs"
389 set info_msgs "INFO"
390 set timer_msgs TIMER
391
392 # Used as a line separator inside modules
393 set modlin "\[-\]+"
394 set sep_line [string repeat - 67]
395
396 # List of supported shells
397 set sh_shells [list sh bash ksh zsh]
398 set csh_shells [list csh tcsh]
399 set real_shells [concat $sh_shells $csh_shells [list fish]]
400 set other_shells [list tcl cmd perl python ruby lisp cmake r pwsh]
401 set supported_shells [concat $real_shells $other_shells]
402
403 # Common messages
404 set vers_reportre {Modules Release [0-9a-zA-Z\.\+\-_/]+ \([0-9\-]{10}\)}
405 set no_loaded {No Modulefiles Currently Loaded.}
406 set no_matchingloaded {No Matching Modulefiles Currently Loaded.}
407 set cur_loaded {Currently Loaded Modulefiles:}
408 set cur_matchingloaded {Currently Loaded Matching Modulefiles:}
409 set msg_invcmdname {invalid command name}
410 set msg_patheqsep {cannot handle path equals to separator string}
411 set msg_multipatheqsep {cannot handle multiple paths equal to separator string}
412 set msg_needenvvarname {should get an environment variable name}
413 set msg_needenvvarval {should get a value for environment variable}
414 set msg_validenvvarname {should get a valid environment variable name}
415 set msg_valididxvalue {should get valid number as index value}
416 set msg_nonemptydelim {should get a non-empty path delimiter}
417 set msg_nomodnameinarg {No module name defined in argument}
418 set msg_invversspec {Invalid version specifier}
419 set msg_filenameempty {File name empty}
420 set msg_collnameempty {Invalid empty collection name}
421 set msg_nomodpath {No module path defined}
422 set msg_nomodloaded {No module has been loaded}
423 set datetimere {[0-9/]{10} [0-9:]{8}}
424 set avail_long_headerre "- Package/Alias $modlin.- Versions $modlin.- Last mod. $modlin"
425 set list_long_headerre "- Package $modlin.- Versions $modlin.- Last mod. $modlin"
426 set savelist_long_headerre "- Collection $modlin.- Last mod. $modlin"
427
428 # Common error responses
429 set err_path "$error_msgs: Unable to locate a modulefile for "
430 set err_file "$error_msgs: No such file or directory on "
431 set warn_file "$warn_msgs: No such file or directory on "
432 set err_illdir "$error_msgs: [expr {[cmpversion $tclsh_version 9.0] > -1 ? {Is} : {Illegal operation on}}] a directory on "
433 set err_notadir "$error_msgs: Not a directory on "
434 set err_nomodpath "$error_msgs: $msg_nomodpath"
435 set err_magicns "$moderr_msgs: Magic cookie '#%Module' missing\nIn "
436 set err_magic "$moderr_msgs: Magic cookie '#%Module' missing\n In "
437 set err_magivnovers "$moderr_msgs: Modules version requirement missing\n In "
438 set err_contactns "Please contact <root@localhost>"
439 set err_contact " $err_contactns"
440 set err_typehelp " Try 'module --help' for more information."
441 set err_loinconsist "$error_msgs: Loaded environment state is inconsistent"
442 set err_emptymodname "$error_msgs: Invalid empty module name"
443 set err_emptycollname "$error_msgs: $msg_collnameempty"
444 set err_emptydirname "$error_msgs: Invalid empty directory name"
445 set err_emptyfilename "$error_msgs: $msg_filenameempty"
446 set err_unsatreload "$error_msgs: Cannot reload modules, some of their constraints are not satisfied"
447 set err_nodefault "$error_msgs: No default version defined for "
448 set err_evalabort "$error_msgs: Module evaluation aborted"
449 set warn_evalabort "$warn_msgs: Module evaluation aborted"
450 set err_specmodname "$error_msgs: $msg_nomodnameinarg "
451 set err_specvers "$error_msgs: $msg_invversspec "
452 set err_rangevers "$error_msgs: Invalid version range "
453 set err_stickyunload "$::error_msgs: Unload of sticky module skipped"
454 set warn_stickyunload "$::warn_msgs: Unload of sticky module skipped"
455 set err_stickyunloadf "$::warn_msgs: Unload of sticky module forced"
456 set err_superstickyunload "$::error_msgs: Unload of super-sticky module skipped"
457 set warn_superstickyunload "$::warn_msgs: Unload of super-sticky module skipped"
458 set err_stickyrequnload "$::error_msgs: Unload of sticky module requirement\
459 skipped"
460 set warn_stickyrequnload "$::warn_msgs: Unload of sticky module requirement\
461 skipped"
462 set err_superstickyrequnload "$::error_msgs: Unload of super-sticky module\
463 requirement skipped"
464 set warn_superstickyrequnload "$::warn_msgs: Unload of super-sticky module\
465 requirement skipped"
466 set err_reqfull "$::error_msgs: Module version must be specified to load module"
467 set err_nomodloaded "$error_msgs: $msg_nomodloaded"
468 set err_modfromdiffpathloaded "$error_msgs: Module already loaded from a different modulepath"
469 set err_save_emptyenv "$::error_msgs: Nothing to save in a collection"
470 set err_save_unsat "$::error_msgs: Cannot save collection, some module constraints are not satisfied"
471 set warn_nostash "$::warn_msgs: No specific environment to save"
472 set warn_cache_nowritable "$::warn_msgs: Cannot remove cache file, directory is not writable"
473 set warn_cache_build_nowritable "$::warn_msgs: Cannot build cache file, directory is not writable"
474 set warn_cache_nothingtorec "$::warn_msgs: Nothing to record in cache file"
475 set warn_issue_logging "$::warn_msgs: Issue occurred when logging information"
476
477 set x11_warn_prefix "$error_msgs: X11 resources cannot be edited, issue spotted"
478 set xrdb_warn "$x11_warn_prefix\n$error_msgs: $xrdb_notfound_msg"
479 if {!$is_xrdb_avail} {
480 set x11_warn "$x11_warn_prefix\n$error_msgs: $xrdb_issue_msg"
481 }
482 set domainname_warn "$error_msgs: Command '$install_domainname' cannot be found"
483 set lsb_cmd_err "$error_msgs: Command 'lsb_release' cannot be found"
484
485
486 proc err_conflict {args} {
487 return "$::error_msgs: Module cannot be loaded due to a conflict.
488 HINT: Might try \"module unload [join $args { }]\" first."
489 }
490
491 proc err_conloi {args} {
492 set is [expr {[llength $args] > 1 ? {are} : {is}}]
493 return "$::error_msgs: Conflicting [join $args { and }] $is loading"
494 }
495
496 proc err_conloif {args} {
497 set is [expr {[llength $args] > 1 ? {are} : {is}}]
498 return "$::warn_msgs: Conflicting [join $args { and }] $is loading"
499 }
500
501 proc err_conlo {args} {
502 set is [expr {[llength $args] > 1 ? {are} : {is}}]
503 return "$::error_msgs: Conflicting [join $args { and }] $is loaded"
504 }
505
506 proc err_conlof {args} {
507 set is [expr {[llength $args] > 1 ? {are} : {is}}]
508 return "$::warn_msgs: Conflicting [join $args { and }] $is loaded"
509 }
510
511 proc err_conun {args} {
512 return "$::error_msgs: Unload of conflicting [join $args { and }] failed"
513 }
514
515 proc err_conunf {args} {
516 return "$::warn_msgs: Unload of conflicting [join $args { and }] failed"
517 }
518
519 proc err_prereq {args} {
520 return "$::error_msgs: Module cannot be loaded due to missing prereq.
521 HINT: the following module must be loaded first: [join $args]"
522 }
523
524 proc err_prereq_path {args} {
525 return "$::error_msgs: Module cannot be loaded due to missing prereq (specific path).
526 HINT: the following module must be loaded first: [join $args]"
527 }
528
529 proc err_prereqor {args} {
530 return "$::error_msgs: Module cannot be loaded due to missing prereq.
531 HINT: at least one of the following modules must be loaded first: $args"
532 }
533
534 proc err_prereqor_path {args} {
535 return "$::error_msgs: Module cannot be loaded due to missing prereq (specific path).
536 HINT: at least one of the following modules must be loaded first: $args"
537 }
538
539 proc err_prerequn {args} {
540 return "$::error_msgs: Module cannot be unloaded due to a prereq.
541 HINT: Might try \"module unload $args\" first."
542 }
543
544 proc err_deplo {args} {
545 set is [expr {[llength $args] > 1 ? {are} : {is}}]
546 return "$::error_msgs: Dependent [join $args { and }] $is loaded"
547 }
548
549 proc err_deploi {args} {
550 set is [expr {[llength $args] > 1 ? {are} : {is}}]
551 return "$::error_msgs: Dependent [join $args { and }] $is loading"
552 }
553
554 proc err_deplof {args} {
555 set is [expr {[llength $args] > 1 ? {are} : {is}}]
556 return "$::warn_msgs: Dependent [join $args { and }] $is loaded"
557 }
558
559 proc err_deploif {args} {
560 set is [expr {[llength $args] > 1 ? {are} : {is}}]
561 return "$::warn_msgs: Dependent [join $args { and }] $is loading"
562 }
563
564 proc err_reqlo {args} {
565 return "$::error_msgs: Load of requirement [join $args { or }] failed"
566 }
567
568 proc err_reqlo_path {args} {
569 return "$::error_msgs: Load of requirement [join $args { or }] (specific path) failed"
570 }
571
572 proc err_reqlof {args} {
573 return "$::warn_msgs: Load of requirement [join $args { or }] failed"
574 }
575
576 proc err_reqlof_path {args} {
577 return "$::warn_msgs: Load of requirement [join $args { or }] (specific path) failed"
578 }
579
580 proc err_reqmis {args} {
581 return "$::error_msgs: Requirement [join $args { or }] is not loaded"
582 }
583
584 proc err_reqmis_path {args} {
585 return "$::error_msgs: Requirement [join $args { or }] (specific path) is not loaded"
586 }
587
588 proc err_reqmisf {args} {
589 return "$::warn_msgs: Requirement [join $args { or }] is not loaded"
590 }
591
592 proc err_reqmisf_path {args} {
593 return "$::warn_msgs: Requirement [join $args { or }] (specific path) is not loaded"
594 }
595
596 proc err_depun {mod} {
597 return "$::error_msgs: Unload of dependent $mod failed"
598 }
599
600 proc err_depunf {mod} {
601 return "$::warn_msgs: Unload of dependent $mod failed"
602 }
603
604 proc err_urequn {mod} {
605 return "$::warn_msgs: Unload of useless requirement $mod failed"
606 }
607
608 proc err_depre {mod} {
609 return "$::error_msgs: Reload of dependent $mod failed"
610 }
611
612 proc err_depref {mod} {
613 return "$::warn_msgs: Reload of dependent $mod failed"
614 }
615
616 proc err_stickydepre {mod} {
617 return "$::error_msgs: Reload of sticky dependent $mod failed"
618 }
619
620 proc err_depreun {mod} {
621 return [err_depun $mod]
622 }
623
624 proc err_depreunf {mod} {
625 return [err_depunf $mod]
626 }
627
628 proc err_swoff {mod} {
629 return "$::error_msgs: Unload of switched-off $mod failed"
630 }
631
632 proc err_swon {mod} {
633 return "$::error_msgs: Load of switched-on $mod failed"
634 }
635
636 proc err_conflocked {option} {
637 return "$::error_msgs: Configuration option '$option' is locked"
638 }
639
640 proc moderr_minverreq {modfile minver} {
641 return "$::moderr_msgs: Modulefile requires at least Modules version $minver\n In '$modfile'\n$::err_contact"
642 }
643
644 proc moderr_minverreqns {modfile minver} {
645 return "$::moderr_msgs: Modulefile requires at least Modules version $minver\nIn '$modfile'\n$::err_contactns"
646 }
647
648 proc modwarn_minverreqns {modfile minver} {
649 return "$::modwarn_msgs: Modulefile requires at least Modules version $minver\nIn '$modfile'\n$::err_contactns"
650 }
651
652 proc collerr_minverreqns {collfile minver} {
653 return "$::error_msgs: Collection $collfile requires at least Modules version $minver"
654 }
655
656 proc cacheerr_magic {cachefile} {
657 return "$::cacheerr_msgs: Magic cookie '#%Module' missing\n In '$cachefile'\n$::err_contact"
658 }
659
660 proc cacheerr_misverreq {cachefile} {
661 return "$::cacheerr_msgs: Modules version requirement missing\n In '$cachefile'\n$::err_contact"
662 }
663
664 proc cacheerr_minverreq {cachefile minver} {
665 return "$::cacheerr_msgs: Cache file requires at least Modules version $minver\n In '$cachefile'\n$::err_contact"
666 }
667
668 proc moderr_missingmcookiens {modfile} {
669 return $::err_magicns'$modfile'\n$::err_contactns
670 }
671 proc moderr_missingmcookie {modfile} {
672 return $::err_magic'$modfile'\n$::err_contact
673 }
674
675 proc couldnotopen_nofile {file} {
676 return "couldn't open \"$file\": no such file or directory"
677 }
678
679 proc couldnotopen_permdenied {file} {
680 return "couldn't open \"$file\": permission denied"
681 }
682
683 proc err_couldnotopen_permdenied {file} {
684 return "$::error_msgs: [couldnotopen_permdenied $file]"
685 }
686
687 proc couldnotexec_nofile {file} {
688 return "couldn't execute \"$file\": no such file or directory"
689 }
690
691 proc warn_couldnotexec_nofile {file} {
692 return "$::warn_msgs: [couldnotexec_nofile $file]"
693 }
694
695 proc err_permdenied {modfile} {
696 return "$::error_msgs: Permission denied on '$modfile'"
697 }
698
699 proc err_accessdenied {mod {extramsg {}} {pad { }}} {
700 set msg "$::error_msgs: Access to module $mod is denied"
701 if {$extramsg ne {}} {
702 append msg "\n$pad$extramsg"
703 }
704 return $msg
705 }
706
707 proc err_accessnearlydenied {date {extramsg {}}} {
708 set msg "$::warn_msgs: Access to module will be denied starting '$date'"
709 if {$extramsg ne {}} {
710 append msg "\n$extramsg"
711 }
712 return $msg
713 }
714
715 proc err_unablelocate {mod} {
716 return "$::error_msgs: Unable to locate a modulefile for '$mod'"
717 }
718
719 proc err_noloaded {mod} {
720 return "$::error_msgs: No loaded version found for '$mod' module"
721 }
722
723 proc err_invalvarval {vrname vrvalue vrvalues {padding {}}} {
724 return "$::error_msgs: Invalid value '$vrvalue' for variant '$vrname'\n${padding}Allowed values are: $vrvalues"
725 }
726
727 proc err_novarval {vrname vrvalues {padding {}}} {
728 return "$::error_msgs: No value specified for variant '$vrname'\n${padding}Allowed values are: $vrvalues"
729 }
730
731 proc err_novariantname {vrspec} {
732 return "$::error_msgs: No variant name defined in argument '$vrspec'"
733 }
734
735 proc err_nofreevarval {vrname} {
736 return "$::error_msgs: No value specified for variant '$vrname'"
737 }
738
739 proc invalid_variant_name {vrname} {
740 return "Invalid variant name '$vrname'"
741 }
742
743 proc err_varspec {vrspec} {
744 return "$::error_msgs: Invalid variant specification '$vrspec'"
745 }
746
747 proc err_boolvarval {vrname {padding {}}} {
748 return "No value should be defined for boolean variant '$vrname'"
749 }
750
751 proc err_booldflvarval {vrname {padding {}}} {
752 return "Boolean value is expected as default value for variant '$vrname'"
753 }
754
755 proc err_boolonnonbool {vrname {padding {}}} {
756 return "Boolean value defined on non-boolean variant '$vrname'"
757 }
758
759 proc err_unkvar {vrname} {
760 return "$::error_msgs: Unknown variant '$vrname' specified"
761 }
762
763 proc err_invopt {opt} {
764 return "$::error_msgs: Invalid option '$opt'\n$::err_typehelp"
765 }
766
767 proc err_invcmd {cmd} {
768 return "$::error_msgs: Invalid command '$cmd'\n$::err_typehelp"
769 }
770
771 proc info_alreadyloaded {mod} {
772 return "$::info_msgs: Module '$mod' is already loaded"
773 }
774
775 proc info_notloaded {mod} {
776 return "$::info_msgs: Module '$mod' is not loaded"
777 }
778
779 proc err_othervariantloaded {vrlist {setsgr 0} {is_loading 0}} {
780 if {$setsgr} {
781 set vrdesiglist {}
782 foreach vr $vrlist {
783 lappend vrdesiglist [sgr 93]$vr[sgr 0]
784 }
785 set vrdesig [sgr 2]\{[sgr 22][join $vrdesiglist [sgr 2]:[sgr 22]][sgr 2]\}[sgr 22]
786 } else {
787 set vrdesig "{[join $vrlist :]}"
788 }
789 set state [expr {$is_loading ? {loading} : {loaded}}]
790 return "$::error_msgs: Variant $vrdesig is already $state"
791 }
792
793 proc err_extraspec {xtspec} {
794 return "$::error_msgs: Invalid extra specification '$xtspec'"
795 }
796
797 proc err_extraspecifier {xtspec} {
798 return "$::error_msgs: Invalid extra specifier '$xtspec'\n Valid extra\
799 specifiers are: always-load append-path chdir complete conflict\
800 depends-on depends-on-any envvar family incompat load load-any\
801 prepend-path prereq prereq-all prereq-any provide provided-alias\
802 pushenv remove-path require set-alias set-function setenv switch\
803 switch-on switch-off tag try-load uncomplete unload unset-alias\
804 unset-function unsetenv use variant"
805 }
806
807 proc err_xtspec_notallowed {} {
808 return "$::error_msgs: No extra specification allowed on this command"
809 }
810
811 proc err_tagmanset {tag} {
812 return "$::error_msgs: Tag '$tag' cannot be manually set"
813 }
814
815 proc err_misoptval {opt} {
816 return "$::error_msgs: Missing value for '$opt' option"
817 }
818
819 proc err_unsupportedshell {shell} {
820 return "$::error_msgs: Unsupported shell type '$shell'"
821 }
822
823 proc err_unsupportedopt {opt subcmd} {
824 return "$::error_msgs: Unsupported option '$opt' on $subcmd sub-command"
825 }
826
827 proc err_coll_notfound {coll {target {}}} {
828 if {$target ne {}} {
829 set targetmsg "(for target \"$target\") "
830 } else {
831 set targetmsg {}
832 }
833 return "$::error_msgs: Collection $coll ${targetmsg}cannot be found"
834 }
835
836 proc err_coll_notvalid {coll} {
837 return "$::error_msgs: $coll is not a valid collection"
838 }
839
840 proc err_stash_index {idx} {
841 return "$::error_msgs: Invalid stash index '$idx'"
842 }
843
844 proc err_stash_name {name} {
845 return "$::error_msgs: Invalid stash collection name '$name'"
846 }
847
848 proc msg_named_coll {{matching 0} {target {}}} {
849 if {$matching} {
850 set msg {Matching named }
851 } else {
852 set msg {Named }
853 }
854 append msg {collection list}
855 if {$target ne {}} {
856 append msg " (for target \"$target\")"
857 }
858 append msg :
859 return $msg
860 }
861
862 proc msg_no_named_coll {{matching 0} {target {}}} {
863 if {$matching} {
864 set msg {No matching }
865 } else {
866 set msg {No }
867 }
868 append msg {named collection}
869 if {$target ne {}} {
870 append msg " (for target \"$target\")"
871 }
872 append msg .
873 return $msg
874 }
875
876 proc msg_stash_coll {{target {}}} {
877 set msg {Stash collection list}
878 if {$target ne {}} {
879 append msg " (for target \"$target\")"
880 }
881 append msg :
882 return $msg
883 }
884
885 proc msg_no_stash_coll {{target {}}} {
886 set msg {No stash collection}
887 if {$target ne {}} {
888 append msg " (for target \"$target\")"
889 }
890 append msg .
891 return $msg
892 }
893
894 proc msg_modwarn {msg cmdline modfile linenum {pad {}} {procname {}} {contact {}} {custom {}} {custom2 {while executing}}} {
895 return [msg_moderr $msg $cmdline $modfile $linenum $pad $procname $contact $custom $custom2 {Module WARNING}]
896 }
897
898 proc msg_moderr {msg cmdline modfile linenum {pad {}} {procname {}} {contact {}} {custom {}} {custom2 {while executing}} {title {Module ERROR}}} {
899
900 set linefile [expr {$procname ne {} || $linenum eq {} ? {} : " line $linenum"}]
901 set errcontact [expr {$contact eq {} ? $::err_contactns : "Please contact <$contact>"}]
902 set res "$title: $msg
903 $pad $custom2
904 $pad\"$cmdline\""
905 if {$procname ne {}} {
906 append res "
907 $pad (procedure \"$procname\" line $linenum)
908 $pad invoked from within
909 $pad\"$procname\""
910 }
911 if {$custom ne {}} {
912 foreach custline [split $custom \n] {
913 append res "\n$pad$custline"
914 }
915 }
916 append res "
917 $pad (file \"$modfile\"$linefile)
918 $pad$errcontact"
919 return $res
920 }
921
922 proc msg_cacheerr {msg cmdline modfile linenum {custom {while executing}}} {
923 set res "$::cacheerr_msgs: $msg
924 $custom
925 \"$cmdline\""
926 append res "
927 (file \"$modfile\" line $linenum)
928 $::err_contactns"
929 return $res
930 }
931
932 proc is_conf_enabled {args} {
933 foreach conf $args {
934 if {[set ::install_$conf] ne {y}} {
935 return 0
936 }
937 }
938 return 1
939 }
940
941 proc if_implicitdefault {then {else {}}} {
942 return [expr {$::install_implicitdefault eq {y} ? $then : $else}]
943 }
944
945 proc if_availindepth {then {else {}}} {
946 return [expr {$::install_availindepth eq {y} ? $then : $else}]
947 }
948
949 proc if_searchcontains {then {else {}}} {
950 return [expr {$::install_searchmatch eq {contains} ? $then : $else}]
951 }
952
953 proc if_configlocked {option then {else {}}} {
954 return [expr {[is_config_locked $option] ? $then : $else}]
955 }
956
957 proc is_config_locked {option} {
958 return [expr {[lsearch -exact $::install_lockedconfigs $option] != -1}]
959 }
960
961 proc is_real_shell {shell} {
962 return [expr {[lsearch -exact $::real_shells $shell] != -1}]
963 }
964
965 proc is_full_path {file_path} {
966 return [regexp {^(|\.|\.\.)/} $file_path]
967 }
968
969 # helper procedures to format block message output
970 proc msg_block_content {args} {
971 set msg {}
972 foreach arg $args {
973 set first 1
974 set padding { }
975
976 set max_idx [expr {$::msg_disp_cols - [string length $padding]}]
977 set linelist [list]
978 foreach line [split $arg \n] {
979 set lineadd {}
980 while {$lineadd ne $line} {
981 # no split if no whitespace found to slice
982 if {[string length $line] > $max_idx && [set cut_idx [string\
983 last { } $line $max_idx]] != -1} {
984 set lineadd [string range $line 0 [expr {$cut_idx-1}]]
985 set line [string range $line [expr {$cut_idx+1}] end]
986 } else {
987 set lineadd $line
988 }
989 lappend linelist $lineadd
990 if {$first} {
991 set first 0
992 incr max_idx -[string length $padding]
993 }
994 }
995 }
996
997 # display each line
998 set first 1
999 foreach line $linelist {
1000 append msg \n
1001 if {$first} {
1002 set first 0
1003 } else {
1004 append msg $padding
1005 }
1006 append msg "$padding$line"
1007 }
1008 }
1009 return $msg
1010 }
1011
1012 proc msg_load {mod args} {
1013 set msg "Loading $mod"
1014 append msg [eval msg_block_content $args]
1015 return $msg
1016 }
1017
1018 proc msg_unload {mod args} {
1019 set msg "Unloading $mod"
1020 append msg [eval msg_block_content $args]
1021 return $msg
1022 }
1023
1024 proc msg_switch {old new args} {
1025 set msg "Switching from $old to $new"
1026 append msg [eval msg_block_content $args]
1027 return $msg
1028 }
1029
1030 proc msg_refresh {mod args} {
1031 set msg "Refreshing $mod"
1032 append msg [eval msg_block_content $args]
1033 return $msg
1034 }
1035
1036 proc msg_tag {mod args} {
1037 set msg "Tagging $mod"
1038 append msg [eval msg_block_content $args]
1039 return $msg
1040 }
1041
1042 proc msg_lint {mod args} {
1043 set msg "Linting $mod"
1044 append msg [eval msg_block_content $args]
1045 return $msg
1046 }
1047
1048 proc msg_delete {mod args} {
1049 set msg "Deleting $mod"
1050 append msg [eval msg_block_content $args]
1051 return $msg
1052 }
1053
1054 proc msg_create {mod args} {
1055 set msg "Creating $mod"
1056 append msg [eval msg_block_content $args]
1057 return $msg
1058 }
1059
1060 proc msg_top_load {mod unlist reqlolist deprelist args} {
1061 lassign [mix_depre_depun_list $deprelist {}] deprelist depunlist
1062
1063 if {[llength $depunlist]} {
1064 lappend args "Unloading dependent: [join $depunlist]"
1065 }
1066 if {[llength $unlist]} {
1067 lappend args "Unloading conflict: [join $unlist]"
1068 }
1069 if {[llength $reqlolist]} {
1070 lappend args "Loading requirement: [join $reqlolist]"
1071 }
1072 if {[llength $deprelist]} {
1073 lappend args "Reloading dependent: [join $deprelist]"
1074 }
1075 return [eval msg_load "{$mod}" $args]
1076 }
1077
1078 proc msg_top_load_conun_noauto {mod depunlist unlist urequnlist reqlolist deprelist args} {
1079 lassign [mix_depre_depun_list $deprelist $depunlist] deprelist depunlist
1080
1081 if {[llength $depunlist]} {
1082 lappend args "Unloading dependent: [join $depunlist]"
1083 }
1084 if {[llength $unlist]} {
1085 lappend args "Unloading conflict: [join $unlist]"
1086 }
1087 if {[llength $urequnlist]} {
1088 lappend args "Unloading useless requirement: [join $urequnlist]"
1089 }
1090 if {[llength $reqlolist]} {
1091 lappend args "Loading requirement: [join $reqlolist]"
1092 }
1093 if {[llength $deprelist]} {
1094 lappend args "Reloading dependent: [join $deprelist]"
1095 }
1096 return [eval msg_load "{$mod}" $args]
1097 }
1098
1099 proc msg_top_load_conun {mod depunlist unlist urequnlist reqlolist deprelist args} {
1100 lassign [mix_depre_depun_list $deprelist $depunlist] deprelist depunlist
1101
1102 if {[llength $depunlist]} {
1103 lappend args "Unloading dependent: [join $depunlist]"
1104 }
1105 if {[llength $unlist]} {
1106 lappend args "Unloading conflict: [join $unlist]"
1107 }
1108 if {[llength $reqlolist]} {
1109 lappend args "Loading requirement: [join $reqlolist]"
1110 }
1111 if {[llength $urequnlist]} {
1112 lappend args "Unloading useless requirement: [join $urequnlist]"
1113 }
1114 if {[llength $deprelist]} {
1115 lappend args "Reloading dependent: [join $deprelist]"
1116 }
1117 return [eval msg_load "{$mod}" $args]
1118 }
1119
1120 proc msg_top_unload {mod depunlist urequnlist deprelist args} {
1121 lassign [mix_depre_depun_list $deprelist $depunlist] deprelist depunlist
1122 if {[llength $depunlist]} {
1123 lappend args "Unloading dependent: [join $depunlist]"
1124 }
1125 if {[llength $urequnlist]} {
1126 lappend args "Unloading useless requirement: [join $urequnlist]"
1127 }
1128 if {[llength $deprelist]} {
1129 lappend args "Reloading dependent: [join $deprelist]"
1130 }
1131 return [eval msg_unload "{$mod}" $args]
1132 }
1133
1134 proc msg_top_switch_noauto {old new depunlist urequnlist unlist reqlolist deprelist args} {
1135 lassign [mix_depre_depun_list $deprelist $depunlist] deprelist depunlist
1136
1137 if {[llength $depunlist]} {
1138 lappend args "Unloading dependent: [join $depunlist]"
1139 }
1140 if {[llength $unlist]} {
1141 lappend args "Unloading conflict: [join $unlist]"
1142 }
1143 if {[llength $urequnlist]} {
1144 lappend args "Unloading useless requirement: [join $urequnlist]"
1145 }
1146 if {[llength $reqlolist]} {
1147 lappend args "Loading requirement: [join $reqlolist]"
1148 }
1149 if {[llength $deprelist]} {
1150 lappend args "Reloading dependent: [join $deprelist]"
1151 }
1152 return [eval msg_switch "{$old}" "{$new}" $args]
1153 }
1154
1155 proc msg_top_switch {old new depunlist urequnlist unlist reqlolist deprelist args} {
1156 lassign [mix_depre_depun_list $deprelist $depunlist] deprelist depunlist
1157
1158 if {[llength $depunlist]} {
1159 lappend args "Unloading dependent: [join $depunlist]"
1160 }
1161 if {[llength $unlist]} {
1162 lappend args "Unloading conflict: [join $unlist]"
1163 }
1164 if {[llength $reqlolist]} {
1165 lappend args "Loading requirement: [join $reqlolist]"
1166 }
1167 if {[llength $urequnlist]} {
1168 lappend args "Unloading useless requirement: [join $urequnlist]"
1169 }
1170 if {[llength $deprelist]} {
1171 lappend args "Reloading dependent: [join $deprelist]"
1172 }
1173 return [eval msg_switch "{$old}" "{$new}" $args]
1174 }
1175
1176 proc msg_top_switch_conun {old new depunlist urequnlist unlist reqlolist deprelist args} {
1177 lassign [mix_depre_depun_list $deprelist $depunlist] deprelist depunlist
1178
1179 if {[llength $depunlist]} {
1180 lappend args "Unloading dependent: [join $depunlist]"
1181 }
1182 if {[llength $unlist]} {
1183 lappend args "Unloading conflict: [join $unlist]"
1184 }
1185 if {[llength $urequnlist]} {
1186 lappend args "Unloading useless requirement: [join $urequnlist]"
1187 }
1188 if {[llength $reqlolist]} {
1189 lappend args "Loading requirement: [join $reqlolist]"
1190 }
1191 if {[llength $deprelist]} {
1192 lappend args "Reloading dependent: [join $deprelist]"
1193 }
1194 return [eval msg_switch "{$old}" "{$new}" $args]
1195 }
1196
1197 proc mix_depre_depun_list {deprelist depunlist} {
1198 # dependent reload unload phase appears with dependent unload (in actual unload order)
1199 # if some dependent fail to unload, 1 unload list and 1 reload list could be passed
1200 if {[llength $deprelist] == 2 && [llength [set depreun [lindex $deprelist 0]]] !=\
1201 [llength [set deprelo [lindex $deprelist 1]]]} {
1202 set depunlist [concat $depreun $depunlist]
1203 set deprelist $deprelo
1204 } else {
1205 set depunlist [concat [lreverse $deprelist] $depunlist]
1206 }
1207 return [list $deprelist $depunlist]
1208 }
1209
1210 proc sgr {code} {
1211 return "\033\\\[${code}m"
1212 }
1213
1214 # escape regexp chars in string
1215 proc escre {str} {
1216 return [string map {<EXM> (.*)+} [regsub -all {([.?*()+\[\]$])} $str {\\\1}]]
1217 }
1218
1219 proc create_stash_coll {content} {
1220 set colldir $::env(HOME)/.module
1221 if {![file exists $colldir]} {
1222 file mkdir $colldir
1223 }
1224 set coll stash-[clock milliseconds]
1225 if {[info exists ::env(MODULES_COLLECTION_TARGET)]} {
1226 append coll .$::env(MODULES_COLLECTION_TARGET)
1227 }
1228 send_user "\tCreating stash collection $colldir/$coll\n"
1229 set fid [open $colldir/$coll w]
1230 puts $fid $content
1231 close $fid
1232 }
1233
1234 proc delete_last_stash_coll {} {
1235 set collfile [lindex [lsort [glob $::env(HOME)/.module/stash-*]] 0]
1236 send_user "\tDeleting stash collection $collfile\n"
1237 file delete $collfile
1238 }
1239
1240 # fetch stash collections
1241 proc get_all_stash_colls {} {
1242 return [glob -types f $::env(HOME)/.module/stash-*]
1243 }
1244
1245 proc get_last_stash_coll {} {
1246 return [lindex [lsort [get_all_stash_colls]] end]
1247 }
1248
1249 proc create_dummy_cachefile {mp} {
1250 set cachefile $mp/.modulecache
1251 send_user "\tCreating dummy cache file $cachefile\n"
1252 set fid [open $cachefile w]
1253 puts $fid "#%Module$::cache_mcookie_version"
1254 close $fid
1255 }
1256
1257 proc create_dummy_modulefile {modfile} {
1258 send_user "\tCreating dummy module file $modfile\n"
1259 set fid [open $modfile w]
1260 puts $fid {#%Module}
1261 close $fid
1262 }
1263
1264 # create test modulefiles on the fly as those files finishing by a space character cannot
1265 # be recorded in git repository (checkout will fail on Windows platform)
1266 proc create_endspace_test_modulefiles {} {
1267 set mp $::modpath.2
1268 set module {space y }
1269
1270 file mkdir $mp/$module
1271
1272 set fid [open $mp/$module/.modulerc w]
1273 puts $fid {#%Module
1274 module-version {space y /1 } {n }
1275 module-version {space y /2.2} default
1276 module-alias {space y /a } {space y /1 }
1277 module-virtual {space y /v } {./1 }}
1278 close $fid
1279
1280 foreach f [list {1 } 2.2 2.5 2.7 2.10] {
1281 set fid [open $mp/$module/$f w]
1282 puts $fid {#%Module
1283 module-whatis [module-info name]}
1284 close $fid
1285 }
1286
1287 # do not rely on cache if prebuilt
1288 ignore_modulecache_if_built
1289 }
1290
1291 proc delete_endspace_test_modulefiles {} {
1292 set mp $::modpath.2
1293 set module {space y }
1294 foreach f [list .modulerc {1 } 2.2 2.5 2.7 2.10] {
1295 file delete $mp/$module/$f
1296 }
1297 file delete $mp/$module
1298
1299 # can reuse prebuilt cache if any now temporary modules are deleted
1300 end_ignore_modulecache_if_built
1301 }
1302
1303 # ensure next tests will ignore cache files if modulecache have been built
1304 proc ignore_modulecache_if_built {} {
1305 if {[info exists ::env(TESTSUITE_ENABLE_MODULECACHE)]} {
1306 send_user "\tIgnore module cache files on next tests\n"
1307 setenv_var MODULES_IGNORE_CACHE 1
1308 }
1309 }
1310
1311 proc end_ignore_modulecache_if_built {} {
1312 if {[info exists ::env(TESTSUITE_ENABLE_MODULECACHE)]} {
1313 send_user "\tUse cache files again on next tests\n"
1314 unsetenv_var MODULES_IGNORE_CACHE
1315 }
1316 }