| 1 |
#%Module1.0 |
| 2 |
|
| 3 |
############################################################################## |
| 4 |
# Modules Revision 3.0 |
| 5 |
# Providing a flexible user environment |
| 6 |
# |
| 7 |
# File: spreadrc/%M% |
| 8 |
# Revision: %I% |
| 9 |
# First Edition: 2017/06/23 |
| 10 |
# Last Mod.: %U%, %G% |
| 11 |
# |
| 12 |
# Authors: Xavier Delaruelle, [email protected] |
| 13 |
# |
| 14 |
# Description: Testuite modulefile |
| 15 |
# Command: |
| 16 |
# Sub-Command: |
| 17 |
# |
| 18 |
# Invocation: load @M@, unload @M@, switch @M@ @M@, |
| 19 |
# help @M@, display @M@, test @M@, whatis @M@ |
| 20 |
# Result: %R{ |
| 21 |
# }R% |
| 22 |
# Comment: %C{ |
| 23 |
# Test how variable and procedure definitions spread from |
| 24 |
# one modulerc or modulefile interpretation to another one |
| 25 |
# when these interpretations are cascaded. |
| 26 |
# }C% |
| 27 |
# |
| 28 |
############################################################################## |
| 29 |
|
| 30 |
|
| 31 |
# test if specific or overridden pre-existing variables have spread here |
| 32 |
# coming from modulerc or sibbling modulefiles |
| 33 |
if {[info exists spreadrc]} { |
| 34 |
puts stderr "variable spreadrc exists" |
| 35 |
} |
| 36 |
if {[info exists spreadmod]} { |
| 37 |
puts stderr "variable spreadmod exists" |
| 38 |
} |
| 39 |
if {$tcl_version eq "test"} { |
| 40 |
puts stderr "variable tcl_version equals test" |
| 41 |
} |
| 42 |
if {[array exists spreadrc_array]} { |
| 43 |
puts stderr "array variable spreadrc_array exists" |
| 44 |
} |
| 45 |
if {[array exists spreadmod_array]} { |
| 46 |
puts stderr "array variable spreadmod_array exists" |
| 47 |
} |
| 48 |
if {$tcl_platform(osVersion) eq "test"} { |
| 49 |
puts stderr "variable tcl_platform(osVersion) equals test" |
| 50 |
} |
| 51 |
if {[llength $auto_path] <= 1} { |
| 52 |
puts stderr "variable auto_path has lost elements" |
| 53 |
} |
| 54 |
if {[lsearch -exact $auto_path $env(TESTSUITEDIR)] > -1} { |
| 55 |
puts stderr "variable auto_path contains $env(TESTSUITEDIR)" |
| 56 |
} |
| 57 |
|
| 58 |
# test if specific or overridden interpreter alias command have spread here |
| 59 |
# coming from modulerc or sibbling modulefiles |
| 60 |
set existing_proc [lindex [info procs] 0] |
| 61 |
# test if first proc defined has been altered |
| 62 |
if {[info procs $existing_proc] ne $existing_proc} { |
| 63 |
puts stderr "procedure $existing_proc does not exist" |
| 64 |
# env variable spread across interpretation and even between interpreters |
| 65 |
} else { |
| 66 |
# overridden proc does not spread as interp is renewed when a command is overridden |
| 67 |
if {[info exists env(spreadmodcasccmd)] && [$existing_proc] eq "spreadmodcasccmd"} { |
| 68 |
puts stderr "procedure $existing_proc has been altered" |
| 69 |
} |
| 70 |
if {[info exists env(spreadrccasc)] && [$existing_proc] eq "spreadrccasc"} { |
| 71 |
puts stderr "procedure $existing_proc has been altered" |
| 72 |
} |
| 73 |
} |
| 74 |
if {[info procs spreadrc_proc] eq "spreadrc_proc"} { |
| 75 |
puts stderr "procedure spreadrc_proc exists" |
| 76 |
} |
| 77 |
if {[info procs spreadmod_proc] eq "spreadmod_proc"} { |
| 78 |
puts stderr "procedure spreadmod_proc exists" |
| 79 |
} |
| 80 |
if {[info procs ModulesHelp] eq "ModulesHelp"} { |
| 81 |
puts stderr "procedure ModulesHelp exists" |
| 82 |
} |
| 83 |
if {[info procs ModulesTest] eq "ModulesTest"} { |
| 84 |
puts stderr "procedure ModulesTest exists" |
| 85 |
} |
| 86 |
if {[info procs ModulesDisplay] eq "ModulesDisplay"} { |
| 87 |
puts stderr "procedure ModulesDisplay exists" |
| 88 |
} |
| 89 |
if {[info procs module-version] eq "module-version"} { |
| 90 |
puts stderr "procedure module-version exists" |
| 91 |
} |
| 92 |
if {[info commands set] ne "set"} { |
| 93 |
puts stderr "command set does not exist" |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
# define specific variables or override value in pre-existing variables |
| 98 |
set spreadmod "yes" |
| 99 |
set tcl_version "test" |
| 100 |
array set spreadmod_array [list "yes" 1] |
| 101 |
set tcl_platform(osVersion) "test" |
| 102 |
lappend auto_path $env(TESTSUITEDIR) |
| 103 |
set env(spreadmodcasc) "yes" |
| 104 |
set env(spreadmodcasccmd) "yes" |
| 105 |
|
| 106 |
# define specific procs or override interpreter alias command |
| 107 |
# override first proc defined |
| 108 |
proc $existing_proc {args} { |
| 109 |
return "spreadmodcasccmd" |
| 110 |
} |
| 111 |
proc spreadmod_proc {text} { |
| 112 |
puts stderr "spreadmod_proc: $text" |
| 113 |
} |
| 114 |
proc ModulesHelp {} { |
| 115 |
puts stderr "spreadmod" |
| 116 |
} |
| 117 |
proc ModulesTest {} { |
| 118 |
puts stderr "spreadmod" |
| 119 |
return 1 |
| 120 |
} |
| 121 |
proc ModulesDisplay {} { |
| 122 |
puts stderr "spreadmod" |
| 123 |
} |
| 124 |
proc module-version {args} { |
| 125 |
puts stderr "spreadmod" |
| 126 |
} |
| 127 |
# define proc to override interpreter initial command |
| 128 |
proc set {args} { |
| 129 |
if {[lsearch -exact [list ::env(LOADEDMODULES) ::env(_LMFILES_) ::env(__MODULES_LMPREREQ) ::env(__MODULES_LMTAG) ::env(testspreadrccmd) ::env(testspreadrc) ::env(testspreadrccmdsub) ::env(testspreadrcsub) vrerrlist] [lindex $args 0]] == -1} { |
| 130 |
puts stderr "spreadmod" |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
setenv testspreadrccmd "yes" |
| 135 |
|
| 136 |
module load spreadrc/dir8/1.0 |
| 137 |
|
| 138 |
# test if specific or overridden pre-existing variables are still there |
| 139 |
# after cascaded interpretation |
| 140 |
if {![info exists spreadmod]} { |
| 141 |
puts stderr "variable spreadmod has been reset" |
| 142 |
} |
| 143 |
if {$tcl_version ne "test"} { |
| 144 |
puts stderr "variable tcl_version has been reset" |
| 145 |
} |
| 146 |
if {![array exists spreadmod_array]} { |
| 147 |
puts stderr "array variable spreadmod_array has been reset" |
| 148 |
} |
| 149 |
if {$tcl_platform(osVersion) ne "test"} { |
| 150 |
puts stderr "variable tcl_platform(osVersion) has been reset" |
| 151 |
} |
| 152 |
if {[lsearch -exact $auto_path $env(TESTSUITEDIR)] == -1} { |
| 153 |
puts stderr "variable auto_path has been reset" |
| 154 |
} |
| 155 |
|
| 156 |
# test if specific or overridden interpreter alias command are still there |
| 157 |
# after cascaded interpretation |
| 158 |
# test if first proc defined has been altered |
| 159 |
if {[info procs $existing_proc] ne $existing_proc} { |
| 160 |
puts stderr "procedure $existing_proc does not exist" |
| 161 |
# env variable spread across interpretation and even between interpreters |
| 162 |
} elseif {[info exists env(spreadmodcasccmd)] && [$existing_proc] ne "spreadmodcasccmd"} { |
| 163 |
puts stderr "procedure $existing_proc has been reset" |
| 164 |
} |
| 165 |
if {[info procs spreadmod_proc] ne "spreadmod_proc"} { |
| 166 |
puts stderr "procedure spreadmod_proc has been reset" |
| 167 |
} |
| 168 |
if {[info procs ModulesHelp] ne "ModulesHelp"} { |
| 169 |
puts stderr "procedure ModulesHelp has been reset" |
| 170 |
} |
| 171 |
if {[info procs ModulesTest] ne "ModulesTest"} { |
| 172 |
puts stderr "procedure ModulesTest has been reset" |
| 173 |
} |
| 174 |
if {[info procs ModulesDisplay] ne "ModulesDisplay"} { |
| 175 |
puts stderr "procedure ModulesDisplay has been reset" |
| 176 |
} |
| 177 |
if {[info procs module-version] ne "module-version"} { |
| 178 |
puts stderr "procedure module-version has been reset" |
| 179 |
} |