Skip to content

Commit

Permalink
Merge branch 'testing' into PR674
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Dec 1, 2023
2 parents 86f9d66 + 8d3c4d6 commit 37a16ff
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 11 deletions.
5 changes: 5 additions & 0 deletions README.new
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,8 @@ Lmod 8.7+
(8.7.32) * Better handling of zsh shell functions in source_sh(). Must match "\n}\n" to find end of function.
* Better name for extension title, remove trailing \n
* Testing github actions
W.I.P:
(8.7.33) * Issue #678: Change isFile(fn) to return nil if fn is a broken symlink.
* Issue #678: Change abspath() to l_abspath() in tools/fileOps.lua
* Issue #678: Create realpath() to use posix.realpath() if it exists otherwise use l_abspath()

18 changes: 13 additions & 5 deletions rt/symlink/err.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
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.32 2023-08-28 12:42 -05:00
by Robert McLay [email protected]
===========================
step 2
lua ProjectDIR/src/lmod.in.lua shell --regression_testing avail
===========================
ProjectDIR/rt/symlink/mf/Core
a/1.1 boost/1.55.0 (D) intel/14.0.2 mv2/2.1
a/1.2 (D) boost/1.56.0 mv2/2.0 mv2/2.2
b/1.1 (D) intel/12.1.5 (D) mv2/2.1rc1
b/1.2 intel/13.1 mv2/2.1rc2 (D)
a/1.1 bad_symlink/1.0 intel/13.1 mv2/2.1rc2 (D)
a/1.2 (D) boost/1.55.0 (D) intel/14.0.2 mv2/2.1
b/1.1 (D) boost/1.56.0 mv2/2.0 mv2/2.2
b/1.2 intel/12.1.5 (D) mv2/2.1rc1
Where:
D: Default Module
If the avail list is too long consider trying:
Expand All @@ -27,6 +27,7 @@ lua ProjectDIR/src/lmod.in.lua shell --regression_testing -t -d avail
ProjectDIR/rt/symlink/mf/Core:
a/1.2
b/1.1
bad_symlink/1.0
boost/1.55.0
intel/12.1.5
mv2/2.1rc2
Expand All @@ -40,3 +41,10 @@ lua ProjectDIR/src/lmod.in.lua shell --regression_testing list
===========================
Currently Loaded Modules:
1) intel/12.1.5 2) a/1.2 3) b/1.1 4) boost/1.55.0 5) mv2/2.1rc2
===========================
step 6
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load bad_symlink
===========================
good.text true
bad1.text nil
bad2.text nil
7 changes: 7 additions & 0 deletions rt/symlink/foo/bar/mf/Core/bad_symlink/1.0.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local a = { "good.text", "bad1.text", "bad2.text"}

for i = 1,#a do
local result = isFile(a[i])
io.stderr:write(a[i].." "..tostring(result).."\n")
end

