Skip to content

Commit

Permalink
Fix 'module load a b' in modfiles when a or b is loaded
Browse files Browse the repository at this point in the history
Fix automatic loading of modulefiles when multiple module names are set
on a single ``module load`` modulefile command. When auto_handling mode
was disabled, the load of not loaded modules was not achieved as soon as
some modules on this list were already loaded.

Fixes cea-hpc#281.
  • Loading branch information
xdelaruelle committed Jul 8, 2019
1 parent 4016696 commit 27abbbe
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 6 deletions.
19 changes: 13 additions & 6 deletions modulecmd.tcl.in
Original file line number Diff line number Diff line change
Expand Up @@ -1850,12 +1850,19 @@ proc module {command args} {
# load here if no auto mode, done through prereq elsewhere
# inhibited if currently in DepRe context
if {![getAutoHandling] && [currentModuleEvalContext] ne\
{depre} && ![eval is-loaded $args] && ![eval is-loading\
$args]} {
set ret [eval cmdModuleLoad reqlo 0 $args]
# ignore obtained error if force mode enabled
if {[getForce]} {
set ret 0
{depre}} {
# attempt load of not already loaded modules
foreach arg $args {
if {![is-loaded $arg] && ![is-loading $arg]} {
lappend modlist $arg
}
}
if {[info exists modlist]} {
set ret [eval cmdModuleLoad reqlo 0 $modlist]
# ignore obtained error if force mode enabled
if {[getForce]} {
set ret 0
}
}
}
# register modulefiles to load as individual prereqs
Expand Down
1 change: 1 addition & 0 deletions testsuite/modulefiles.deps/m10
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#%Module
1 change: 1 addition & 0 deletions testsuite/modulefiles.deps/m11
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#%Module
2 changes: 2 additions & 0 deletions testsuite/modulefiles.deps/m12
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#%Module
module load m10 m11
36 changes: 36 additions & 0 deletions testsuite/modules.50-cmds/376-deps7.exp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,42 @@ set tserr [list {load m7} \n[msg_load m7 "$err_path'm8'" [err_reqlof m8]]]
testouterr_cmd_re sh {load --force --auto m7} $ans [join $tserr \n]
testouterr_cmd_re sh {load --force --no-auto m7} $ans [join $tserr \n]

# load test where 'module load' has multiple module args
set ans [list]
lappend ans [list setpath LOADEDMODULES m10:m11:m12]
lappend ans [list setpath _LMFILES_ $mp/m10:$mp/m11:$mp/m12]
lappend ans [list setpath MODULES_LMPREREQ m12&m10&m11]
lappend ans [list setpath MODULES_LMNOTUASKED m10:m11]
set tserr [list [msg_top_load m12 {} {m10 m11} {}]]
testouterr_cmd_re sh {load --auto m12} $ans [join $tserr \n]
testouterr_cmd_re sh {load --no-auto m12} $ans [join $tserr \n]
setenv_loaded_module [list m10] [list $mp/m10]
set ans [list]
lappend ans [list setpath LOADEDMODULES m10:m11:m12]
lappend ans [list setpath _LMFILES_ $mp/m10:$mp/m11:$mp/m12]
lappend ans [list setpath MODULES_LMPREREQ m12&m10&m11]
lappend ans [list setpath MODULES_LMNOTUASKED m11]
set tserr [list [msg_top_load m12 {} {m11} {}]]
testouterr_cmd_re sh {load --auto m12} $ans [join $tserr \n]
testouterr_cmd_re sh {load --no-auto m12} $ans [join $tserr \n]
setenv_loaded_module [list m11] [list $mp/m11]
set ans [list]
lappend ans [list setpath LOADEDMODULES m11:m10:m12]
lappend ans [list setpath _LMFILES_ $mp/m11:$mp/m10:$mp/m12]
lappend ans [list setpath MODULES_LMPREREQ m12&m10&m11]
lappend ans [list setpath MODULES_LMNOTUASKED m10]
set tserr [list [msg_top_load m12 {} {m10} {}]]
testouterr_cmd_re sh {load --auto m12} $ans [join $tserr \n]
testouterr_cmd_re sh {load --no-auto m12} $ans [join $tserr \n]
setenv_loaded_module [list m10 m11] [list $mp/m10 $mp/m11]
set ans [list]
lappend ans [list setpath LOADEDMODULES m10:m11:m12]
lappend ans [list setpath _LMFILES_ $mp/m10:$mp/m11:$mp/m12]
lappend ans [list setpath MODULES_LMPREREQ m12&m10&m11]
set tserr {}
testouterr_cmd_re sh {load --auto m12} $ans [join $tserr \n]
testouterr_cmd_re sh {load --no-auto m12} $ans [join $tserr \n]


#
# 'module unload' tests
Expand Down

0 comments on commit 27abbbe

Please sign in to comment.