Debian Codegraph @

testsuite/modules.30-cache/041-cache-interp.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.30-cache/%M%
6 # Revision: %I%
7 # First Edition: 2022/11/26
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command: avail
14 # Modulefiles:
15 # Sub-Command:
16 #
17 # Comment: %C{
18 # Test cachefile interpreter
19 # }C%
20 #
21 ##############################################################################
22
23 skip_if_quick_mode
24
25 # ensure avail tests are made using in depth mode
26 setenv_var MODULES_AVAIL_INDEPTH 1
27
28 # generate content in modulepaths
29 lassign [create_simple_module_setup $mp1] dir_list file_list
30 array set file_arr $file_list
31 lassign [create_simple_module_setup $mp2] other_dir_list other_file_list
32 array set other_file_arr $other_file_list
33
34 # create cache file for mp1 that supersedes command definition
35 set fid [open $mp1cache w]
36 puts $fid "#%Module$cache_mcookie_version
37 modulefile-content foo/1.0 {} {#%Module} {#%Module}
38 modulerc-content foo/.modulerc {#%Module} {#%Module}
39 proc modulefile-content {args} {}
40 modulefile-content bar/1.0 {} {#%Module} {#%Module}
41 modulefile-content bar/2.0 {} {#%Module} {#%Module}"
42 close $fid
43 set tserr [msg_create $mp2cache]
44 testouterr_cmd sh "cachebuild $mp2" OK $tserr
45
46 setenv_var MODULEPATH $mp1:$mp2
47 set tserr "$mp1:
48 foo/1.0
49
50 $mp2:
51 bar/1.0
52 bar/2.0
53 foo/1.0"
54 # polluted proc is reset when evaluating next cachefile
55 testouterr_cmd sh {avail -t} OK $tserr
56
57
58 # test local variables and procedures are not propagated to the next evaluation
59 set fid [open $mp1cache w]
60 puts $fid "#%Module$cache_mcookie_version
61 proc foo {args} {}
62 set bar val"
63 close $fid
64 set fid [open $mp2cache w]
65 puts $fid "#%Module$cache_mcookie_version
66 if {\[llength \[info procs foo\]\]} {
67 modulefile-content foo/1.0 {} {#%Module} {#%Module}
68 }
69 if {\[info exists bar\]} {
70 modulefile-content bar/1.0 {} {#%Module} {#%Module}
71 }"
72 close $fid
73 setenv_var MODULEPATH $mp1:$mp2
74 # local procedures or variables are not propagated to the next evaluation
75 testouterr_cmd sh {avail -t} OK {}
76
77
78 # test a cachefile overriding basic Tcl command
79 set fid [open $mp1cache w]
80 puts $fid "#%Module$cache_mcookie_version
81 proc set {args} {}"
82 close $fid
83 set tserr [msg_create $mp2cache]
84 testouterr_cmd sh "cachebuild $mp2" OK $tserr
85
86 setenv_var MODULEPATH $mp1:$mp2
87 set tserr "$mp2:
88 bar/1.0
89 bar/2.0
90 foo/1.0"
91 # due to polluted command, interp is reset when prior evaluating next cachefile
92 testouterr_cmd sh {avail -t} OK $tserr
93 set tserr ".*
94 Evaluate cache file: '[escre $mp2cache]'
95 DEBUG \\\[cache:[escre $mp2cache]\\\] resetInterpState: removing on __cachefile proc set
96 DEBUG \\\[cache:[escre $mp2cache]\\\] resetInterpState: missing command\\(s\\), recreating interp __cachefile
97 DEBUG \\\[cache:[escre $mp2cache]\\\] execute-cachefile: readCacheContent [escre $mp2cache]
98 DEBUG \\\[cache:[escre $mp2cache]\\\] execute-cachefile: exiting [escre $mp2cache] \\(result=1\\)
99 .*"
100 testouterr_cmd_re sh {avail -D -t} OK $tserr
101
102
103 #
104 # Cleanup
105 #
106
107 file delete $mp1cache
108 file delete $mp2cache
109
110 # delete created files and dirs
111 delete_module_setup $mp1 [array names file_arr] $dir_list
112 delete_module_setup $mp2 [array names other_file_arr] $other_dir_list
113
114 reset_test_env