Debian Codegraph @

testsuite/install.00-init/030-options.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.00-init/%M%
6 # Revision: %I%
7 # First Edition: 2017/05/07
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command:
14 # Sub-Command:
15 #
16 # Comment: %C{
17 # Check selected installation options have been honored
18 # }C%
19 #
20 ##############################################################################
21
22
23 set bad_cmd "$error_msgs: Invalid command 'foo'"
24 set use_desc "Search path for module files \\(in search order\\):"
25 set moddir_header "$install_modulefilesdirre:"
26 set versdir_header "$install_versionfilesdirre:"
27 foreach mod [list dot module-git module-info modules null use.own] {
28 if {[info exists mod_examples]} {
29 append mod_examples "\n"
30 }
31 append mod_examples $mod
32 if {[lsearch -exact [split $install_loadedmodulesre :] $mod] != -1} {
33 append mod_examples { <L>}
34 }
35 }
36 set lm_list [split $install_loadedmodulesre ":"]
37
38 # check if modulefiles dir is part of default MODULEPATH
39 set modfilesdir_in_modpath 0
40 foreach modp [split $install_modulepath ":"] {
41 # adapt modulepath entry if it contains variable reference
42 regsub -all {\$[{]?[A-Za-z_][A-Za-z0-9_]*[}]?} $modp {.*} modp
43 if {[regexp "^$modp\$" $install_modulefilesdir]} {
44 set modfilesdir_in_modpath 1
45 break
46 }
47 }
48
49 # adapt modulepath entry if it contains variable reference
50 set modpath_listre [list]
51 foreach modp [split $install_modulepathre ":"] {
52 regsub -all {\$[{]?[A-Za-z_][A-Za-z0-9_]*[}]?} $modp {.*} modp
53 lappend modpath_listre $modp
54 }
55
56 #
57 # The tests
58 #
59
60 if {$install_setmanpath eq "y" && $install_builddoc ne "n"} {
61 if {$verbose} {
62 send_user "\tChecking man pages availability\n"
63 }
64 unsetenv_var MANPATH
65 foreach shell $shell_list {
66 # ask for all man page locations to ensure finding ours rather others installed on the system
67 testall_cmd_re "$shell" "man -a -w modulefile" ".*$install_mandirre/man5/modulefile.*" {} 0
68 testall_cmd_re "$shell" "man -a -w module" ".*$install_mandirre/man1/module.*" {} 0
69 }
70 } elseif {$verbose} {
71 send_user "\tSkipping man pages availability checks\n"
72 }
73
74 if {$install_setbinpath eq "y"} {
75 if {$verbose} {
76 send_user "\tChecking envml availability\n"
77 }
78 foreach shell $shell_list {
79 testall_cmd_re "$shell" "envml -h" "Usage:.*/envml .*" {} 0
80 }
81 if {$install_examplemodulefiles eq "y" && $install_loadedmodules eq "" \
82 && $modfilesdir_in_modpath} {
83 foreach shell $shell_list {
84 if {$shell eq {bash} || $shell eq {basheu} || [is_set_shell_startup_enabled] || ($shell eq {sh} && $sh_kind eq {bash})} {
85 testall_cmd "$shell" "envml null printenv LOADEDMODULES" "null" "" 0
86 } else {
87 testall_cmd "$shell" "envml null printenv LOADEDMODULES" "" "envml: module command not found..." 1
88 }
89 }
90 }
91
92 if {$verbose} {
93 send_user "\tChecking modulecmd availability\n"
94 }
95 foreach shell $shell_list {
96 if {$shell eq "basheu"} {
97 testall_cmd_re "$shell" "modulecmd bash --version" {} "Modules Release \\S+ (\\S+)" 0
98 } else {
99 testall_cmd_re "$shell" "modulecmd $shell --version" {} "Modules Release \\S+ (\\S+)" 0
100 }
101 }
102
103 if {$verbose} {
104 send_user "\tChecking other utilities availability\n"
105 }
106 foreach shell $shell_list {
107 switch -- $shell {
108 csh - tcsh {
109 testall_cmd "$shell" "which add.modules" "$install_bindir/add.modules" "" 0
110 testall_cmd "$shell" "which mkroot" "$install_bindir/mkroot" "" 0
111 }
112 ksh {
113 if {[string first { } $install_bindir] != -1} {
114 testall_cmd $shell {command -v add.modules} "'$install_bindir/add.modules'" {} 0
115 testall_cmd $shell {command -v mkroot} "'$install_bindir/mkroot'" {} 0
116 } else {
117 testall_cmd $shell {command -v add.modules} $install_bindir/add.modules {} 0
118 testall_cmd $shell {command -v mkroot} $install_bindir/mkroot {} 0
119 }
120 }
121 default {
122 testall_cmd "$shell" "command -v add.modules" "$install_bindir/add.modules" "" 0
123 testall_cmd "$shell" "command -v mkroot" "$install_bindir/mkroot" "" 0
124 }
125 }
126 }
127 } elseif {$verbose} {
128 send_user "\tSkipping envml availability checks\n"
129 send_user "\tSkipping modulecmd availability checks\n"
130 send_user "\tSkipping other utilities availability checks\n"
131 }
132
133 if {$install_modulepath ne ""} {
134 if {$verbose} {
135 send_user "\tChecking default modulepath setup\n"
136 }
137 foreach shell $shell_list {
138 testall_cmd_re "$shell" "module use" {} "$use_desc\n\\s+[join $modpath_listre {\n\\s+}]" 0
139 }
140 foreach shell $othlang_list {
141 testall_cmd_re "$shell" "use" {} "$use_desc\n\\s+[join $modpath_listre {\n\\s+}]" 0
142 }
143 } elseif {$verbose} {
144 send_user "\tSkipping default modulepath checks\n"
145 }
146
147 if {$install_examplemodulefiles eq "y" && $modfilesdir_in_modpath} {
148 if {$verbose} {
149 send_user "\tChecking example modulefiles installation\n"
150 }
151 set env(MODULES_TAG_ABBREV) {loaded=L}
152 foreach shell $shell_list {
153 testall_cmd_re "$shell" "module avail -t" {} "$moddir_header\n$mod_examples" 0
154 }
155 foreach shell $othlang_list {
156 testall_cmd_re "$shell" "avail,-t" {} "$moddir_header\n$mod_examples" 0
157 }
158 unset env(MODULES_TAG_ABBREV)
159 # check version-specific modulefile, related to versioning installation mode
160 if {$install_versioning eq "y"} {
161 # disable advanced version spec to correctly resolve version module
162 # when module version contains a branch name and '+' sign
163 setenv_var MODULES_ADVANCED_VERSION_SPEC 0
164 foreach shell $shell_list {
165 testall_cmd_re "$shell" "module load modules; module avail -t $install_version" {} "$versdir_header\n$install_versionre" 0
166 }
167 foreach shell $othlang_list {
168 testall_cmd_re "$shell" "load,modules:avail,-t,$install_version" {} "$versdir_header\n$install_versionre" 0
169 }
170 unsetenv_var MODULES_ADVANCED_VERSION_SPEC
171 }
172 } elseif {$verbose} {
173 send_user "\tSkipping example modulefiles installation checks\n"
174 }
175
176 if {$install_loadedmodules ne ""} {
177 if {$verbose} {
178 send_user "\tChecking default loaded modules setup\n"
179 }
180 foreach shell $shell_list {
181 testall_cmd_re "$shell" "module list -t" {} "$cur_loaded\n[join $lm_list {.*\n}]" 0
182 }
183 foreach shell $othlang_list {
184 testall_cmd_re "$shell" "list,-t" {} "$cur_loaded\n[join $lm_list {.*\n}]" 0
185 }
186 } elseif {$verbose} {
187 send_user "\tSkipping default loaded modules checks\n"
188 }
189
190 # basic test for MODULES_SILENT_SHELL_DEBUG, checking module answer is still present
191 # among the debugging output
192 if {$install_silentshdbgsupport eq y} {
193 if {$verbose} {
194 send_user "\tChecking MODULES_SILENT_SHELL_DEBUG\n"
195 send_user "\tSetup MODULES_SILENT_SHELL_DEBUG = '1'\n"
196 }
197 set env(MODULES_SILENT_SHELL_DEBUG) 1
198
199 set no_loadedmodules_inject 1
200 foreach shell $shell_sh_family {
201 if {[info exists shell_opts($shell)]} {
202 set shell_opts_save $shell_opts($shell)
203 set shell_opts($shell) "$shell_opts($shell)xv"
204 } else {
205 set shell_opts($shell) "-xv"
206 }
207 testall_cmd_re "$shell" "module --version" {} ".*Modules Release \\S+ (\\S+).*" 0
208 if {[info exists shell_opts_save]} {
209 set shell_opts($shell) $shell_opts_save
210 unset shell_opts_save
211 } else {
212 unset shell_opts($shell)
213 }
214 }
215 unset no_loadedmodules_inject
216
217 if {$verbose} {
218 send_user "\tSetup MODULES_SILENT_SHELL_DEBUG = '0'\n"
219 }
220 set env(MODULES_SILENT_SHELL_DEBUG) 0
221
222 set no_loadedmodules_inject 1
223 foreach shell $shell_sh_family {
224 if {[info exists shell_opts($shell)]} {
225 set shell_opts_save $shell_opts($shell)
226 set shell_opts($shell) "$shell_opts($shell)xv"
227 } else {
228 set shell_opts($shell) "-xv"
229 }
230 testall_cmd_re "$shell" "module --version" {} ".*Modules Release \\S+ (\\S+).*" 0
231 if {[info exists shell_opts_save]} {
232 set shell_opts($shell) $shell_opts_save
233 unset shell_opts_save
234 } else {
235 unset shell_opts($shell)
236 }
237 }
238 unset no_loadedmodules_inject
239
240 unset env(MODULES_SILENT_SHELL_DEBUG)
241 } elseif {$verbose} {
242 send_user "\tSkipping silent shell debug checks\n"
243 }
244
245 # test Windows-specific install
246 if {$verbose} {
247 send_user "\tChecking Windows-specific files availability\n"
248 }
249 testall_cmd_re "sh" "test -e '$install_initdir/cmd.cmd'" "" "" [expr {$install_windowssupport ne {y}}]
250 testall_cmd_re "sh" "test -e '$install_bindir/module.cmd'" "" "" [expr {$install_windowssupport ne {y}}]
251 testall_cmd_re "sh" "test -e '$install_bindir/ml.cmd'" "" "" [expr {$install_windowssupport ne {y}}]
252 testall_cmd_re "sh" "test -e '$install_bindir/envml.cmd'" "" "" [expr {$install_windowssupport ne {y}}]
253
254 # test Nagelfar lint capabilities
255 set nafelgar_script [glob -nocomplain nagelfar*/nagelfar.tcl]
256 if {[string length $nafelgar_script]} {
257 if {$verbose} {
258 send_user "\tChecking Nagelfar linting\n"
259 }
260 set tserr "Linting $testsuite_modpath/prepend/1.6\n"
261 append tserr " $error_msgs line 24: Wrong number of arguments (3) to \"prepend-path\""
262 testall_cmd sh "module config tcl_linter $nafelgar_script; module lint --redirect $testsuite_modpath/prepend/1.6" $tserr {} 1
263 set tserr "Linting $testsuite_modpath.3/lcompat/.version\n"
264 append tserr " $warn_msgs line 6: Variable \"ModuleVersion\" should be renamed \"ModulesVersion\"\n"
265 append tserr " $warn_msgs line 10: Variable \"ModuleVersion\" should be renamed \"ModulesVersion\"\n"
266 append tserr " $warn_msgs line 13: Variable \"ModuleVersion\" should be renamed \"ModulesVersion\""
267 testall_cmd sh "module config tcl_linter $nafelgar_script; module lint --redirect $testsuite_modpath.3/lcompat/.version" $tserr {} 0
268 }
269
270
271 # test env_modules Python module installation location
272 if {$verbose} {
273 send_user "\tChecking env_modules Python module installation\n"
274 }
275 if {$install_pythondir ne {}} {
276 set pythondir $install_pythondir
277 } else {
278 set pythondir $install_initdir
279 }
280 testall_cmd_re "sh" "test -f '$pythondir/env_modules.py'" "" "" 0
281 testall_cmd_re "sh" "test -f '$install_initdir/python.py'" "" "" 0
282
283 # test Python module is found if PYTHONPATH is defined
284 if {$install_setpythonpath eq {y} && [info exists shell_path(python)]} {
285 # create a temporary script that checks import of module command
286 # cannot pass the code as argument to python command due to the intermediate processing done by bin/install_* script
287 set temp_script $env(TESTSUITEDIR)/tempt_script.py
288 set fid [open $temp_script w]
289 puts $fid "from env_modules import module\nmodule('list', '-t')"
290 close $fid
291
292 if {$install_loadedmodules ne ""} {
293 set tserr "$cur_loaded\n[join $lm_list {.*\n}]"
294 } else {
295 set tserr $no_loaded
296 }
297
298 testall_cmd_re sh "$shell_path(python) $temp_script" {} $tserr 0
299
300 file delete $temp_script
301 }
302
303
304 #
305 # Clean up variables used in this test case
306 #
307
308 reset_test_env
309
310 # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: