Skip to content

Commit

Permalink
No duplicate entry in resolved modulepath list
Browse files Browse the repository at this point in the history
When resolving the enabled list of modulepaths, ensure resolved path
entries are unique.

Fixes #274.
  • Loading branch information
xdelaruelle committed May 15, 2019
1 parent c83032c commit 9f5fcb7
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modulecmd.tcl.in
Original file line number Diff line number Diff line change
Expand Up @@ -3595,7 +3595,7 @@ proc getModulePathList {{behavior returnempty} {resolv_var 1} {set_abs 1}} {
if {$set_abs} {
set modpath [getAbsolutePath $modpath]
}
lappend modpathlist $modpath
appendNoDupToList modpathlist $modpath
}
}
return $modpathlist
Expand Down
37 changes: 37 additions & 0 deletions testsuite/modules.90-avail/090-dup-modpath.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
##############################################################################
# Modules Revision 3.0
# Providing a flexible user environment
#
# File: modules.90-avail/%M%
# Revision: %I%
# First Edition: 2019/05/15
# Last Mod.: %U%, %G%
#
# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr
#
# Description: Testuite testsequence
# Command: avail
# Modulefiles:
# Sub-Command:
#
# Comment: %C{
# Check the module 'avail' command when MODULEPATH variable
# hold duplicate path entries
# }C%
#
##############################################################################

# set MODULEPATH with multiple entries all pointing to the same directory
setenv_path_var MODULEPATH $modpath:$modpath:$modpath/test/..

# single entry should be reported
testouterr_cmd sh {avail -t help/2.0} OK "$modpath:\nhelp/2.0"
testouterr_cmd sh use OK "Search path for module files (in search order):\n $modpath"

#
# Cleanup
#

# restore MODULEPATH
setenv_path_var MODULEPATH $modpath

42 changes: 42 additions & 0 deletions testsuite/modules.95-version/090-dup-modpath-version.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
##############################################################################
# Modules Revision 3.0
# Providing a flexible user environment
#
# File: modules.95-version/%M%
# Revision: %I%
# First Edition: 2019/05/15
# Last Mod.: %U%, %G%
#
# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr
#
# Description: Testuite testsequence
# Command: avail
# Modulefiles:
# Sub-Command:
#
# Comment: %C{
# Check the module 'avail' command when MODULEPATH variable
# hold path entries using variable reference that all resolve
# to the same directory
# }C%
#
##############################################################################

# set MODULEPATH with multiple entries all pointing to the same directory
unsetenv_var UNDEFINED
setenv_var DEFINED modulefiles
setenv_path_var MODULEPATH $modpath:$modpath/\$UNDEFINED:$modpath/../\$DEFINED

# single entry should be reported
testouterr_cmd sh {avail -t help/2.0} OK "$modpath:\nhelp/2.0"
testouterr_cmd sh use OK "Search path for module files (in search order):\n $modpath"


#
# Cleanup
#

# restore environment
setenv_path_var MODULEPATH $modpath
unsetenv_var DEFINED

0 comments on commit 9f5fcb7

Please sign in to comment.