12 changes: 12 additions & 0 deletions rt/symlink/out.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,15 @@ MODULEPATH=ProjectDIR/rt/symlink/mf/Core;
export MODULEPATH;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={a={fn="ProjectDIR/rt/symlink/mf/Core/a/1.2.lua",fullName="a/1.2",loadOrder=2,propT={},stackDepth=0,status="active",userName="a",wV="^00000001.000000002.*zfinal",},b={fn="ProjectDIR/rt/symlink/mf/Core/b/1.1.lua",fullName="b/1.1",loadOrder=3,propT={},stackDepth=0,status="active",userName="b",wV="^00000001.000000001.*zfinal",},boost={fn="ProjectDIR/rt/symlink/mf/Core/boost/1.55.0.lua",fullName="boost/1.55.0",loadOrder=4,propT={},stackDepth=0,status="active",userName="boost",wV="^00000001.000000055.*zfinal",},intel={fn="ProjectDIR/rt/symlink/mf/Core/intel/12.1.5.lua",fullName="intel/12.1.5",loadOrder=1,propT={},stackDepth=0,status="active",userName="intel",wV="^00000012.000000001.000000005.*zfinal",},mv2={fn="ProjectDIR/rt/symlink/mf/Core/mv2/2.1rc2.lua",fullName="mv2/2.1rc2",loadOrder=5,propT={},stackDepth=0,status="active",userName="mv2",wV="^00000002.000000001.*c.000000002.*zfinal",},},mpathA={"ProjectDIR/rt/symlink/mf/Core",},systemBaseMPATH="ProjectDIR/rt/symlink/mf/Core",}';
export _ModuleTable_;
===========================
step 6
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load bad_symlink
===========================
LOADEDMODULES=intel/12.1.5:a/1.2:b/1.1:boost/1.55.0:mv2/2.1rc2:bad_symlink/1.0;
export LOADEDMODULES;
MODULEPATH=ProjectDIR/rt/symlink/mf/Core;
export MODULEPATH;
_LMFILES_=ProjectDIR/rt/symlink/mf/Core/intel/12.1.5.lua:ProjectDIR/rt/symlink/mf/Core/a/1.2.lua:ProjectDIR/rt/symlink/mf/Core/b/1.1.lua:ProjectDIR/rt/symlink/mf/Core/boost/1.55.0.lua:ProjectDIR/rt/symlink/mf/Core/mv2/2.1rc2.lua:ProjectDIR/rt/symlink/mf/Core/bad_symlink/1.0.lua;
export _LMFILES_;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={a={fn="ProjectDIR/rt/symlink/mf/Core/a/1.2.lua",fullName="a/1.2",loadOrder=2,propT={},stackDepth=0,status="active",userName="a",wV="^00000001.000000002.*zfinal",},b={fn="ProjectDIR/rt/symlink/mf/Core/b/1.1.lua",fullName="b/1.1",loadOrder=3,propT={},stackDepth=0,status="active",userName="b",wV="^00000001.000000001.*zfinal",},bad_symlink={fn="ProjectDIR/rt/symlink/mf/Core/bad_symlink/1.0.lua",fullName="bad_symlink/1.0",loadOrder=6,propT={},stackDepth=0,status="active",userName="bad_symlink",wV="000000001.*zfinal",},boost={fn="ProjectDIR/rt/symlink/mf/Core/boost/1.55.0.lua",fullName="boost/1.55.0",loadOrder=4,propT={},stackDepth=0,status="active",userName="boost",wV="^00000001.000000055.*zfinal",},intel={fn="ProjectDIR/rt/symlink/mf/Core/intel/12.1.5.lua",fullName="intel/12.1.5",loadOrder=1,propT={},stackDepth=0,status="active",userName="intel",wV="^00000012.000000001.000000005.*zfinal",},mv2={fn="ProjectDIR/rt/symlink/mf/Core/mv2/2.1rc2.lua",fullName="mv2/2.1rc2",loadOrder=5,propT={},stackDepth=0,status="active",userName="mv2",wV="^00000002.000000001.*c.000000002.*zfinal",},},mpathA={"ProjectDIR/rt/symlink/mf/Core",},systemBaseMPATH="ProjectDIR/rt/symlink/mf/Core",}';
export _ModuleTable_;
6 changes: 6 additions & 0 deletions rt/symlink/symlink.tdesc
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@ testdescript = {
MODULEPATH=$MODULEPATH_ROOT/Core; export MODULEPATH
rm -fr _stderr.* _stdout.* err.* out.* .lmod.d .cache .config
rm -f good.text bad1.text bad2.text
runLmod --version # 1
runLmod avail # 2
runLmod -t -d avail # 3
runLmod load intel a b boost mv2 # 4
runLmod list # 5
touch good.text
ln -s bad bad1.text
ln -s bad1.text bad2.text
runLmod load bad_symlink # 6
Expand Down
2 changes: 1 addition & 1 deletion src/cmdfuncs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ function Use(...)
if (v:sub(1,1) ~= '/') then
local old = v
-- If relative convert to try to convert to absolute path
v = abspath(v)
v = realpath(v)
-- If it doesn't exist then build path with current directory and relative path.
if (not v) then
v = pathJoin(posix.getcwd(), old)
Expand Down
3 changes: 2 additions & 1 deletion src/sandbox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ local sandbox_env = {
removeExt = removeExt,
barefilename = barefilename,
splitFileName = splitFileName,
abspath = abspath,
abspath = realpath,
realpath = realpath,
path_regularize = path_regularize,

------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/spider.in.lua
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ local function l_add2map(entry, tbl, dirA, moduleFn, kind, rmapT)
end
dbg.print{"assigning rmapT for path: ",path,"\n"}
rmapT[path] = t
local p2 = abspath(path)
local p2 = realpath(path)
if (p2 and p2 ~= path) then
dbg.print{"assigning rmapT for path: ",p2,"\n"}
rmapT[p2] = deepcopy(t)
Expand Down
2 changes: 1 addition & 1 deletion src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ function locatePkg(pkg)
for path in package.path:split(";") do
local s = path:gsub("?",pkg)
if (isFile(s)) then
result = abspath(s)
result = realpath(s)
break
end
end
Expand Down
15 changes: 13 additions & 2 deletions tools/fileOps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ function isFile(fn)
local t = posix.stat(fn,"type")

local result = t and t ~= "directory"
if (t == "link") then
result = realpath(fn)
end
return result
end

Expand Down Expand Up @@ -318,7 +321,7 @@ end
-- when following symlinks
-- @return A absolute path.

function abspath (path, localDir)
local function l_abspath (path, localDir)
if (path == nil) then return nil end

local cwd = lfs.currentdir()
Expand Down Expand Up @@ -355,12 +358,20 @@ function abspath (path, localDir)
lfs.chdir(cwd)
return result
end
result = abspath(rl, localDir)
result = l_abspath(rl, localDir)
end
lfs.chdir(cwd)
return result
end

function realpath(path, localDir)
if (localDir or not posix.realpath) then
return l_abspath(path, localDir)
end
return posix.realpath(path)
end


--------------------------------------------------------------------------
-- Remove leading and trail spaces and extra slashes.
-- @param value A path
Expand Down

0 comments on commit 37a16ff

Please sign in to comment.