File: 300-err_stack.exp

package info (click to toggle)
modules 5.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,036 kB
  • sloc: exp: 79,659; sh: 6,142; tcl: 5,900; makefile: 1,493; ansic: 474; python: 265; csh: 202; perl: 47; ruby: 44; lisp: 13
file content (309 lines) | stat: -rw-r--r-- 9,203 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.70-maint/%M%
#   Revision:		%I%
#   First Edition:	2020/02/29
#   Last Mod.:		%U%, %G%
#
#   Authors:		Xavier Delaruelle, xavier.delaruelle@cea.fr
#
#   Description:	Testuite testsequence
#   Command:
#   Modulefiles:
#   Sub-Command:    load, source, help, display, test
#
#   Comment:	%C{
#           Check error stack trace printed during failed evaluation
#		}C%
#
##############################################################################

set mp $modpath.2
set mpre [regsub -all "\(\[.+?\]\)" $mp {\\\1}]

# setup specific environment
setenv_path_var MODULEPATH $mp

# load tests

set custom {    (procedure "good-command" line 2)
    invoked from within
"good-command"}
set tserr [msg_load bad3/bodyproc [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/bodyproc 6 {} {} {} $custom]]
testouterr_cmd sh "load bad3/bodyproc" ERR $tserr

skip_if_quick_mode

set custom "    (procedure \"good-command\" line 2)
    invoked from within
\"good-command\"
    (file \"$mp/bad3/.bodycommon\" line 5)
    invoked from within
\"source \$env(TESTSUITEDIR)/modulefiles.2/bad3/.bodycommon\""
set tserr [msg_load bad3/bodysource [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/bodysource 2 {} {} {} $custom]]
testouterr_cmd sh "load bad3/bodysource" ERR $tserr

# error in conditional block
if {[cmpversion $tclsh_version 8.6] == -1} {
    set custom "
    invoked from within
\"if \{\$i == 1 \} \{
    bad-command
\}\""
    set linenum 3
} else {
    set custom {}
    set linenum 4
}
set tserr [msg_load bad3/bodyif [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/bodyif $linenum {} {} {} $custom]]
testouterr_cmd sh "load bad3/bodyif" ERR $tserr
if {[cmpversion $tclsh_version 8.6] == -1} {
    set custom "
    (\"for\" body line 2)
    invoked from within
\"for \{set i 0\} \{\$i<10\} \{incr i\} \{
    bad-command
\}\""
    set linenum 2
} else {
    set custom {}
    set linenum 3
}
set tserr [msg_load bad3/bodyfor [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/bodyfor $linenum {} {} {} $custom]]
testouterr_cmd sh "load bad3/bodyfor" ERR $tserr
if {[cmpversion $tclsh_version 8.6] == -1} {
    set custom "
    (\"while\" body line 2)
    invoked from within
\"while \{\$i == 1\} \{
    bad-command
\}\""
    set linenum 3
} else {
    set custom {}
    set linenum 4
}
set tserr [msg_load bad3/bodywhile [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/bodywhile $linenum {} {} {} $custom]]
testouterr_cmd sh "load bad3/bodywhile" ERR $tserr



