| 1 |
############################################################################## |
| 2 |
# Modules Revision 3.0 |
| 3 |
# Providing a flexible user environment |
| 4 |
# |
| 5 |
# File: modules.90-avail/%M% |
| 6 |
# Revision: %I% |
| 7 |
# First Edition: 2018/12/18 |
| 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 |
# Check the module 'avail' command in no in depth mode |
| 19 |
# }C% |
| 20 |
# |
| 21 |
############################################################################## |
| 22 |
|
| 23 |
set mp "$modpath.indepth" |
| 24 |
set mpre "$modpathre.indepth" |
| 25 |
|
| 26 |
# setup specific environment |
| 27 |
setenv_path_var MODULEPATH $mp |
| 28 |
|
| 29 |
# ensure default tag abbreviation is defined |
| 30 |
setenv_var MODULES_TAG_ABBREV {auto-loaded=aL:loaded=L:hidden=H:hidden-loaded=H:forbidden=F:nearly-forbidden=nF} |
| 31 |
|
| 32 |
set ts_indepth "$mp: |
| 33 |
deepA/4/1/(ds) |
| 34 |
deepA/4/1/2/1 |
| 35 |
deepA/4/1/2/3 |
| 36 |
deepA/4/1/3/1(default) |
| 37 |
deepA/4/1/3/2 |
| 38 |
mod0 |
| 39 |
mod1/1 |
| 40 |
mod1/2 |
| 41 |
mod2/1(default) |
| 42 |
mod2/2 |
| 43 |
mod3/1(@) |
| 44 |
mod5/1 |
| 45 |
mod6/3/1/2/1 |
| 46 |
mod7/4/1 |
| 47 |
mod8/4/1(@) |
| 48 |
mod9/3/2(default) |
| 49 |
mod9/4/1 |
| 50 |
mod10 |
| 51 |
mod11/1(sym) |
| 52 |
mod11/2 |
| 53 |
mod30/2 |
| 54 |
modv/1(default)" |
| 55 |
|
| 56 |
set ts_noindepth "$mp: |
| 57 |
deepA/ |
| 58 |
mod0 |
| 59 |
mod1/ |
| 60 |
mod2/ |
| 61 |
mod3/ |
| 62 |
mod5/ |
| 63 |
mod6/ |
| 64 |
mod7/ |
| 65 |
mod8/ |
| 66 |
mod9/ |
| 67 |
mod10 |
| 68 |
mod11/ |
| 69 |
mod30/ |
| 70 |
modv/" |
| 71 |
|
| 72 |
# check various initialization ways |
| 73 |
testouterr_cmd sh {avail -t --indepth} OK $ts_indepth |
| 74 |
testouterr_cmd sh {avail -t --no-indepth --indepth} OK $ts_indepth |
| 75 |
testouterr_cmd sh {avail -t --no-indepth} OK $ts_noindepth |
| 76 |
testouterr_cmd sh {avail -t --indepth --no-indepth} OK $ts_noindepth |
| 77 |
|
| 78 |
skip_if_quick_mode |
| 79 |
|
| 80 |
if {$install_availindepth eq {y}} { |
| 81 |
testouterr_cmd sh {avail -t} OK $ts_indepth |
| 82 |
} else { |
| 83 |
testouterr_cmd sh {avail -t} OK $ts_noindepth |
| 84 |
} |
| 85 |
|
| 86 |
setenv_var MODULES_AVAIL_INDEPTH 0 |
| 87 |
testouterr_cmd sh {avail -t} OK $ts_noindepth |
| 88 |
testouterr_cmd sh {avail -t --indepth} OK $ts_indepth |
| 89 |
|
| 90 |
setenv_var MODULES_AVAIL_INDEPTH 1 |
| 91 |
testouterr_cmd sh {avail -t} OK $ts_indepth |
| 92 |
testouterr_cmd sh {avail -t --no-indepth} OK $ts_noindepth |
| 93 |
|
| 94 |
|
| 95 |
# test spider indepth has no impact |
| 96 |
setenv_var MODULES_AVAIL_INDEPTH 0 |
| 97 |
setenv_var MODULES_SPIDER_INDEPTH 1 |
| 98 |
testouterr_cmd sh {avail -t} OK $ts_noindepth |
| 99 |
setenv_var MODULES_SPIDER_INDEPTH 0 |
| 100 |
testouterr_cmd sh {avail -t --indepth} OK $ts_indepth |
| 101 |
setenv_var MODULES_AVAIL_INDEPTH 1 |
| 102 |
setenv_var MODULES_SPIDER_INDEPTH 0 |
| 103 |
testouterr_cmd sh {avail -t} OK $ts_indepth |
| 104 |
setenv_var MODULES_SPIDER_INDEPTH 1 |
| 105 |
testouterr_cmd sh {avail -t --no-indepth} OK $ts_noindepth |
| 106 |
|
| 107 |
|
| 108 |
# enable no in depth mode for the remaining tests |
| 109 |
setenv_var MODULES_AVAIL_INDEPTH 0 |
| 110 |
|
| 111 |
# long display |
| 112 |
set tserr "- Package/Alias $modlin.- Versions $modlin.- Last mod. $modlin\n$mpre: |
| 113 |
mod1/\\s+ |
| 114 |
mod10\\s+\[0-9\/]{10} \[0-9:]{8} |
| 115 |
mod11/\\s+" |
| 116 |
testouterr_cmd_re sh {avail -l mod1} OK $tserr |
| 117 |
|
| 118 |
# hidden modulefile only displayed if fully qualified |
| 119 |
testouterr_cmd sh {avail -t mod4} OK {} |
| 120 |
testouterr_cmd sh {avail -t mod4/.1} OK "$mp:\nmod4/.1 <H>" |
| 121 |
|
| 122 |
# returns elements of current depth level (need a trailing / to go down) |
| 123 |
testouterr_cmd sh {avail -t mod1} OK "$mp:\nmod1/\nmod10\nmod11/" |
| 124 |
testouterr_cmd sh {avail -t mod11} OK "$mp:\nmod11/" |
| 125 |
testouterr_cmd sh {avail -t mod1/} OK "$mp:\nmod1/1\nmod1/2" |
| 126 |
|
| 127 |
# check depth level recognition against wildcard characters |
| 128 |
testouterr_cmd sh {avail -t mod1*} OK "$mp:\nmod1/\nmod10\nmod11/" |
| 129 |
testouterr_cmd sh {avail -t mod1**} OK "$mp:\nmod1/\nmod10\nmod11/" |
| 130 |
testouterr_cmd sh {avail -t mod1/*} OK "$mp:\nmod1/1\nmod1/2" |
| 131 |
testouterr_cmd sh {avail -t mod1/?} OK "$mp:\nmod1/1\nmod1/2" |
| 132 |
testouterr_cmd sh {avail -t mod1/??} OK {} |
| 133 |
testouterr_cmd sh {avail -t mod1*/*} OK "$mp:\nmod1/1\nmod1/2\nmod11/1(sym)\nmod11/2" |
| 134 |
testouterr_cmd sh {avail -t mod1?/} OK "$mp:\nmod11/1(sym)\nmod11/2" |
| 135 |
testouterr_cmd sh {avail -t mod1?/*} OK "$mp:\nmod11/1(sym)\nmod11/2" |
| 136 |
testouterr_cmd sh {avail -t mod1?} OK "$mp:\nmod10\nmod11/" |
| 137 |
testouterr_cmd sh {avail -t mod1?*} OK "$mp:\nmod10\nmod11/" |
| 138 |
testouterr_cmd sh {avail -t mod1*?} OK "$mp:\nmod10\nmod11/" |
| 139 |
testouterr_cmd sh {avail -t mod??} OK "$mp:\nmod10\nmod11/\nmod30/" |
| 140 |
testouterr_cmd sh {avail -t mod?*?} OK "$mp:\nmod10\nmod11/\nmod30/" |
| 141 |
testouterr_cmd sh {avail -t mod??/} OK "$mp:\nmod11/1(sym)\nmod11/2\nmod30/2" |
| 142 |
testouterr_cmd sh {avail -t mod??/*} OK "$mp:\nmod11/1(sym)\nmod11/2\nmod30/2" |
| 143 |
testouterr_cmd sh {avail -t mod??/?} OK "$mp:\nmod11/1(sym)\nmod11/2\nmod30/2" |
| 144 |
testouterr_cmd sh {avail -t mod??/2} OK "$mp:\nmod11/2\nmod30/2" |
| 145 |
testouterr_cmd sh {avail -t mod2?} OK {} |
| 146 |
testouterr_cmd sh {avail -t mod2?/} OK {} |
| 147 |
|
| 148 |
# test no in depth mode on various sub-directories |
| 149 |
testouterr_cmd sh {avail -t mod2/} OK "$mp:\nmod2/1(default)\nmod2/2" |
| 150 |
testouterr_cmd sh {avail -t mod2/default} OK "$mp:\nmod2/1(default)" |
| 151 |
testouterr_cmd sh {avail -t mod3/} OK "$mp:\nmod3/1(@)" |
| 152 |
testouterr_cmd sh {avail -t mod5/} OK "$mp:\nmod5/1" |
| 153 |
testouterr_cmd sh {avail -t mod6/} OK "$mp:\nmod6/3/" |
| 154 |
testouterr_cmd sh {avail -t mod6/3} OK "$mp:\nmod6/3/" |
| 155 |
testouterr_cmd sh {avail -t mod6/3/} OK "$mp:\nmod6/3/1/" |
| 156 |
testouterr_cmd sh {avail -t mod6/3/1/2} OK "$mp:\nmod6/3/1/2/" |
| 157 |
testouterr_cmd sh {avail -t mod6/3/1/2/} OK "$mp:\nmod6/3/1/2/1" |
| 158 |
testouterr_cmd sh {avail -t mod6/?/1/2/} OK "$mp:\nmod6/3/1/2/1" |
| 159 |
testouterr_cmd sh {avail -t mod6/?/2/2/} OK {} |
| 160 |
testouterr_cmd sh {avail -t mod6/?/2/6/7/} OK {} |
| 161 |
testouterr_cmd sh {avail -t mod7/} OK "$mp:\nmod7/4/" |
| 162 |
testouterr_cmd sh {avail -t mod7/4/} OK "$mp:\nmod7/4/1" |
| 163 |
testouterr_cmd sh {avail -t mod8/} OK "$mp:\nmod8/4/" |
| 164 |
testouterr_cmd sh {avail -t mod8/4/} OK "$mp:\nmod8/4/1(@)" |
| 165 |
testouterr_cmd sh {avail -t mod9/} OK "$mp:\nmod9/3/\nmod9/4/" |
| 166 |
testouterr_cmd sh {avail -t mod9/4/} OK "$mp:\nmod9/4/1" |
| 167 |
testouterr_cmd sh {avail -t mod11/sym} OK "$mp:\nmod11/1(sym)" |
| 168 |
testouterr_cmd sh {avail -t mod?/3/} OK "$mp:\nmod6/3/1/\nmod9/3/2(default)" |
| 169 |
|
| 170 |
# check impact of only latest and only default output filtering |
| 171 |
testouterr_cmd sh {avail -t -d} OK [if_implicitdefault $ts_noindepth $mp:\nmod0\nmod2/\nmod10\nmodv/] |
| 172 |
testouterr_cmd sh {avail -t -L} OK $ts_noindepth |
| 173 |
testouterr_cmd sh {avail -t -d mod2} OK "$mp:\nmod2/" |
| 174 |
testouterr_cmd sh {avail -t -L mod2} OK "$mp:\nmod2/" |
| 175 |
testouterr_cmd sh {avail -t -d mod2/} OK "$mp:\nmod2/1(default)" |
| 176 |
testouterr_cmd sh {avail -t -L mod2/} OK "$mp:\nmod2/2" |
| 177 |
testouterr_cmd sh {avail -t -d mod1*} OK [if_implicitdefault $mp:\nmod1/\nmod10\nmod11/ $mp:\nmod10] |
| 178 |
testouterr_cmd sh {avail -t -L mod1*} OK "$mp:\nmod1/\nmod10\nmod11/" |
| 179 |
testouterr_cmd sh {avail -t -d mod1*/*} OK [if_implicitdefault "$mp:\nmod1/2\nmod11/2"] |
| 180 |
testouterr_cmd sh {avail -t -L mod1*/*} OK "$mp:\nmod1/2\nmod11/2" |
| 181 |
testouterr_cmd sh {avail -t -d mod1?/} OK [if_implicitdefault "$mp:\nmod11/2"] |
| 182 |
testouterr_cmd sh {avail -t -L mod1?/} OK "$mp:\nmod11/2" |
| 183 |
# contains search-match matches "/" character |
| 184 |
testouterr_cmd sh {avail -t -d mod2?} OK [if_searchcontains "$mp:\nmod2/" {}] |
| 185 |
testouterr_cmd sh {avail -t -L mod2?} OK [if_searchcontains "$mp:\nmod2/" {}] |
| 186 |
testouterr_cmd sh {avail -t -d mod2?/} OK {} |
| 187 |
testouterr_cmd sh {avail -t -L mod2?/} OK {} |
| 188 |
testouterr_cmd sh {avail -t */*/} OK "$mp:\ndeepA/4/1/(ds)\nmod6/3/1/\nmod7/4/1\nmod8/4/1(@)\nmod9/3/2(default)\nmod9/4/1" |
| 189 |
testouterr_cmd sh {avail -t -d */*/} OK [if_implicitdefault "$mp:\ndeepA/4/1/(ds)\nmod6/3/1/\nmod7/4/1\nmod8/4/1(@)\nmod9/3/2(default)\nmod9/4/1" "$mp:\nmod9/3/2(default)"] |
| 190 |
testouterr_cmd sh {avail -t -L */*/} OK "$mp:\ndeepA/4/1/(ds)\nmod6/3/1/\nmod7/4/1\nmod8/4/1(@)\nmod9/3/2(default)\nmod9/4/1" |
| 191 |
testouterr_cmd sh {avail -t -d deepA/4/1/3/} OK "$mp:\ndeepA/4/1/3/1(default)" |
| 192 |
testouterr_cmd sh {avail -t -L deepA/4/1/3/} OK "$mp:\ndeepA/4/1/3/2" |
| 193 |
# specific tests to improve modEq procedure coverage |
| 194 |
setenv_var MODULES_EXTENDED_DEFAULT 1 |
| 195 |
testouterr_cmd sh {avail -t -L */*/} OK "$mp:\ndeepA/4/1/(ds)\nmod6/3/1/\nmod7/4/1\nmod8/4/1(@)\nmod9/3/2(default)\nmod9/4/1" |
| 196 |
testouterr_cmd sh {avail -i -t -L */*/} OK "$mp:\ndeepA/4/1/(ds)\nmod6/3/1/\nmod7/4/1\nmod8/4/1(@)\nmod9/3/2(default)\nmod9/4/1" |
| 197 |
unsetenv_var MODULES_EXTENDED_DEFAULT |
| 198 |
|
| 199 |
# test no in depth mode and contains search match mode |
| 200 |
testouterr_cmd sh {avail -t -C od2/} OK "$mp:\nmod2/1(default)\nmod2/2" |
| 201 |
testouterr_cmd sh {avail -t -C 1} OK "$mp:\nmod1/\nmod10\nmod11/" |
| 202 |
testouterr_cmd sh {avail -t -C ul} OK {} |
| 203 |
testouterr_cmd sh {avail -t -C 6/3/1} OK "$mp:\nmod6/3/1/" |
| 204 |
|
| 205 |
# usage of no indepth mode avail in modulefile |
| 206 |
unsetenv_var MODULES_AVAIL_INDEPTH |
| 207 |
set tserr "$mp: |
| 208 |
mod1/ |
| 209 |
mod10 |
| 210 |
mod11/ |
| 211 |
|
| 212 |
$mp: |
| 213 |
mod10 |
| 214 |
mod11/ |
| 215 |
|
| 216 |
$mp: |
| 217 |
mod1/1 |
| 218 |
mod1/2 |
| 219 |
mod10 |
| 220 |
mod11/1(sym) |
| 221 |
mod11/2 |
| 222 |
|
| 223 |
$mp: |
| 224 |
mod1/1 |
| 225 |
mod1/2 |
| 226 |
|
| 227 |
$mp: |
| 228 |
mod1/1 |
| 229 |
mod1/2 |
| 230 |
mod11/1(sym) |
| 231 |
mod11/2 |
| 232 |
|
| 233 |
$mp: |
| 234 |
mod11/1(sym) |
| 235 |
mod11/2" |
| 236 |
set ts_indepth "$mp: |
| 237 |
mod1/1 |
| 238 |
mod1/2 |
| 239 |
mod10 |
| 240 |
mod11/1(sym) |
| 241 |
mod11/2 |
| 242 |
|
| 243 |
$tserr" |
| 244 |
set ts_noindepth "$mp: |
| 245 |
mod1/ |
| 246 |
mod10 |
| 247 |
mod11/ |
| 248 |
|
| 249 |
$tserr" |
| 250 |
set ans [list] |
| 251 |
lappend ans [list set _LMFILES_ $mp/mod0] |
| 252 |
lappend ans [list set LOADEDMODULES mod0] |
| 253 |
if {$install_availindepth eq {y}} { |
| 254 |
testouterr_cmd sh {load mod0} $ans $ts_indepth |
| 255 |
# argument passed on the command line for a load sub-command is ignored |
| 256 |
# by the underlying avail commands |
| 257 |
testouterr_cmd sh {load mod0 --indepth} $ans $ts_indepth |
| 258 |
testouterr_cmd sh {load mod0 --no-indepth} $ans $ts_indepth |
| 259 |
} else { |
| 260 |
testouterr_cmd sh {load mod0} $ans $ts_noindepth |
| 261 |
testouterr_cmd sh {load mod0 --indepth} $ans $ts_noindepth |
| 262 |
testouterr_cmd sh {load mod0 --no-indepth} $ans $ts_noindepth |
| 263 |
} |
| 264 |
|
| 265 |
# test modulepath and module names containing space character |
| 266 |
setenv_var MODULES_AVAIL_INDEPTH 0 |
| 267 |
set mp "$modpath wspace" |
| 268 |
if {!$is_symlink_supported} { |
| 269 |
send_user "\tskipping tests over '$mp' modulepath as symbolic links are not supported on filesystem\n" |
| 270 |
} else { |
| 271 |
|
| 272 |
setenv_path_var MODULEPATH $mp |
| 273 |
testouterr_cmd sh {avail -t spacen} OK "$mp:\nspacen/\nspacenb/(dw s)\nspacenc/" |
| 274 |
testouterr_cmd sh {avail -t space\ ya} OK "$mp:\n'space ya'/" |
| 275 |
|
| 276 |
} |
| 277 |
|
| 278 |
set mp "$modpath wspac " |
| 279 |
# create modulepath finishing by space on the file (it crashes git checkout on Windows if saved in repo) |
| 280 |
# MSYS environment does not support anymore such test |
| 281 |
if {!$is_symlink_supported || $os_name eq {msys} || [catch {file link -symbolic $mp modulefiles.2}]} { |
| 282 |
send_user "\tskipping tests over '$mp' modulepath as symbolic links are not supported on filesystem or cannot be created\n" |
| 283 |
} else { |
| 284 |
|
| 285 |
# generate modulefiles that cannot be recorded in git repository |
| 286 |
create_endspace_test_modulefiles |
| 287 |
|
| 288 |
setenv_path_var MODULEPATH $mp |
| 289 |
testouterr_cmd sh {avail -t space\ y\ } OK "$mp:\n'space y '/" |
| 290 |
|
| 291 |
# delete modulepath link created for the test |
| 292 |
file delete $mp |
| 293 |
|
| 294 |
# delete generated modulefiles |
| 295 |
delete_endspace_test_modulefiles |
| 296 |
|
| 297 |
} |
| 298 |
|
| 299 |
|
| 300 |
# |
| 301 |
# Cleanup |
| 302 |
# |
| 303 |
|
| 304 |
reset_test_env |