| 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: 2020/02/29 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Xavier Delaruelle, [email protected] |
| 11 |
# |
| 12 |
# Description: Testuite testsequence |
| 13 |
# Command: |
| 14 |
# Modulefiles: |
| 15 |
# Sub-Command: load, source, help, display, test |
| 16 |
# |
| 17 |
# Comment: %C{ |
| 18 |
# Check error stack trace printed during failed evaluation |
| 19 |
# }C% |
| 20 |
# |
| 21 |
############################################################################## |
| 22 |
|
| 23 |
set mp $modpath.2 |
| 24 |
set mpre [regsub -all "\(\[.+?\]\)" $mp {\\\1}] |
| 25 |
|
| 26 |
# setup specific environment |
| 27 |
setenv_path_var MODULEPATH $mp |
| 28 |
|
| 29 |
# load tests |
| 30 |
|
| 31 |
set custom { (procedure "good-command" line 2) |
| 32 |
invoked from within |
| 33 |
"good-command"} |
| 34 |
set tserr [msg_load bad3/bodyproc [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/bodyproc 6 {} {} {} $custom]] |
| 35 |
testouterr_cmd sh "load bad3/bodyproc" ERR $tserr |
| 36 |
|
| 37 |
skip_if_quick_mode |
| 38 |
|
| 39 |
set custom " (procedure \"good-command\" line 2) |
| 40 |
invoked from within |
| 41 |
\"good-command\" |
| 42 |
(file \"$mp/bad3/.bodycommon\" line 5) |
| 43 |
invoked from within |
| 44 |
\"source \$env(TESTSUITEDIR)/modulefiles.2/bad3/.bodycommon\"" |
| 45 |
set tserr [msg_load bad3/bodysource [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/bodysource 2 {} {} {} $custom]] |
| 46 |
testouterr_cmd sh "load bad3/bodysource" ERR $tserr |
| 47 |
|
| 48 |
# error in conditional block |
| 49 |
if {[cmpversion $tclsh_version 8.6] == -1} { |
| 50 |
set custom " |
| 51 |
invoked from within |
| 52 |
\"if \{\$i == 1 \} \{ |
| 53 |
bad-command |
| 54 |
\}\"" |
| 55 |
set linenum 3 |
| 56 |
} else { |
| 57 |
set custom {} |
| 58 |
set linenum 4 |
| 59 |
} |
| 60 |
set tserr [msg_load bad3/bodyif [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/bodyif $linenum {} {} {} $custom]] |
| 61 |
testouterr_cmd sh "load bad3/bodyif" ERR $tserr |
| 62 |
if {[cmpversion $tclsh_version 8.6] == -1} { |
| 63 |
set custom " |
| 64 |
(\"for\" body line 2) |
| 65 |
invoked from within |
| 66 |
\"for \{set i 0\} \{\$i<10\} \{incr i\} \{ |
| 67 |
bad-command |
| 68 |
\}\"" |
| 69 |
set linenum 2 |
| 70 |
} else { |
| 71 |
set custom {} |
| 72 |
set linenum 3 |
| 73 |
} |
| 74 |
set tserr [msg_load bad3/bodyfor [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/bodyfor $linenum {} {} {} $custom]] |
| 75 |
testouterr_cmd sh "load bad3/bodyfor" ERR $tserr |
| 76 |
if {[cmpversion $tclsh_version 8.6] == -1} { |
| 77 |
set custom " |
| 78 |
(\"while\" body line 2) |
| 79 |
invoked from within |
| 80 |
\"while \{\$i == 1\} \{ |
| 81 |
bad-command |
| 82 |
\}\"" |
| 83 |
set linenum 3 |
| 84 |
} else { |
| 85 |
set custom {} |
| 86 |
set linenum 4 |
| 87 |
} |
| 88 |
set tserr [msg_load bad3/bodywhile [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/bodywhile $linenum {} {} {} $custom]] |
| 89 |
testouterr_cmd sh "load bad3/bodywhile" ERR $tserr |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
# error in modulerc |
| 94 |
setenv_var BADRC3_CASE 1 |
| 95 |
set custom { (procedure "good-command" line 2) |
| 96 |
invoked from within |
| 97 |
"good-command"} |
| 98 |
if {[cmpversion $tclsh_version 8.6] == -1} { |
| 99 |
append custom " |
| 100 |
(\"1\" arm line 5) |
| 101 |
invoked from within |
| 102 |
\"switch -- \$case \{ |
| 103 |
1 \{ |
| 104 |
proc good-command \{\} \{ |
| 105 |
bad-command |
| 106 |
\} |
| 107 |
good-command |
| 108 |
\} |
| 109 |
2 \{ |
| 110 |
source \$env(TESTSUITEDIR)/modulefiles.2/bad3/.bo...\"" |
| 111 |
set tserr [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/badrc3/.modulerc 8 { } {} {} $custom] |
| 112 |
} else { |
| 113 |
set tserr [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/badrc3/.modulerc 13 { } {} {} $custom] |
| 114 |
} |
| 115 |
set ans [list] |
| 116 |
if {[is_conf_enabled advversspec implicitdefault]} { |
| 117 |
lappend ans [list set __MODULES_LMALTNAME badrc3/1&as|badrc3/default&as|badrc3/latest] |
| 118 |
} |
| 119 |
lappend ans [list set _LMFILES_ $mp/badrc3/1] |
| 120 |
lappend ans [list set LOADEDMODULES badrc3/1] |
| 121 |
lappend ans [list ERR] |
| 122 |
testouterr_cmd sh {load badrc3/1} $ans $tserr |
| 123 |
|
| 124 |
setenv_var BADRC3_CASE 2 |
| 125 |
set custom " (procedure \"good-command\" line 2) |
| 126 |
invoked from within |
| 127 |
\"good-command\" |
| 128 |
(file \"$mp/bad3/.bodycommon\" line 5) |
| 129 |
invoked from within |
| 130 |
\"source \$env(TESTSUITEDIR)/modulefiles.2/bad3/.bodycommon\"" |
| 131 |
if {[cmpversion $tclsh_version 8.6] == -1} { |
| 132 |
append custom " |
| 133 |
(\"2\" arm line 2) |
| 134 |
invoked from within |
| 135 |
\"switch -- \$case \{ |
| 136 |
1 \{ |
| 137 |
proc good-command \{\} \{ |
| 138 |
bad-command |
| 139 |
\} |
| 140 |
good-command |
| 141 |
\} |
| 142 |
2 \{ |
| 143 |
source \$env(TESTSUITEDIR)/modulefiles.2/bad3/.bo...\"" |
| 144 |
set tserr [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/badrc3/.modulerc 8 { } {} {} $custom] |
| 145 |
} else { |
| 146 |
set tserr [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/badrc3/.modulerc 16 { } {} {} $custom] |
| 147 |
} |
| 148 |
testouterr_cmd sh {load badrc3/1} $ans $tserr |
| 149 |
|
| 150 |
setenv_var BADRC3_CASE 3 |
| 151 |
if {[cmpversion $tclsh_version 8.6] == -1} { |
| 152 |
set custom " (\"3\" arm line 2) |
| 153 |
invoked from within |
| 154 |
\"switch -- \$case \{ |
| 155 |
1 \{ |
| 156 |
proc good-command \{\} \{ |
| 157 |
bad-command |
| 158 |
\} |
| 159 |
good-command |
| 160 |
\} |
| 161 |
2 \{ |
| 162 |
source \$env(TESTSUITEDIR)/modulefiles.2/bad3/.bo...\"" |
| 163 |
set linenum 8 |
| 164 |
} else { |
| 165 |
set custom {} |
| 166 |
set linenum 19 |
| 167 |
} |
| 168 |
set tserr [msg_moderr {module-info bad not supported} "module-info bad" $mp/badrc3/.modulerc $linenum { } {} {} $custom] |
| 169 |
testouterr_cmd sh {load badrc3/1} $ans $tserr |
| 170 |
|
| 171 |
unsetenv_var BADRC3_CASE |
| 172 |
|
| 173 |
|
| 174 |
# source tests |
| 175 |
|
| 176 |
set custom { (procedure "good-command" line 2) |
| 177 |
invoked from within |
| 178 |
"good-command"} |
| 179 |
set tserr [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/bodyproc 6 { } {} {} $custom] |
| 180 |
testouterr_cmd sh "source $mp/bad3/bodyproc" ERR $tserr |
| 181 |
|
| 182 |
set custom " (procedure \"good-command\" line 2) |
| 183 |
invoked from within |
| 184 |
\"good-command\" |
| 185 |
(file \"$mp/bad3/.bodycommon\" line 5) |
| 186 |
invoked from within |
| 187 |
\"source \$env(TESTSUITEDIR)/modulefiles.2/bad3/.bodycommon\"" |
| 188 |
set tserr [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/bodysource 2 { } {} {} $custom] |
| 189 |
testouterr_cmd sh "source $mp/bad3/bodysource" ERR $tserr |
| 190 |
|
| 191 |
# display tests |
| 192 |
|
| 193 |
set custom { (procedure "good-command" line 2) |
| 194 |
invoked from within |
| 195 |
"good-command" |
| 196 |
(procedure "ModulesDisplay" line 2) |
| 197 |
invoked from within |
| 198 |
"ModulesDisplay"} |
| 199 |
set custom [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/procproc {} { } {} {} $custom]] |
| 200 |
set tserr "$modlin |
| 201 |
$mpre/bad3/procproc: |
| 202 |
|
| 203 |
$custom |
| 204 |
$modlin" |
| 205 |
testouterr_cmd_re sh {display bad3/procproc} ERR $tserr |
| 206 |
|
| 207 |
set custom " (procedure \"good-command\" line 2) |
| 208 |
invoked from within |
| 209 |
\"good-command\" |
| 210 |
(procedure \"ModulesDisplay\" line 2) |
| 211 |
invoked from within |
| 212 |
\"ModulesDisplay\"" |
| 213 |
set custom [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/procsource {} { } {} {} $custom]] |
| 214 |
set tserr "$modlin |
| 215 |
$mpre/bad3/procsource: |
| 216 |
|
| 217 |
$custom |
| 218 |
$modlin" |
| 219 |
testouterr_cmd_re sh {display bad3/procsource} ERR $tserr |
| 220 |
|
| 221 |
|
| 222 |
# help tests |
| 223 |
|
| 224 |
set custom { (procedure "good-command" line 2) |
| 225 |
invoked from within |
| 226 |
"good-command" |
| 227 |
(procedure "ModulesHelp" line 2) |
| 228 |
invoked from within |
| 229 |
"ModulesHelp"} |
| 230 |
set custom [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/procproc {} { } {} {} $custom]] |
| 231 |
set tserr "$modlin |
| 232 |
Module Specific Help for $mpre/bad3/procproc: |
| 233 |
|
| 234 |
$custom |
| 235 |
$modlin" |
| 236 |
testouterr_cmd_re sh {help bad3/procproc} ERR $tserr |
| 237 |
|
| 238 |
set custom " (procedure \"good-command\" line 2) |
| 239 |
invoked from within |
| 240 |
\"good-command\" |
| 241 |
(procedure \"ModulesHelp\" line 2) |
| 242 |
invoked from within |
| 243 |
\"ModulesHelp\"" |
| 244 |
set custom [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/procsource {} { } {} {} $custom]] |
| 245 |
set tserr "$modlin |
| 246 |
Module Specific Help for $mpre/bad3/procsource: |
| 247 |
|
| 248 |
$custom |
| 249 |
$modlin" |
| 250 |
testouterr_cmd_re sh {help bad3/procsource} ERR $tserr |
| 251 |
|
| 252 |
|
| 253 |
# test tests |
| 254 |
|
| 255 |
set custom { (procedure "good-command" line 2) |
| 256 |
invoked from within |
| 257 |
"good-command" |
| 258 |
(procedure "ModulesTest" line 2) |
| 259 |
invoked from within |
| 260 |
"ModulesTest"} |
| 261 |
set custom [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/procproc {} { } {} {} $custom]] |
| 262 |
set tserr "$modlin |
| 263 |
Module Specific Test for $mpre/bad3/procproc: |
| 264 |
|
| 265 |
$custom |
| 266 |
$modlin" |
| 267 |
testouterr_cmd_re sh {test bad3/procproc} ERR $tserr |
| 268 |
|
| 269 |
set custom " (procedure \"good-command\" line 2) |
| 270 |
invoked from within |
| 271 |
\"good-command\" |
| 272 |
(procedure \"ModulesTest\" line 2) |
| 273 |
invoked from within |
| 274 |
\"ModulesTest\"" |
| 275 |
set custom [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/procsource {} { } {} {} $custom]] |
| 276 |
set tserr "$modlin |
| 277 |
Module Specific Test for $mpre/bad3/procsource: |
| 278 |
|
| 279 |
$custom |
| 280 |
$modlin" |
| 281 |
testouterr_cmd_re sh {test bad3/procsource} ERR $tserr |
| 282 |
|
| 283 |
# wrongly call a legit modulefile command from a modulefile procedure |
| 284 |
set custom "$moderr_msgs: wrong # args: should be \"setenv ?--set-if-undef? var val\" |
| 285 |
while executing |
| 286 |
\"setenv\" |
| 287 |
(procedure \"my-proc\" line 2) |
| 288 |
invoked from within |
| 289 |
\"my-proc\" |
| 290 |
(file \"$mp/bad3/proc2\" line 6) |
| 291 |
Please contact <root@localhost>" |
| 292 |
set tserr [msg_load bad3/proc2 $custom] |
| 293 |
testouterr_cmd sh {load bad3/proc2} ERR $tserr |
| 294 |
|
| 295 |
# try to reach a modulecmd.tcl internal procedure from a modulefile evaluation |
| 296 |
# "unknown command"-error will preserve internal command name reference in error stack |
| 297 |
set custom { |
| 298 |
(procedure "my-proc" line 2) |
| 299 |
invoked from within |
| 300 |
"my-proc"} |
| 301 |
set tserr [msg_load bad3/proc3 [msg_moderr {invalid command name "getModshareVarName"} {getModshareVarName} $mp/bad3/proc3 6 {} {} {} $custom]] |
| 302 |
testouterr_cmd sh {load bad3/proc3} ERR $tserr |
| 303 |
|
| 304 |
|
| 305 |
# |
| 306 |
# Cleanup |
| 307 |
# |
| 308 |
|
| 309 |
reset_test_env |