| 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: 2026/08/23 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Xavier Delaruelle, [email protected] |
| 11 |
# |
| 12 |
# Description: Testuite testsequence |
| 13 |
# Command: avail, whatis, load, add, ml |
| 14 |
# Modulefiles: |
| 15 |
# Sub-Command: |
| 16 |
# |
| 17 |
# Comment: %C{ |
| 18 |
# Test ignore_cache_subcmds configuration option |
| 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 |
|
| 32 |
setenv_var MODULEPATH $mp1 |
| 33 |
|
| 34 |
# tests with empty cache file |
| 35 |
create_dummy_cachefile $mp1 |
| 36 |
|
| 37 |
set tserr_avail "bar/1.0 |
| 38 |
bar/2.0 |
| 39 |
foo/1.0" |
| 40 |
set tserr_whatis "$modlin [escre $mp1] $modlin |
| 41 |
\\s+foo/1.0: foo/1.0" |
| 42 |
set ans_load [list] |
| 43 |
lappend ans_load [list set _LMFILES_ $mp1/bar/1.0] |
| 44 |
lappend ans_load [list set LOADEDMODULES bar/1.0] |
| 45 |
|
| 46 |
# option unset: cache used whatever the sub-command |
| 47 |
testouterr_cmd sh {avail -t -o } OK {} |
| 48 |
testouterr_cmd sh {whatis} OK {} |
| 49 |
testouterr_cmd sh {load bar/1.0} ERR $err_path'bar/1.0' |
| 50 |
|
| 51 |
# cache only ignored on listed sub-commands |
| 52 |
setenv_var MODULES_IGNORE_CACHE_SUBCMDS load |
| 53 |
testouterr_cmd sh {avail -t -o } OK {} |
| 54 |
testouterr_cmd sh {whatis} OK {} |
| 55 |
testouterr_cmd sh {load bar/1.0} $ans_load {} |
| 56 |
# sub-command name alias resolves to the sub-command set in option value |
| 57 |
testouterr_cmd sh {add bar/1.0} $ans_load {} |
| 58 |
# ml frontend translates to the underlying load sub-command |
| 59 |
testouterr_cmd sh {ml bar/1.0} $ans_load {} |
| 60 |
# ml frontend with explicit sub-command or alias resolves to it |
| 61 |
testouterr_cmd sh {ml load bar/1.0} $ans_load {} |
| 62 |
testouterr_cmd sh {ml add bar/1.0} $ans_load {} |
| 63 |
|
| 64 |
# ml is not a value to match: it translates to underlying load or unload |
| 65 |
setenv_var MODULES_IGNORE_CACHE_SUBCMDS ml |
| 66 |
testouterr_cmd sh {ml bar/1.0} ERR $err_path'bar/1.0' |
| 67 |
testouterr_cmd sh {load bar/1.0} ERR $err_path'bar/1.0' |
| 68 |
|
| 69 |
setenv_var MODULES_IGNORE_CACHE_SUBCMDS avail:whatis |
| 70 |
testouterr_cmd sh {avail -t -o } OK $tserr_avail |
| 71 |
testouterr_cmd_re sh {whatis} OK $tserr_whatis |
| 72 |
testouterr_cmd sh {load bar/1.0} ERR $err_path'bar/1.0' |
| 73 |
|
| 74 |
# value that does not match a sub-command name has no effect |
| 75 |
setenv_var MODULES_IGNORE_CACHE_SUBCMDS foo:load |
| 76 |
testouterr_cmd sh {avail -t -o } OK {} |
| 77 |
testouterr_cmd sh {load bar/1.0} $ans_load {} |
| 78 |
|
| 79 |
# ignore_cache option applies whatever the sub-command |
| 80 |
setenv_var MODULES_IGNORE_CACHE_SUBCMDS load |
| 81 |
setenv_var MODULES_IGNORE_CACHE 1 |
| 82 |
testouterr_cmd sh {avail -t -o } OK $tserr_avail |
| 83 |
testouterr_cmd sh {load bar/1.0} $ans_load {} |
| 84 |
unsetenv_var MODULES_IGNORE_CACHE |
| 85 |
setenv_var MODULES_IGNORE_CACHE 0 |
| 86 |
testouterr_cmd sh {avail -t -o } OK {} |
| 87 |
testouterr_cmd sh {load bar/1.0} $ans_load {} |
| 88 |
unsetenv_var MODULES_IGNORE_CACHE |
| 89 |
|
| 90 |
# --ignore-cache command line switch applies whatever the sub-command |
| 91 |
testouterr_cmd sh {avail --ignore-cache -t -o } OK $tserr_avail |
| 92 |
testouterr_cmd sh {load bar/1.0 --ignore-cache} $ans_load {} |
| 93 |
|
| 94 |
unsetenv_var MODULES_IGNORE_CACHE_SUBCMDS |
| 95 |
|
| 96 |
|
| 97 |
# |
| 98 |
# Cleanup |
| 99 |
# |
| 100 |
|
| 101 |
file delete $mp1cache |
| 102 |
|
| 103 |
# delete created files and dirs |
| 104 |
delete_module_setup $mp1 [array names file_arr] $dir_list |
| 105 |
|
| 106 |
reset_test_env |