Debian Codegraph @

testsuite/modulefiles/spread/7.0

raw
1 #%Module1.0
2
3 ##############################################################################
4 # Modules Revision 3.0
5 # Providing a flexible user environment
6 #
7 # File: spread/%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 modulefile interpretation to another one when these
25 # interpretations are cascaded.
26 # }C%
27 #
28 ##############################################################################
29
30
31 # test if specific or overridden pre-existing variables have spread here
32 if {[info exists spread]} {
33 puts stderr "variable spread exists"
34 }
35 if {$tcl_version eq "test"} {
36 puts stderr "variable tcl_version equals test"
37 }
38 if {[array exists spread_array]} {
39 puts stderr "array variable spread_array exists"
40 }
41 if {$tcl_platform(osVersion) eq "test"} {
42 puts stderr "variable tcl_platform(osVersion) equals test"
43 }
44 if {[llength $auto_path] <= 1} {
45 puts stderr "variable auto_path has lost elements"
46 }
47 if {[lsearch -exact $auto_path $env(TESTSUITEDIR)] > -1} {
48 puts stderr "variable auto_path contains $env(TESTSUITEDIR)"
49 }
50
51 # test if specific or overridden interpreter alias command have spread here
52 set existing_proc [lindex [info procs] 0]
53 # test if first proc defined has been altered
54 if {[info procs $existing_proc] ne $existing_proc} {
55 puts stderr "procedure $existing_proc does not exist"
56 # env variable spread across interpretation and even between interpreters
57 # overridden proc does not spread as interp is renewed when a command is overridden
58 } elseif {[info exists env(spreadcasccmd)] && [$existing_proc] eq "spreadcasccmd"} {
59 puts stderr "procedure $existing_proc has been altered"
60 }
61 if {[info procs spread_proc] eq "spread_proc"} {
62 puts stderr "procedure spread_proc exists"
63 }
64 if {[info procs ModulesHelp] eq "ModulesHelp"} {
65 puts stderr "procedure ModulesHelp exists"
66 }
67 if {[info procs ModulesTest] eq "ModulesTest"} {
68 puts stderr "procedure ModulesTest exists"
69 }
70 if {[info procs ModulesDisplay] eq "ModulesDisplay"} {
71 puts stderr "procedure ModulesDisplay exists"
72 }
73 if {[info procs module-version] eq "module-version"} {
74 puts stderr "procedure module-version exists"
75 }
76 if {[info commands set] ne "set"} {
77 puts stderr "command set does not exist"
78 }
79
80 # define specific variables or override value in pre-existing variables
81 set spread "yes"
82 set tcl_version "test"
83 array set spread_array [list "yes" 1]
84 set tcl_platform(osVersion) "test"
85 lappend auto_path $env(TESTSUITEDIR)
86 set env(spread) "yes"
87 set env(spreadcasccmd) "yes"
88
89 # define specific procs or override interpreter alias command
90 # override first proc defined
91 proc $existing_proc {args} {
92 return "spreadcasccmd"
93 }
94 proc spread_proc {text} {
95 puts stderr "spread_proc: $text"
96 }
97 proc ModulesHelp {} {
98 puts stderr "spread"
99 }
100 proc ModulesTest {} {
101 puts stderr "spread"
102 return 1
103 }
104 proc ModulesDisplay {} {
105 puts stderr "spread"
106 }
107 proc module-version {args} {
108 puts stderr "spread"
109 }
110 # define proc to override interpreter initial command
111 proc set {args} {
112 if {[lsearch -exact [list ::env(LOADEDMODULES) ::env(_LMFILES_) ::env(__MODULES_LMPREREQ) ::env(__MODULES_LMTAG) ::env(testspreadrccmd) ::env(testspreadrc) ::env(testspreadrccmdsub) ::env(testspreadrcsub) ::env(testspreadsub) ::env(testspreadcmd) ::env(testspreadcmdsub) vrerrlist] [lindex $args 0]] == -1} {
113 puts stderr "spread"
114 }
115 }
116
117 setenv testspreadcmd "yes"
118
119 module load spread/8.0
120
121 # test if specific or overridden pre-existing variables are still there
122 # after cascaded interpretation
123 if {![info exists spread]} {
124 puts stderr "variable spread has been reset"
125 }
126 if {$tcl_version ne "test"} {
127 puts stderr "variable tcl_version has been reset"
128 }
129 if {![array exists spread_array]} {
130 puts stderr "array variable spread_array has been reset"
131 }
132 if {$tcl_platform(osVersion) ne "test"} {
133 puts stderr "variable tcl_platform(osVersion) has been reset"
134 }
135 if {[lsearch -exact $auto_path $env(TESTSUITEDIR)] == -1} {
136 puts stderr "variable auto_path has been reset"
137 }
138
139 # test if specific or overridden interpreter alias command are still there
140 # after cascaded interpretation
141 # test if first proc defined has been altered
142 if {[info procs $existing_proc] ne $existing_proc} {
143 puts stderr "procedure $existing_proc does not exist"
144 # env variable spread across interpretation and even between interpreters
145 } elseif {[info exists env(spreadcasccmd)] && [$existing_proc] ne "spreadcasccmd"} {
146 puts stderr "procedure $existing_proc has been reset"
147 }
148 if {[info procs spread_proc] ne "spread_proc"} {
149 puts stderr "procedure spread_proc has been reset"
150 }
151 if {[info procs ModulesHelp] ne "ModulesHelp"} {
152 puts stderr "procedure ModulesHelp has been reset"
153 }
154 if {[info procs ModulesTest] ne "ModulesTest"} {
155 puts stderr "procedure ModulesTest has been reset"
156 }
157 if {[info procs ModulesDisplay] ne "ModulesDisplay"} {
158 puts stderr "procedure ModulesDisplay has been reset"
159 }
160 if {[info procs module-version] ne "module-version"} {
161 puts stderr "procedure module-version has been reset"
162 }
163