Debian Codegraph @

testsuite/modules.50-cmds/069-remove-env.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.50-cmds/%M%
6 # Revision: %I%
7 # First Edition: 2018/04/14
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command: load, unload, display, help, test
14 # Modulefiles: remove/5.0
15 # Sub-Command:
16 #
17 # Comment: %C{
18 # Check the effect of 'remove-path' command on $env() array
19 # variable through the different modulefile evaluation mode
20 # }C%
21 #
22 ##############################################################################
23
24 skip_if_quick_mode
25
26 set module "remove/5.0"
27 set modulefile "$modpath/$module"
28 set modulefilere "$modpathre/$module"
29
30 #
31 # test load mode
32 #
33
34 # test with value not set to variable prior to load
35 set ans [list]
36 lappend ans [list unset TS1]
37 lappend ans [list set TS2 ""]
38 lappend ans [list set _LMFILES_ $modulefile]
39 lappend ans [list set LOADEDMODULES $module]
40 testouterr_cmd_re "sh" "load $module" $ans ""
41
42 # test with value set to variable prior to load (diff value than removed one)
43 setenv_var TS1 "no"
44 set ans [list]
45 lappend ans [list set TS1 "no"]
46 lappend ans [list set TS2 "no"]
47 lappend ans [list set _LMFILES_ $modulefile]
48 lappend ans [list set LOADEDMODULES $module]
49 testouterr_cmd_re "sh" "load $module" $ans ""
50
51 # test with value set to variable prior to load (value is removed one)
52 setenv_var TS1 "yes"
53 set ans [list]
54 lappend ans [list unset TS1]
55 lappend ans [list set TS2 ""]
56 lappend ans [list set _LMFILES_ $modulefile]
57 lappend ans [list set LOADEDMODULES $module]
58 testouterr_cmd_re "sh" "load $module" $ans ""
59
60 # test with value set to variable (as path var) prior to load (value is removed one)
61 setenv_path_var TS1 "yes"
62 set ans [list]
63 lappend ans [list unset TS1]
64 lappend ans [list set TS2 ""]
65 lappend ans [list set _LMFILES_ $modulefile]
66 lappend ans [list set LOADEDMODULES $module]
67 testouterr_cmd_re "sh" "load $module" $ans ""
68
69
70 #
71 # test unload mode
72 #
73
74 # test with module loaded but vanished env vars
75 unsetenv_path_var TS1
76 setenv_loaded_module $module $modulefile
77
78 set ans [list]
79 lappend ans [list unset TS2]
80 lappend ans [list unset _LMFILES_]
81 lappend ans [list unset LOADEDMODULES]
82 testouterr_cmd "sh" "unload $module" $ans ""
83
84 # test with value set to variable prior to unload (diff value than removed one)
85 setenv_var TS1 "no"
86 set ans [list]
87 lappend ans [list unset TS2]
88 lappend ans [list unset _LMFILES_]
89 lappend ans [list unset LOADEDMODULES]
90 testouterr_cmd "sh" "unload $module" $ans ""
91
92 # test with value set to variable prior to unload (value is removed one)
93 setenv_var TS1 "yes"
94 set ans [list]
95 lappend ans [list unset TS1]
96 lappend ans [list unset TS2]
97 lappend ans [list unset _LMFILES_]
98 lappend ans [list unset LOADEDMODULES]
99
100 # test with value set to variable (as path var) prior to load (value is removed one)
101 setenv_path_var TS1 "yes"
102 set ans [list]
103 lappend ans [list unset TS1]
104 lappend ans [list unset TS2]
105 lappend ans [list unset _LMFILES_]
106 lappend ans [list unset LOADEDMODULES]
107
108 # restore environment
109 unsetenv_loaded_module
110 unsetenv_path_var TS1
111
112
113 #
114 # test display mode
115 #
116
117 # test with value not set to variable prior to display
118 set tserr "$modlin
119 $modulefilere:
120
121 remove-path\tTS1 yes
122 setenv\t\tTS2 {}
123 $modlin"
124 testouterr_cmd_re "sh" "display $module" "" $tserr
125
126 # test with value set to variable prior to display (diff value than removed one)
127 setenv_var TS1 "no"
128 set tserr "$modlin
129 $modulefilere:
130
131 remove-path\tTS1 yes
132 setenv\t\tTS2 no
133 $modlin"
134 testouterr_cmd_re "sh" "display $module" "" $tserr
135
136 # test with value set to variable prior to display (value is removed one)
137 setenv_var TS1 "yes"
138 set tserr "$modlin
139 $modulefilere:
140
141 remove-path\tTS1 yes
142 setenv\t\tTS2 {}
143 $modlin"
144 testouterr_cmd_re "sh" "display $module" "" $tserr
145
146 # test with value set to variable (as path var) prior to display (value is removed one)
147 setenv_path_var TS1 "yes"
148 set tserr "$modlin
149 $modulefilere:
150
151 remove-path\tTS1 yes
152 setenv\t\tTS2 {}
153 $modlin"
154 testouterr_cmd_re "sh" "display $module" "" $tserr
155
156 # restore environment
157 unsetenv_path_var TS1
158
159
160 #
161 # test help mode
162 #
163
164 # test with value not set to variable prior to help
165 set tserr "$modlin
166 Module Specific Help for $modulefilere:
167
168 $warn_msgs: Unable to find ModulesHelp in $modulefilere.
169 $modlin"
170 testouterr_cmd_re "sh" "help $module" "" $tserr
171
172 # test with value set to variable prior to help (diff value than removed one)
173 setenv_var TS1 "no"
174 testouterr_cmd_re "sh" "help $module" "" $tserr
175
176 # test with value set to variable prior to help (value is removed one)
177 setenv_var TS1 "yes"
178 testouterr_cmd_re "sh" "help $module" "" $tserr
179
180 # test with value set to variable (as path var) prior to help (value is removed one)
181 setenv_path_var TS1 "yes"
182 testouterr_cmd_re "sh" "help $module" "" $tserr
183
184 # restore environment
185 unsetenv_path_var TS1
186
187
188 #
189 # test test mode
190 #
191
192 # test with value not set to variable prior to test
193 set tserr "$modlin
194 Module Specific Test for $modulefilere:
195
196 $warn_msgs: Unable to find ModulesTest in $modulefilere.
197 $modlin"
198 testouterr_cmd_re "sh" "test $module" "" $tserr
199
200 # test with value set to variable prior to test (diff value than removed one)
201 setenv_var TS1 "no"
202 testouterr_cmd_re "sh" "test $module" "" $tserr
203
204 # test with value set to variable prior to test (value is removed one)
205 setenv_var TS1 "yes"
206 testouterr_cmd_re "sh" "test $module" "" $tserr
207
208 # test with value set to variable (as path var) prior to test (value is removed one)
209 setenv_path_var TS1 "yes"
210 testouterr_cmd_re "sh" "test $module" "" $tserr
211
212 # restore environment
213 unsetenv_path_var TS1
214
215
216 #
217 # Cleanup
218 #
219
220 reset_test_env