# error in modulerc
setenv_var BADRC3_CASE 1
set custom {    (procedure "good-command" line 2)
    invoked from within
"good-command"}
if {[cmpversion $tclsh_version 8.6] == -1} {
    append custom "
    (\"1\" arm line 5)
    invoked from within
\"switch -- \$case \{
1 \{
    proc good-command \{\} \{
        bad-command
    \}
    good-command
\}
2 \{
    source \$env(TESTSUITEDIR)/modulefiles.2/bad3/.bo...\""
    set tserr [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/badrc3/.modulerc 8 {  } {} {} $custom]
} else {
    set tserr [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/badrc3/.modulerc 13 {  } {} {} $custom]
}
set ans [list]
if {[is_conf_enabled advversspec implicitdefault]} {
    lappend ans [list set __MODULES_LMALTNAME badrc3/1&as|badrc3/default&as|badrc3/latest]
}
lappend ans [list set _LMFILES_ $mp/badrc3/1]
lappend ans [list set LOADEDMODULES badrc3/1]
lappend ans [list ERR]
testouterr_cmd sh {load badrc3/1} $ans $tserr

setenv_var BADRC3_CASE 2
set custom "    (procedure \"good-command\" line 2)
    invoked from within
\"good-command\"
    (file \"$mp/bad3/.bodycommon\" line 5)
    invoked from within
\"source \$env(TESTSUITEDIR)/modulefiles.2/bad3/.bodycommon\""
if {[cmpversion $tclsh_version 8.6] == -1} {
    append custom "
    (\"2\" arm line 2)
    invoked from within
\"switch -- \$case \{
1 \{
    proc good-command \{\} \{
        bad-command
    \}
    good-command
\}
2 \{
    source \$env(TESTSUITEDIR)/modulefiles.2/bad3/.bo...\""
    set tserr [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/badrc3/.modulerc 8 {  } {} {} $custom]
} else {
    set tserr [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/badrc3/.modulerc 16 {  } {} {} $custom]
}
testouterr_cmd sh {load badrc3/1} $ans $tserr

setenv_var BADRC3_CASE 3
if {[cmpversion $tclsh_version 8.6] == -1} {
    set custom "    (\"3\" arm line 2)
    invoked from within
\"switch -- \$case \{
1 \{
    proc good-command \{\} \{
        bad-command
    \}
    good-command
\}
2 \{
    source \$env(TESTSUITEDIR)/modulefiles.2/bad3/.bo...\""
    set linenum 8
} else {
    set custom {}
    set linenum 19
}
set tserr [msg_moderr {module-info bad not supported} "module-info bad" $mp/badrc3/.modulerc $linenum {  } {} {} $custom]
testouterr_cmd sh {load badrc3/1} $ans $tserr

unsetenv_var BADRC3_CASE


# source tests

set custom {    (procedure "good-command" line 2)
    invoked from within
"good-command"}
set tserr [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/bodyproc 6 {  } {} {} $custom]
testouterr_cmd sh "source $mp/bad3/bodyproc" ERR $tserr

set custom "    (procedure \"good-command\" line 2)
    invoked from within
\"good-command\"
    (file \"$mp/bad3/.bodycommon\" line 5)
    invoked from within
\"source \$env(TESTSUITEDIR)/modulefiles.2/bad3/.bodycommon\""
set tserr [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/bodysource 2 {  } {} {} $custom]
testouterr_cmd sh "source $mp/bad3/bodysource" ERR $tserr

# display tests

set custom {    (procedure "good-command" line 2)
    invoked from within
"good-command"
    (procedure "ModulesDisplay" line 2)
    invoked from within
"ModulesDisplay"}
set custom [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/procproc {} {  } {} {} $custom]]
set tserr "$modlin
$mpre/bad3/procproc:

$custom
$modlin"
testouterr_cmd_re sh {display bad3/procproc} ERR $tserr

set custom "    (procedure \"good-command\" line 2)
    invoked from within
\"good-command\"
    (procedure \"ModulesDisplay\" line 2)
    invoked from within
\"ModulesDisplay\""
set custom [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/procsource {} {  } {} {} $custom]]
set tserr "$modlin
$mpre/bad3/procsource:

$custom
$modlin"
testouterr_cmd_re sh {display bad3/procsource} ERR $tserr


# help tests

set custom {    (procedure "good-command" line 2)
    invoked from within
"good-command"
    (procedure "ModulesHelp" line 2)
    invoked from within
"ModulesHelp"}
set custom [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/procproc {} {  } {} {} $custom]]
set tserr "$modlin
Module Specific Help for $mpre/bad3/procproc:

$custom
$modlin"
testouterr_cmd_re sh {help bad3/procproc} ERR $tserr

set custom "    (procedure \"good-command\" line 2)
    invoked from within
\"good-command\"
    (procedure \"ModulesHelp\" line 2)
    invoked from within
\"ModulesHelp\""
set custom [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/procsource {} {  } {} {} $custom]]
set tserr "$modlin
Module Specific Help for $mpre/bad3/procsource:

$custom
$modlin"
testouterr_cmd_re sh {help bad3/procsource} ERR $tserr


# test tests

set custom {    (procedure "good-command" line 2)
    invoked from within
"good-command"
    (procedure "ModulesTest" line 2)
    invoked from within
"ModulesTest"}
set custom [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/procproc {} {  } {} {} $custom]]
set tserr "$modlin
Module Specific Test for $mpre/bad3/procproc:

$custom
$modlin"
testouterr_cmd_re sh {test bad3/procproc} ERR $tserr

set custom "    (procedure \"good-command\" line 2)
    invoked from within
\"good-command\"
    (procedure \"ModulesTest\" line 2)
    invoked from within
\"ModulesTest\""
set custom [escre [msg_moderr "$msg_invcmdname \"bad-command\"" bad-command $mp/bad3/procsource {} {  } {} {} $custom]]
set tserr "$modlin
Module Specific Test for $mpre/bad3/procsource:

$custom
$modlin"
testouterr_cmd_re sh {test bad3/procsource} ERR $tserr

# wrongly call a legit modulefile command from a modulefile procedure
set custom "$moderr_msgs: wrong # args: should be \"setenv ?--set-if-undef? var val\"
    while executing
\"setenv\"
    (procedure \"my-proc\" line 2)
    invoked from within
\"my-proc\"
    (file \"$mp/bad3/proc2\" line 6)
Please contact <root@localhost>"
set tserr [msg_load bad3/proc2 $custom]
testouterr_cmd sh {load bad3/proc2} ERR $tserr

# try to reach a modulecmd.tcl internal procedure from a modulefile evaluation
# "unknown command"-error will preserve internal command name reference in error stack
set custom {
    (procedure "my-proc" line 2)
    invoked from within
"my-proc"}
set tserr [msg_load bad3/proc3 [msg_moderr {invalid command name "getModshareVarName"} {getModshareVarName} $mp/bad3/proc3 6 {} {} {} $custom]]
testouterr_cmd sh {load bad3/proc3} ERR $tserr


#
#  Cleanup
#

reset_test_env