Skip to content

Commit b4f741c

Browse files
committed
Fix extra spec search for mod matching requirement query
always_read_full_file state is initialized after parsing of search query. As a result readModuleContent fails to read module defined in search query. This module is afterward skipped during modulefile scan evaluations. Fixes #494
1 parent 2f443de commit b4f741c

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

NEWS.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Release notes
66
This file describes changes in recent versions of Modules. It primarily
77
documents those changes that are of interest to users and admins.
88

9-
.. _5.X release notes:
9+
.. _5.3 release notes:
1010

11-
Modules 5.X.Y (not yet released)
11+
Modules 5.3.1 (not yet released)
1212
--------------------------------
1313

1414
* Fix additional `ShellCheck`_ warning reports over sh and bash shell scripts.
@@ -17,10 +17,10 @@ Modules 5.X.Y (not yet released)
1717
Modules from git repository.
1818
* Install: adapt RPM spec file to install module initialization script for
1919
fish as configuration snippet for this shell.
20+
* Fix extra specifier search to evaluate module matching requirement query.
21+
(fix issue #494)
2022

2123

22-
.. _5.3 release notes:
23-
2424
Modules 5.3.0 (2023-05-14)
2525
--------------------------
2626

tcl/main.tcl.in

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,12 @@ proc module {command args} {
355355
knerror "${msgprefix}Invalid command '$command'$tryhelpmsg"
356356
}
357357

358+
# define states needed by module spec parsing and sub-command processing
359+
# define if modfile should always be fully read even for validity check
360+
lappendState always_read_full_file [expr {$command ni [list path paths\
361+
list avail aliases edit]}]
362+
lappendState commandname $command
363+
358364
# parse options, do that globally to ignore options not related to a given
359365
# module sub-command (exclude them from arg list)
360366
lassign [parseModuleCommandArgs $topcall $command 0 {*}$args]\
@@ -387,8 +393,8 @@ proc module {command args} {
387393
}
388394
# other commands can only be called from modulefile evaluated from
389395
# command acting as top-level context (source and autoinit)
390-
if {([depthState modulename] > 1 || [currentState commandname] ni [list\
391-
source autoinit]) && $command eq {config}} {
396+
if {([depthState modulename] > 1 || [aboveCommandName] ni [list source\
397+
autoinit]) && $command eq {config}} {
392398
knerror "${msgprefix}Command '$command' not supported$tryhelpmsg"
393399
}
394400
# no requirement should be recorded this module load/unload/switch cmd
@@ -447,11 +453,6 @@ proc module {command args} {
447453
knerror "Unexpected number of args for '$command' command$tryhelpmsg"
448454
}
449455

450-
# define if modfile should always be fully read even for validity check
451-
lappendState always_read_full_file [expr {$command ni [list path paths\
452-
list avail aliases edit]}]
453-
lappendState commandname $command
454-
455456
if {$topcall} {
456457
# Find and execute any global rc file found
457458
runModulerc
@@ -573,6 +574,10 @@ proc ml {args} {
573574
if {$cmdvalid} {
574575
module $command {*}$margs
575576
} else {
577+
# define if modfile should always be fully read even for validity check
578+
lappendState always_read_full_file 1
579+
lappendState commandname ml
580+
576581
# parse specified module and get list of mods to unload and mods to load
577582
defineParseModuleSpecificationProc [getConf advanced_version_spec]
578583
lassign [parseModuleSpecification 1 0 0 0 {*}$fargs] modunlist modlolist
@@ -585,10 +590,6 @@ proc ml {args} {
585590
show_mtime show_filter search_filter search_match dump_state\
586591
addpath_pos not_req tag_list fargs
587592

588-
# define if modfile should always be fully read even for validity check
589-
lappendState always_read_full_file 1
590-
lappendState commandname ml
591-
592593
# Find and execute any global rc file found
593594
runModulerc
594595

testsuite/modulefiles.4/extra/1.0

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ if {[info exists env(TESTSUITE_EXTRA)]} {
167167
load6 {
168168
module load
169169
}
170+
load7 {
171+
module load extra/1.0
172+
}
170173
module-err1 {
171174
module unk foo
172175
}

testsuite/modules.51-scan/043-extra_spec-require.exp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,11 @@ setenv_var TESTSUITE_EXTRA load6
335335
testouterr_cmd sh {avail -t extra load:xtfoo} OK {}
336336
testouterr_cmd sh {avail -t extra load:} ERR [err_extraspec load:]
337337

338+
# module requiring itself
339+
setenv_var TESTSUITE_EXTRA load7
340+
testouterr_cmd sh {avail -t extra load:extra/1.0} OK $tserr
341+
testouterr_cmd sh {ml av -t extra load:extra/1.0} OK $tserr
342+
338343

339344
#
340345
# module erroneous commands

0 commit comments

Comments
 (0)