Skip to content

Commit 217ff30

Browse files
committed
ts: test ignore_cache_subcmds config option
Clear MODULES_IGNORE_CACHE_SUBCMDS from test environment, add the new option to the config sub-command checks and craft specific tests verifying cache files are only ignored on the sub-commands listed in option value. Sub-command name alias resolution (add) and ml frontend translation to underlying load sub-command are also covered. These tests fail without the ignore_cache_subcmds option code change. Assisted-by: Claude:claude-fable-5 Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
1 parent 962170e commit 217ff30

4 files changed

Lines changed: 110 additions & 0 deletions

File tree

‎testsuite/install.00-init/010-environ.exp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ unsetenv_var MODULES_RESET_TARGET_STATE
168168

169169
# clean any cache configuration
170170
unsetenv_var MODULES_IGNORE_CACHE
171+
unsetenv_var MODULES_IGNORE_CACHE_SUBCMDS
171172
unsetenv_var MODULES_CACHE_BUFFER_BYTES
172173
unsetenv_var MODULES_CACHE_EXPIRY_SECS
173174

‎testsuite/modules.00-init/010-environ.exp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ unsetenv_var MODULES_RESET_TARGET_STATE
169169

170170
# clean any cache configuration
171171
unsetenv_var MODULES_IGNORE_CACHE
172+
unsetenv_var MODULES_IGNORE_CACHE_SUBCMDS
172173
unsetenv_var MODULES_CACHE_BUFFER_BYTES
173174
unsetenv_var MODULES_CACHE_EXPIRY_SECS
174175

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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, xavier.delaruelle@cea.fr
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

‎testsuite/modules.70-maint/220-config.exp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ array set configdfl [list\
8282
home [regsub -all "\(\[.+?\]\)" $install_moduleshome {\\\1}]\
8383
icase $install_icase\
8484
ignore_cache 0\
85+
ignore_cache_subcmds {}\
8586
ignore_user_rc 0\
8687
ignored_dirs {CVS RCS SCCS .svn .git .SYNC .sos}\
8788
implicit_default [expr {$install_implicitdefault eq {y}}]\
@@ -157,6 +158,7 @@ array set configvar [list\
157158
home MODULESHOME\
158159
icase MODULES_ICASE\
159160
ignore_cache MODULES_IGNORE_CACHE\
161+
ignore_cache_subcmds MODULES_IGNORE_CACHE_SUBCMDS\
160162
ignore_user_rc MODULES_IGNORE_USER_RC\
161163
implicit_default MODULES_IMPLICIT_DEFAULT\
162164
implicit_requirement MODULES_IMPLICIT_REQUIREMENT\

0 commit comments

Comments
 (0)