From b1bbd88f55279a5ceaa38d3a746aebce18f7db52 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 23 Aug 2026 17:54:04 +0200 Subject: [PATCH 1/4] Add ignore_cache_subcmds configuration option Module cache file aggregates the content of all the modulercs and modulefiles found in a modulepath. When a module search occurs, this whole file is evaluated even if the search targets specific modules. On setups with a very large number of modulefiles, resulting in cache files of several megabytes, evaluating the whole cache file may take longer than walking through the modulepath directory to find the few requested modules. Add the ignore_cache_subcmds configuration option that defines a list of module sub-commands on which module cache files are ignored. When one of these sub-commands is run, modulepath directories are walked through to search modules instead of relying on their cache file. Option is compared against the resolved top-level sub-command name, obtained with the new topCommandName helper procedure, so sub-command name aliases (like add for load) resolve to their target sub-command and cache is also ignored for the searches that the evaluated modulefiles trigger. The ml command used without a sub-command name translates to the underlying load or unload sub-command it is currently processing. When configuration is modified it sets the MODULES_IGNORE_CACHE_SUBCMDS environment variable. Fixes #563 Assisted-by: Claude:claude-fable-5 Signed-off-by: Xavier Delaruelle --- .hunspell.en.dic | 2 ++ tcl/cache.tcl.in | 6 ++++-- tcl/init.tcl.in | 1 + tcl/main.tcl.in | 10 ++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.hunspell.en.dic b/.hunspell.en.dic index fd5ced893..8eab7b4bb 100644 --- a/.hunspell.en.dic +++ b/.hunspell.en.dic @@ -1595,3 +1595,5 @@ isdir bizstyle importlib pythondir +subcmds +topCommandName diff --git a/tcl/cache.tcl.in b/tcl/cache.tcl.in index f0607ffbe..7cde40a87 100644 --- a/tcl/cache.tcl.in +++ b/tcl/cache.tcl.in @@ -380,8 +380,10 @@ proc limited-access-directory {dir} { proc findModulesInCacheFile {modpath mod depthlvl fetch_mtime} { set cachefile [getModuleCacheFilename $modpath] - # check if cache should be ignored - if {[getConf ignore_cache]} { + # check if cache should be ignored, either globally or for currently + # running top-level sub-command + if {[getConf ignore_cache] || [topCommandName] in [getConfList\ + ignore_cache_subcmds]} { return [list 0 {}] } diff --git a/tcl/init.tcl.in b/tcl/init.tcl.in index 1aacda8af..b70f0459e 100644 --- a/tcl/init.tcl.in +++ b/tcl/init.tcl.in @@ -104,6 +104,7 @@ array set g_config_defs [list\ home {MODULESHOME {@moduleshome@} 0 s}\ icase {MODULES_ICASE @icase@ 0 s {never search always}}\ ignore_cache {MODULES_IGNORE_CACHE 0 0 b {0 1}}\ + ignore_cache_subcmds {MODULES_IGNORE_CACHE_SUBCMDS {} 0 l}\ ignore_user_rc {MODULES_IGNORE_USER_RC 0 0 b {0 1}}\ ignored_dirs {{} {CVS RCS SCCS .svn .git .SYNC .sos} 0 o}\ implicit_requirement {MODULES_IMPLICIT_REQUIREMENT @implicitrequirement@ 0\ diff --git a/tcl/main.tcl.in b/tcl/main.tcl.in index f0604bf85..9c88f405d 100644 --- a/tcl/main.tcl.in +++ b/tcl/main.tcl.in @@ -54,6 +54,16 @@ proc aboveCommandName {} { return [lindex [getState commandname] end-1] } +# get top-level command name, with ml frontend translated onto the +# underlying load or unload sub-command it currently processes +proc topCommandName {} { + set subcmd [topState commandname] + if {$subcmd eq {ml}} { + set subcmd [topState eval_context] + } + return $subcmd +} + proc ongoingCommandName {commandName} { return [expr {[lsearch -exact [getState commandname] $commandName] != -1}] } From 84c76ad9e2f34d6aca0da23c82cbd2b2a5657bb7 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 23 Aug 2026 17:54:04 +0200 Subject: [PATCH 2/4] init: complete ignore_cache_subcmds option Add ignore_cache_subcmds to the configuration option names proposed by the bash, fish, tcsh and zsh completion scripts for the config sub-command. Assisted-by: Claude:claude-fable-5 Signed-off-by: Xavier Delaruelle --- init/Makefile | 2 +- init/fish_completion | 2 +- init/zsh-functions/_module.in | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/init/Makefile b/init/Makefile index c50407e32..244a25fe5 100644 --- a/init/Makefile +++ b/init/Makefile @@ -153,7 +153,7 @@ comp_stashpop_opts := --force -f comp_source_opts := --auto --no-auto --force -f comp_path_opts := -d --delim --duplicates comp_rm_path_opts := -d --delim --index -comp_config_opts := --dump-state --reset abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact csh_limit domainname editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_user_rc ignored_dirs implicit_default implicit_requirement init_envvars info_extension linked_envvars list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml modulepath_ignore nearly_forbidden_days non_exportable_tags pager paginate path_entry_reorder protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug siteconfig source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_ext_lib tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277 +comp_config_opts := --dump-state --reset abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact csh_limit domainname editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_cache_subcmds ignore_user_rc ignored_dirs implicit_default implicit_requirement init_envvars info_extension linked_envvars list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml modulepath_ignore nearly_forbidden_days non_exportable_tags pager paginate path_entry_reorder protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug siteconfig source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_ext_lib tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277 define translate-in-script $(ECHO_GEN) diff --git a/init/fish_completion b/init/fish_completion index e0b84c68c..6a12b5544 100644 --- a/init/fish_completion +++ b/init/fish_completion @@ -76,7 +76,7 @@ complete -c module -n '__fish_module_use_stashlist' -f -a "(module stashlist --c /Stash collection list\$/d; \ /:\$/d; \ /:ERROR:/d;')" -complete -c module -n '__fish_module_use_config' -f -a "--dump-state --reset abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact csh_limit domainname editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_user_rc ignored_dirs implicit_default implicit_requirement init_envvars info_extension linked_envvars list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml modulepath_ignore nearly_forbidden_days non_exportable_tags pager paginate path_entry_reorder protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug siteconfig source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_ext_lib tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277" +complete -c module -n '__fish_module_use_config' -f -a "--dump-state --reset abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact csh_limit domainname editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_cache_subcmds ignore_user_rc ignored_dirs implicit_default implicit_requirement init_envvars info_extension linked_envvars list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml modulepath_ignore nearly_forbidden_days non_exportable_tags pager paginate path_entry_reorder protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug siteconfig source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_ext_lib tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277" complete -f -n '__fish_module_no_subcommand' -c module -a 'help' --description 'Print this or modulefile(s) help info' complete -f -n '__fish_module_no_subcommand' -c module -a 'avail' --description 'List all or matching available modules' diff --git a/init/zsh-functions/_module.in b/init/zsh-functions/_module.in index f7084d2be..661c6a94a 100644 --- a/init/zsh-functions/_module.in +++ b/init/zsh-functions/_module.in @@ -407,7 +407,7 @@ _module() { _arguments \ '--dump-state[Report each state value of current Modules execution]' \ '--reset[Unset environment variable relative to configuration key]' \ - '1:configuration key:(abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact csh_limit domainname editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_user_rc ignored_dirs implicit_default implicit_requirement init_envvars info_extension linked_envvars list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml modulepath_ignore nearly_forbidden_days non_exportable_tags pager paginate path_entry_reorder protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug siteconfig source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_ext_lib tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277)' \ + '1:configuration key:(abort_on_error advanced_version_spec auto_handling avail_indepth avail_output avail_terse_output cache_buffer_bytes cache_expiry_secs collection_pin_version collection_pin_tag collection_target color colors conflict_unload contact csh_limit domainname editor extended_default extra_siteconfig hide_auto_loaded home icase ignore_cache ignore_cache_subcmds ignore_user_rc ignored_dirs implicit_default implicit_requirement init_envvars info_extension linked_envvars list_output list_terse_output locked_configs logged_events logger mcookie_check mcookie_version_check ml modulepath_ignore nearly_forbidden_days non_exportable_tags pager paginate path_entry_reorder protected_envvars quarantine_support rcfile redirect_output require_via reset_target_state run_quarantine search_match set_shell_startup shells_with_ksh_fpath silent_shell_debug siteconfig source_cache spider_indepth spider_output spider_terse_output sticky_purge tag_abbrev tag_color_name tcl_ext_lib tcl_linter term_background term_width unique_name_loaded unload_match_order variant_shortcut verbosity wa_277)' \ && ret=0 ;; (edit) From 6bfa2b99b425127fce6b4ea21b2485e1814fae46 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 23 Aug 2026 17:54:04 +0200 Subject: [PATCH 3/4] doc: describe ignore_cache_subcmds config option Describe the ignore_cache_subcmds configuration option and its associated MODULES_IGNORE_CACHE_SUBCMDS environment variable in the module man page, configuration option table, release notes, migration guide and module cache design notes. Assisted-by: Claude:claude-fable-5 Signed-off-by: Xavier Delaruelle --- INSTALL.rst | 2 ++ MIGRATING.rst | 20 ++++++++++++++++ NEWS.rst | 8 +++++++ doc/source/changes.rst | 6 +++-- doc/source/design/module-cache.rst | 15 ++++++++++++ doc/source/module.rst | 37 ++++++++++++++++++++++++++++++ 6 files changed, 86 insertions(+), 2 deletions(-) diff --git a/INSTALL.rst b/INSTALL.rst index 208eec0e4..832c3a1fe 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -1792,6 +1792,8 @@ installation. | :mconfig:`ignore_cache` | ``0`` | :envvar:`MODULES_IGNORE_CACHE`, | | | | | | :option:`--ignore-cache` | | | +-----------------------------------+----------------------------------------------+----------------------------------------------+--------------+-----------+ +| :mconfig:`ignore_cache_subcmds` | *Empty by default* | :envvar:`MODULES_IGNORE_CACHE_SUBCMDS` | | | ++-----------------------------------+----------------------------------------------+----------------------------------------------+--------------+-----------+ | :mconfig:`ignore_user_rc` | ``0`` | :envvar:`MODULES_IGNORE_USER_RC`, | | | | | | :option:`--ignore-user-rc` | | | +-----------------------------------+----------------------------------------------+----------------------------------------------+--------------+-----------+ diff --git a/MIGRATING.rst b/MIGRATING.rst index 7bd255660..2802b13ce 100644 --- a/MIGRATING.rst +++ b/MIGRATING.rst @@ -80,6 +80,26 @@ These measurements were obtained on a system where all modulefiles are stored on local flash storage. If your modulefiles reside on a shared network filesystem, using a `Module cache`_ is strongly recommended. +A module cache file aggregates the content of all the modulercs and +modulefiles found in a modulepath and this whole file is evaluated when a +module search occurs, even if the search targets specific modules. On setups +with a very large number of modulefiles, resulting in cache files of several +megabytes, evaluating the whole cache file may take longer than walking +through the modulepath directory to find the few requested modules. The new +:mconfig:`ignore_cache_subcmds` configuration option defines a list of +module sub-commands on which module cache files are ignored. For instance to +keep cache benefit on listing sub-commands but avoid its penalty on targeted +ones: + +.. parsed-literal:: + + :ps:`$` module config ignore_cache_subcmds load:try-load:load-any + +When the configuration option is changed from its default value using the +:subcmd:`config` sub-command, the :envvar:`MODULES_IGNORE_CACHE_SUBCMDS` +environment variable is defined accordingly. See +:envvar:`MODULES_IGNORE_CACHE_SUBCMDS` for details. + Reorder existing entries in path-like variables ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/NEWS.rst b/NEWS.rst index c19c09357..8baa7c09c 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -230,6 +230,14 @@ Modules 5.7.0 (not yet released) :instopt:`--enable-set-pythonpath` adds this directory to :envvar:`PYTHONPATH` instead of the Modules ``init`` directory. (fix issue #643) +* Introduce :mconfig:`ignore_cache_subcmds` configuration option that + defines a list of module sub-commands on which module cache files are + ignored. It is useful when cache files are large: a sub-command targeting + specific modules (like :subcmd:`load`) may find them faster by walking + through modulepath directories than by evaluating whole cache files. When + :mconfig:`ignore_cache_subcmds` is changed with :subcmd:`config` + sub-command, it sets the :envvar:`MODULES_IGNORE_CACHE_SUBCMDS` + environment variable. (fix issue #563) .. _5.6 release notes: diff --git a/doc/source/changes.rst b/doc/source/changes.rst index f4c3e8a14..0a83085bf 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -1108,7 +1108,8 @@ The following environment variables appeared on Modules 5. | | :envvar:`MODULES_LINKED_ENVVARS`, | | | :envvar:`MODULES_INIT_ENVVARS`, | | | :envvar:`MODULES_DOMAINNAME`, | -| | :envvar:`MODULES_MODULEPATH_IGNORE` | +| | :envvar:`MODULES_MODULEPATH_IGNORE`, | +| | :envvar:`MODULES_IGNORE_CACHE_SUBCMDS` | +------------+-----------------------------------------------------------------+ Modules Specific Tcl Commands @@ -1326,7 +1327,8 @@ The following Modules configuration option has been introduced on Modules 5. | 5.7 | :mconfig:`path_entry_reorder`, :mconfig:`paginate`, | | | :mconfig:`non_exportable_tags`, :mconfig:`info_extension`, | | | :mconfig:`linked_envvars`, :mconfig:`init_envvars`, | -| | :mconfig:`domainname`, :mconfig:`modulepath_ignore` | +| | :mconfig:`domainname`, :mconfig:`modulepath_ignore`, | +| | :mconfig:`ignore_cache_subcmds` | +------------+-----------------------------------------------------------------+ :mconfig:`auto_handling` diff --git a/doc/source/design/module-cache.rst b/doc/source/design/module-cache.rst index 649809c0f..ff4f8dec9 100644 --- a/doc/source/design/module-cache.rst +++ b/doc/source/design/module-cache.rst @@ -265,6 +265,21 @@ Cache files are ignored if :mconfig:`ignore_cache` configuration option is enabled. This option can also be enabled just for one execution with the :option:`--ignore-cache` command line option. +Cache files are also ignored if the currently running top-level sub-command +is part of the :mconfig:`ignore_cache_subcmds` configuration option. On +setup with a very large number of modulefiles, resulting in cache files of +several megabytes, evaluating the whole cache file may take longer for a +sub-command targeting specific modules (like :subcmd:`load`) than walking +through the modulepath directory to find these modules. This option helps +to skip cache use for such sub-commands while preserving cache benefit on +the others (like :subcmd:`avail`). + +Sub-command name aliases resolve to their target sub-command prior the +comparison against the option value. The :command:`ml` command used without +a sub-command name translates to the :subcmd:`load` or :subcmd:`unload` +sub-command it is currently processing, so ``ml`` is not a value to set in +this option. + Cache files are ignored if cache expiry mechanism is enabled through the :mconfig:`cache_expiry_secs` configuration option. When this option is set to 0, it means a cache file never expires. This is the default behavior. If set diff --git a/doc/source/module.rst b/doc/source/module.rst index e6a563926..54d265004 100644 --- a/doc/source/module.rst +++ b/doc/source/module.rst @@ -1233,6 +1233,19 @@ Module Sub-Commands .. versionadded:: 5.3 + .. mconfig:: ignore_cache_subcmds + + List of module sub-commands that ignore module cache. + + Default is an empty list. The :envvar:`MODULES_IGNORE_CACHE_SUBCMDS` + environment variable is defined by :subcmd:`config` sub-command when + changing this configuration option from its default value. See + :envvar:`MODULES_IGNORE_CACHE_SUBCMDS` description for details. + + .. only:: html or latex + + .. versionadded:: 5.7 + .. mconfig:: ignore_user_rc Skip evaluation of user-specific module rc file (:file:`$HOME/.modulerc`). @@ -5318,6 +5331,30 @@ ENVIRONMENT .. versionadded:: 5.3 +.. envvar:: MODULES_IGNORE_CACHE_SUBCMDS + + A colon separated list of the module sub-commands that ignore module cache. + When one of these sub-commands is run, modulepath directories are walked + through to search modules instead of relying on their cache file. + + Sub-command name aliases (like ``add`` for :subcmd:`load`) resolve to their + target sub-command, which is the name to set in value list. The + :command:`ml` command used without a sub-command name translates to the + underlying :subcmd:`load` or :subcmd:`unload` sub-commands. + + Ignoring cache may be useful for sub-commands targeting specific modules + (like :subcmd:`load`) when cache files are large: walking through modulepath + content to find the requested modules may be faster than evaluating the + whole cache file. + + This environment variable value supersedes the default value set in the + :mconfig:`ignore_cache_subcmds` configuration option. It can be defined + with the :subcmd:`config` sub-command. + + .. only:: html or latex + + .. versionadded:: 5.7 + .. envvar:: MODULES_IGNORE_USER_RC Skip evaluation (if set to ``1``) or not (if set to ``0``) of user-specific From c04c56cbe7716c7cd6db1be51071ac0dae4b9557 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Sun, 23 Aug 2026 17:54:05 +0200 Subject: [PATCH 4/4] 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 --- testsuite/install.00-init/010-environ.exp | 1 + testsuite/modules.00-init/010-environ.exp | 1 + .../053-ignore-cache-subcmds.exp | 106 ++++++++++++++++++ testsuite/modules.70-maint/220-config.exp | 2 + 4 files changed, 110 insertions(+) create mode 100644 testsuite/modules.30-cache/053-ignore-cache-subcmds.exp diff --git a/testsuite/install.00-init/010-environ.exp b/testsuite/install.00-init/010-environ.exp index 369a10789..81b4aa940 100644 --- a/testsuite/install.00-init/010-environ.exp +++ b/testsuite/install.00-init/010-environ.exp @@ -168,6 +168,7 @@ unsetenv_var MODULES_RESET_TARGET_STATE # clean any cache configuration unsetenv_var MODULES_IGNORE_CACHE +unsetenv_var MODULES_IGNORE_CACHE_SUBCMDS unsetenv_var MODULES_CACHE_BUFFER_BYTES unsetenv_var MODULES_CACHE_EXPIRY_SECS diff --git a/testsuite/modules.00-init/010-environ.exp b/testsuite/modules.00-init/010-environ.exp index fc61cba40..a03620490 100644 --- a/testsuite/modules.00-init/010-environ.exp +++ b/testsuite/modules.00-init/010-environ.exp @@ -169,6 +169,7 @@ unsetenv_var MODULES_RESET_TARGET_STATE # clean any cache configuration unsetenv_var MODULES_IGNORE_CACHE +unsetenv_var MODULES_IGNORE_CACHE_SUBCMDS unsetenv_var MODULES_CACHE_BUFFER_BYTES unsetenv_var MODULES_CACHE_EXPIRY_SECS diff --git a/testsuite/modules.30-cache/053-ignore-cache-subcmds.exp b/testsuite/modules.30-cache/053-ignore-cache-subcmds.exp new file mode 100644 index 000000000..d8f126be7 --- /dev/null +++ b/testsuite/modules.30-cache/053-ignore-cache-subcmds.exp @@ -0,0 +1,106 @@ +############################################################################## +# Modules Revision 3.0 +# Providing a flexible user environment +# +# File: modules.30-cache/%M% +# Revision: %I% +# First Edition: 2026/08/23 +# Last Mod.: %U%, %G% +# +# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr +# +# Description: Testuite testsequence +# Command: avail, whatis, load, add, ml +# Modulefiles: +# Sub-Command: +# +# Comment: %C{ +# Test ignore_cache_subcmds configuration option +# }C% +# +############################################################################## + +skip_if_quick_mode + +# ensure avail tests are made using in depth mode +setenv_var MODULES_AVAIL_INDEPTH 1 + +# generate content in modulepaths +lassign [create_simple_module_setup $mp1] dir_list file_list +array set file_arr $file_list + +setenv_var MODULEPATH $mp1 + +# tests with empty cache file +create_dummy_cachefile $mp1 + +set tserr_avail "bar/1.0 +bar/2.0 +foo/1.0" +set tserr_whatis "$modlin [escre $mp1] $modlin +\\s+foo/1.0: foo/1.0" +set ans_load [list] +lappend ans_load [list set _LMFILES_ $mp1/bar/1.0] +lappend ans_load [list set LOADEDMODULES bar/1.0] + +# option unset: cache used whatever the sub-command +testouterr_cmd sh {avail -t -o } OK {} +testouterr_cmd sh {whatis} OK {} +testouterr_cmd sh {load bar/1.0} ERR $err_path'bar/1.0' + +# cache only ignored on listed sub-commands +setenv_var MODULES_IGNORE_CACHE_SUBCMDS load +testouterr_cmd sh {avail -t -o } OK {} +testouterr_cmd sh {whatis} OK {} +testouterr_cmd sh {load bar/1.0} $ans_load {} +# sub-command name alias resolves to the sub-command set in option value +testouterr_cmd sh {add bar/1.0} $ans_load {} +# ml frontend translates to the underlying load sub-command +testouterr_cmd sh {ml bar/1.0} $ans_load {} +# ml frontend with explicit sub-command or alias resolves to it +testouterr_cmd sh {ml load bar/1.0} $ans_load {} +testouterr_cmd sh {ml add bar/1.0} $ans_load {} + +# ml is not a value to match: it translates to underlying load or unload +setenv_var MODULES_IGNORE_CACHE_SUBCMDS ml +testouterr_cmd sh {ml bar/1.0} ERR $err_path'bar/1.0' +testouterr_cmd sh {load bar/1.0} ERR $err_path'bar/1.0' + +setenv_var MODULES_IGNORE_CACHE_SUBCMDS avail:whatis +testouterr_cmd sh {avail -t -o } OK $tserr_avail +testouterr_cmd_re sh {whatis} OK $tserr_whatis +testouterr_cmd sh {load bar/1.0} ERR $err_path'bar/1.0' + +# value that does not match a sub-command name has no effect +setenv_var MODULES_IGNORE_CACHE_SUBCMDS foo:load +testouterr_cmd sh {avail -t -o } OK {} +testouterr_cmd sh {load bar/1.0} $ans_load {} + +# ignore_cache option applies whatever the sub-command +setenv_var MODULES_IGNORE_CACHE_SUBCMDS load +setenv_var MODULES_IGNORE_CACHE 1 +testouterr_cmd sh {avail -t -o } OK $tserr_avail +testouterr_cmd sh {load bar/1.0} $ans_load {} +unsetenv_var MODULES_IGNORE_CACHE +setenv_var MODULES_IGNORE_CACHE 0 +testouterr_cmd sh {avail -t -o } OK {} +testouterr_cmd sh {load bar/1.0} $ans_load {} +unsetenv_var MODULES_IGNORE_CACHE + +# --ignore-cache command line switch applies whatever the sub-command +testouterr_cmd sh {avail --ignore-cache -t -o } OK $tserr_avail +testouterr_cmd sh {load bar/1.0 --ignore-cache} $ans_load {} + +unsetenv_var MODULES_IGNORE_CACHE_SUBCMDS + + +# +# Cleanup +# + +file delete $mp1cache + +# delete created files and dirs +delete_module_setup $mp1 [array names file_arr] $dir_list + +reset_test_env diff --git a/testsuite/modules.70-maint/220-config.exp b/testsuite/modules.70-maint/220-config.exp index 8d3384f28..6e3addcc1 100644 --- a/testsuite/modules.70-maint/220-config.exp +++ b/testsuite/modules.70-maint/220-config.exp @@ -82,6 +82,7 @@ array set configdfl [list\ home [regsub -all "\(\[.+?\]\)" $install_moduleshome {\\\1}]\ icase $install_icase\ ignore_cache 0\ + ignore_cache_subcmds {}\ ignore_user_rc 0\ ignored_dirs {CVS RCS SCCS .svn .git .SYNC .sos}\ implicit_default [expr {$install_implicitdefault eq {y}}]\ @@ -157,6 +158,7 @@ array set configvar [list\ home MODULESHOME\ icase MODULES_ICASE\ ignore_cache MODULES_IGNORE_CACHE\ + ignore_cache_subcmds MODULES_IGNORE_CACHE_SUBCMDS\ ignore_user_rc MODULES_IGNORE_USER_RC\ implicit_default MODULES_IMPLICIT_DEFAULT\ implicit_requirement MODULES_IMPLICIT_REQUIREMENT\