Skip to content

Commit

Permalink
Merge branch 'testing'
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Aug 28, 2023
2 parents b535d7c + 9679066 commit 1a69730
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 14 deletions.
3 changes: 3 additions & 0 deletions README.new
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,6 @@ Lmod 8.7+
* Issue #657: Added support for "module purge" in a TCL modulefile to unload all other modules on load.
(8.7.30) * Issue #662: Fix bug where the version is very long (like git commit tags)
(8.7.31) * Issue #665: Added support for getenv function in TCL modules
W.I.P:
(8.7.32) * Better handling of zsh shell functions in source_sh(). Must match "\n}\n" to find end of function.

2 changes: 1 addition & 1 deletion messageDir/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ See https://lmod.readthedocs.io/en/latest/260_sh_to_modulefile.html for details.
m_Depend_Mods = "\n You will need to load all module(s) on any one of the lines below before the \"%{fullName}\" module is available to load.\n",
m_Description = " Description:\n%{descript}\n\n",
m_Direct_Load = "\n This module can be loaded directly: module load %{fullName}\n",
m_Extensions_head = "This is a list of module extensions \"module --nx avail ...\" to not show.\n",
m_Extensions_head = "This is a list of module extensions. Use \"module --nx avail ...\" to not show extensions.",
m_Extensions_tail = "\nThese extensions cannot be loaded directly, use \"module spider extension_name\" for more information.\n",
m_Family_Swap = "\nLmod is automatically replacing \"%{oldFullName}\" with \"%{newFullName}\".\n",
m_For_System = ", for system: \"%{sname}\"",
Expand Down
2 changes: 1 addition & 1 deletion rt/common_funcs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cleanUp ()
-e "s|='\\\\033|='\\\\\\\\033|g" \
-e "s|^User shell.*||" \
-e "s|\@git\@|$gitV|g" \
-e "s|$PATH_to_SHA1/$SHA1SUM|PATH_to_HASHSUM|g" \
-e "s| $PATH_to_SHA1/$SHA1SUM| PATH_to_HASHSUM|g" \
-e "s|/usr/.*/sha1sum|PATH_to_HASHSUM|g" \
-e "s|/bin/.*/sha1sum|PATH_to_HASHSUM|g" \
-e "s|:$PATH_to_LUA\([:;]\)|\1|g" \
Expand Down
8 changes: 4 additions & 4 deletions rt/extensions/err.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
step 1
lua ProjectDIR/src/lmod.in.lua shell --regression_testing --version
===========================
Modules based on Lua: Version 8.6.12 2022-02-09 16:10 -06:00
Modules based on Lua: Version 8.7.31 2023-08-09 12:41 -05:00
by Robert McLay [email protected]
===========================
step 2
Expand All @@ -27,7 +27,7 @@ ProjectDIR/rt/extensions/mf/Compiler/gcc/9
python/3.7 (L)
ProjectDIR/rt/extensions/mf/Core
TACC gcc/9.4 (L) intel/19.1
This is a list of module extensions "module --nx avail ..." to not show.
This is a list of module extensions. Use "module --nx avail ..." to not show extensions.
CC (E) a (E) b (E)
These extensions cannot be loaded directly, use "module spider extension_name" for more information.
Where:
Expand All @@ -46,7 +46,7 @@ ProjectDIR/rt/extensions/mf/Compiler/gcc/9
python/3.7 (L) snake/3.9 (H)
ProjectDIR/rt/extensions/mf/Core
TACC gcc/9.4 (L) intel/19.1
This is a list of module extensions "module --nx avail ..." to not show.
This is a list of module extensions. Use "module --nx avail ..." to not show extensions.
CC (E) a (E) b (E) d (E)
These extensions cannot be loaded directly, use "module spider extension_name" for more information.
Where:
Expand All @@ -73,7 +73,7 @@ ProjectDIR/rt/extensions/mf/Compiler/intel/19
python/3.7 (L)
ProjectDIR/rt/extensions/mf/Core
TACC gcc/9.4 intel/19.1 (L)
This is a list of module extensions "module --nx avail ..." to not show.
This is a list of module extensions. Use "module --nx avail ..." to not show extensions.
CC (E) DDD (E)
These extensions cannot be loaded directly, use "module spider extension_name" for more information.
Where:
Expand Down
2 changes: 1 addition & 1 deletion rt/help/help.tdesc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ testdescript = {
runLmod help amber # 4
runLmod --config # 5
runLmod --miniConfig # 6
$LUA_EXEC $projectDir/src/lmod.in.lua bash --config_json 2> config.json
LD_PRELOAD= $LUA_EXEC $projectDir/src/lmod.in.lua bash --config_json 2> config.json
runBase $LUA_EXEC $projectDir/src/chkJson < config.json # 7
Expand Down
6 changes: 5 additions & 1 deletion rt/zsh_to_modulefile/err.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
step 1
lua ProjectDIR/src/lmod.in.lua shell --regression_testing --version
===========================
Modules based on Lua: Version 8.6.9 2022-02-02 11:25 -04:00
Modules based on Lua: Version 8.7.31 2023-08-09 12:41 -05:00
by Robert McLay [email protected]
===========================
step 2
buildSh2MF --from zsh ProjectDIR/rt/zsh_to_modulefile/tstScript.zsh
===========================
===========================
step 3
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load matt/1.0
===========================
1 change: 1 addition & 0 deletions rt/zsh_to_modulefile/mf/matt/1.0.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source_sh("zsh", pathJoin(os.getenv("testDir"), "rtm.sh"))
30 changes: 29 additions & 1 deletion rt/zsh_to_modulefile/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,33 @@ prepend_path("PATH","ProjectDIR/rt/zsh_to_modulefile/bin")
append_path("PATH","ProjectDIR/rt/zsh_to_modulefile/sbin")
set_alias("fooAlias","foobin -q -l")
set_shell_function("fooFunc","\
echo \"arg1: $1\"\
echo \"arg1: $1\"\
","")
===========================
step 3
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load matt/1.0
===========================
LOADEDMODULES=matt/1.0;
export LOADEDMODULES;
__LMOD_REF_COUNT_MODULEPATH=ProjectDIR/rt/zsh_to_modulefile/mf:1;
export __LMOD_REF_COUNT_MODULEPATH;
MODULEPATH=ProjectDIR/rt/zsh_to_modulefile/mf;
export MODULEPATH;
_LMFILES_=ProjectDIR/rt/zsh_to_modulefile/mf/matt/1.0.lua;
export _LMFILES_;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={matt={fn="ProjectDIR/rt/zsh_to_modulefile/mf/matt/1.0.lua",fullName="matt/1.0",loadOrder=1,mcmdT={["ProjectDIR/rt/zsh_to_modulefile/rtm.sh"]={[[set_shell_function("_sp_multi_pathadd","\\ local IFS=':' \\ if [ \\"$_sp_shell\\"=zsh ]\\ then\\ emulate -L sh\\ fi\\ for pth in $2\\ do\\ for systype in ${_sp_compatible_sys_types}\\ do\\ _spack_pathadd \\"$1\\" \\"${pth}/${systype}\\"\\ done\\ done\\","")]],},},propT={},stackDepth=0,status="active",userName="matt/1.0",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/zsh_to_modulefile/mf",},systemBaseMPATH="ProjectDIR/rt/zsh_to_modulefile/mf",}';
export _ModuleTable_;
_sp_multi_pathadd () {
local IFS=':'
if [ "$_sp_shell" = zsh ]
then
emulate -L sh
fi
for pth in $2
do
for systype in ${_sp_compatible_sys_types}
do
_spack_pathadd "$1" "${pth}/${systype}"
done
done;
};
11 changes: 11 additions & 0 deletions rt/zsh_to_modulefile/rtm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
_sp_multi_pathadd() {
local IFS=':'
if [ "$_sp_shell" = zsh ]; then
emulate -L sh
fi
for pth in $2; do
for systype in ${_sp_compatible_sys_types}; do
_spack_pathadd "$1" "${pth}/${systype}"
done
done
}
3 changes: 2 additions & 1 deletion rt/zsh_to_modulefile/zsh_to_modulefile.tdesc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- -*- lua -*-
local testName = "sh_to_modulefile"
local testName = "zsh_to_modulefile"

local zsh_path, found = findInPath("zsh", os.getenv("PATH"))

Expand All @@ -26,6 +26,7 @@ testdescript = {
runLmod --version # 1
runSh2MF --from zsh $(testDir)/tstScript.zsh # 2
runLmod load matt/1.0 # 3
HOME=$ORIG_HOME
cat _stdout.[0-9][0-9][0-9] > _stdout.orig
Expand Down
8 changes: 4 additions & 4 deletions tools/MF_Base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ function M.processAliases(self, shellName, old, new, a)
end

local shellFuncPatt = {
bash = { namePatt = "([-a-zA-Z0-9_.?']+) ?%(%)%s+({)", trailingPatt = "(})\n" },
zsh = { namePatt = "([-a-zA-Z0-9_.?']+) ?%(%)%s+({)", trailingPatt = "(})\n" },
ksh = { namePatt = "([-a-zA-Z0-9_.?']+) ?%(%)%s+({)", trailingPatt = "(})\n" },
bash = { namePatt = "([-a-zA-Z0-9_.?']+) ?%(%)%s+({)", trailingPatt = "\n(})\n" },
zsh = { namePatt = "([-a-zA-Z0-9_.?']+) ?%(%)%s+({)", trailingPatt = "\n(})\n" },
ksh = { namePatt = "([-a-zA-Z0-9_.?']+) ?%(%)%s+({)", trailingPatt = "\n(})\n" },
}

local function l_extractFuncs(shellName, funcs)
Expand All @@ -174,7 +174,7 @@ local function l_extractFuncs(shellName, funcs)
local is, ie, Nm, Strt = funcs:find(namePatt)
if (not is) then break end
local js, je, End = funcs:find(trailingPatt, ie+1)
funcT[Nm] = funcs:sub(ie+1,js-1)
funcT[Nm] = funcs:sub(ie+1,js):gsub("\t"," ")
funcs = funcs:sub(je+1,-1)
end

Expand Down

0 comments on commit 1a69730

Please sign in to comment.