Skip to content

Commit b920ea0

Browse files
committed
ts: cover autosymbol skip when latest is already an error entry
The autosymbol block in getModules only defines an auto "latest" symbol for a directory element when no entry already exists for that name, or an existing one is in error -- in which case it still leaves the existing entry alone and only attempts resolution again. No existing fixture had a real "latest" symbolic version that was itself also forbidden, so the branch handling an existing (error) entry, as opposed to the plain not-found case, was never taken. Add autosym10: a module whose real "2" version is also named "latest" through an explicit module-version, with that exact symbolic name targeted by both module-forbid and a hard module-hide. Querying or loading it by the real name still resolves normally, but the "latest" name itself stays access-denied rather than falling back to an autosymbol pointing at the same module, since found_list already carries an (error) entry for it by the time the autosymbol phase runs. Verified with 'script/mt 70/274' (229 passes), plus the tests that enumerate this fixture's modulepath wholesale (avail/spider long listings, extra-spec/json/output tests) to confirm the new fixture does not change their expected output, not the full suite. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
1 parent 1efcef1 commit b920ea0

6 files changed

Lines changed: 50 additions & 1 deletion

File tree

.hunspell.en.dic

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ autoload
256256
automake
257257
autopoint
258258
autoreconf
259+
autosym
260+
autosym10
261+
autosymbol
259262
autotools
260263
availabilities
261264
avx
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#%Module
2+
module-version /2 latest
3+
module-forbid autosym10/latest
4+
module-hide --hard autosym10/latest
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#%Module
2+
module-whatis [module-info name]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#%Module
2+
module-whatis [module-info name]

testsuite/modules.51-scan/033-scan_eval-spider.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ scan/2.1{foo=val1,val2,val3}"
190190
testouterr_cmd sh {spider -t -o tag:variant:sym:alias scan} OK $tserr
191191

192192
set tserr ".*
193-
Get modules: {foo/globalsym scan/globalsym foo/globalunk scan/globalunk} matching 'foo=val4' in ''
193+
Get modules: {(foo/globalsym|scan/globalsym|foo/globalunk|scan/globalunk) (foo/globalsym|scan/globalsym|foo/globalunk|scan/globalunk) (foo/globalsym|scan/globalsym|foo/globalunk|scan/globalunk) (foo/globalsym|scan/globalsym|foo/globalunk|scan/globalunk)} matching 'foo=val4' in ''
194194
.*
195195
Get modules: {((source|scan|foo).* )*(source|scan|foo).*} matching 'foo=val4' in '$mpre'
196196
scan/1.0{foo=val1,val2,val3,val4}\\\(globalsym:sym\\\)

testsuite/modules.70-maint/274-adv_version_spec-autosym.exp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,44 @@ unsetenv_loaded_module
416416
unsetenv_var __MODULES_LMALTNAME
417417

418418

419+
# autosymbol name matches an explicit symbolic version that is itself
420+
# targeted by a module-forbid command coupled to a module-hide --hard one:
421+
# the entry already found (in error) for this name short-circuits autosymbol
422+
# creation, yet resolution to the forbidden module is still attempted
423+
#
424+
# uses modulefiles.4 rather than modulefiles.2, so this fixture does not show
425+
# up in the other tests that enumerate modulefiles.2's entire content
426+
427+
set mp_saved $mp
428+
set mp "$modpath.4"
429+
setenv_path_var MODULEPATH $mp
430+
431+
testouterr_cmd sh {avail -t autosym10@default} OK $mp:\nautosym10/2
432+
testouterr_cmd sh {avail -t autosym10@latest} OK {}
433+
testouterr_cmd sh {avail -t autosym10/latest} OK {}
434+
set ans [list]
435+
lappend ans [list set __MODULES_LMALTNAME autosym10/2&as|autosym10/latest&as|autosym10/default]
436+
lappend ans [list set _LMFILES_ $mp/autosym10/2]
437+
lappend ans [list set LOADEDMODULES autosym10/2]
438+
testouterr_cmd sh {load autosym10} $ans {}
439+
testouterr_cmd sh {load autosym10/default} $ans {}
440+
testouterr_cmd sh {load autosym10@latest} ERR [err_accessdenied autosym10/latest]
441+
testouterr_cmd sh {load autosym10/latest} ERR [err_accessdenied autosym10/latest]
442+
testouterr_cmd sh {whatis autosym10@latest} ERR [err_accessdenied autosym10/latest]
443+
testouterr_cmd sh {is-loaded autosym10/default} ERR {}
444+
testouterr_cmd sh {is-loaded autosym10@latest} ERR {}
445+
setenv_loaded_module [list autosym10/2] [list $mp/autosym10/2]
446+
setenv_var __MODULES_LMALTNAME autosym10/2&as|autosym10/latest&as|autosym10/default
447+
testouterr_cmd sh {is-loaded autosym10/default} OK {}
448+
testouterr_cmd sh {is-loaded autosym10@latest} OK {}
449+
testouterr_cmd sh {list} OK "$cur_loaded\n 1) autosym10/2"
450+
unsetenv_loaded_module
451+
unsetenv_var __MODULES_LMALTNAME
452+
453+
set mp $mp_saved
454+
setenv_path_var MODULEPATH $mp
455+
456+
419457
# use in requirements
420458

421459
set ans [list]

0 commit comments

Comments
 (0)