Skip to content

Commit

Permalink
Merge branch 'main' into testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Feb 7, 2024
2 parents 5f8fb4d + 648509e commit 9d6e288
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 21 deletions.
2 changes: 2 additions & 0 deletions README.new
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,5 @@ Lmod 8.7+
* TACC issue: Change the current version of zsh with the string ${ZSH_VERSION} when builting
the init/zsh file.
(8.7.34) * TACC issue: (Again) Cannot use the string ${ZSH_VERSION} in $FPATH. Instead change orig zsh version to current one.
(8.7.35) * Issue #687: Let is-loaded and is-avail set non-zero exit status. This is different from warnings.
* Issue #688: Do not produce a Lua error on a non-existant collection
26 changes: 26 additions & 0 deletions rt/is_cmd/err.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
===========================
step 1
lua ProjectDIR/src/lmod.in.lua shell --regression_testing --version
===========================
Modules based on Lua: Version 8.7.34 2024-01-05 19:34 -07:00
by Robert McLay [email protected]
===========================
step 2
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load A
===========================
===========================
step 3
lua ProjectDIR/src/lmod.in.lua shell --regression_testing is-loaded A
===========================
===========================
step 4
lua ProjectDIR/src/lmod.in.lua shell --regression_testing is-loaded AA
===========================
===========================
step 5
lua ProjectDIR/src/lmod.in.lua shell --regression_testing is-avail B
===========================
===========================
step 6
lua ProjectDIR/src/lmod.in.lua shell --regression_testing is-avail BB
===========================
56 changes: 56 additions & 0 deletions rt/is_cmd/is_cmd.tdesc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
-- -*- lua -*-

testdescript = {
owner = "rtm",
product = "modules",
description = [[
Test isavail functionality
]],
keywords = {"isloaded" },

active = 1,
testName = "isavail",
job_submit_method = "INTERACTIVE",

runScript = [[
. $(projectDir)/rt/common_funcs.sh
unsetMT
initStdEnvVars
MODULEPATH_ROOT=$(testDir)/mf; export MODULEPATH_ROOT
MODULEPATH=$MODULEPATH_ROOT/Core; export MODULEPATH
rm -fr _stderr.* _stdout.* err.* out.* .lmod.d .cache .config
runLmod --version # 1
runLmod load A # 2
runLmod is-loaded A # 3
runLmod is-loaded AA # 4
runLmod is-avail B # 5
runLmod is-avail BB # 6
HOME=$ORIG_HOME
cat _stdout.[0-9][0-9][0-9] > _stdout.orig
joinBase64Results -bash _stdout.orig _stdout.new
cleanUp _stdout.new out.txt
cat _stderr.[0-9][0-9][0-9] > _stderr.orig
cleanUp _stderr.orig err.txt
rm -f results.csv
wrapperDiff --csv results.csv $(testDir)/out.txt out.txt
wrapperDiff --csv results.csv $(testDir)/err.txt err.txt
testFinish -r $(resultFn) -t $(runtimeFn) results.csv
]],


blessScript = [[
# perform what is needed
]],

tests = {
{ id='t1'},
},

}
Empty file added rt/is_cmd/mf/Core/A/1.0.lua
Empty file.
Empty file added rt/is_cmd/mf/Core/B/2.0.lua
Empty file.
52 changes: 52 additions & 0 deletions rt/is_cmd/out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
===========================
step 1
lua ProjectDIR/src/lmod.in.lua shell --regression_testing --version
===========================
===========================
step 2
lua ProjectDIR/src/lmod.in.lua shell --regression_testing load A
===========================
LOADEDMODULES=A/1.0;
export LOADEDMODULES;
__LMOD_REF_COUNT_MODULEPATH=ProjectDIR/rt/is_cmd/mf/Core:1;
export __LMOD_REF_COUNT_MODULEPATH;
MODULEPATH=ProjectDIR/rt/is_cmd/mf/Core;
export MODULEPATH;
_LMFILES_=ProjectDIR/rt/is_cmd/mf/Core/A/1.0.lua;
export _LMFILES_;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={A={fn="ProjectDIR/rt/is_cmd/mf/Core/A/1.0.lua",fullName="A/1.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="A",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/is_cmd/mf/Core",},systemBaseMPATH="ProjectDIR/rt/is_cmd/mf/Core",}';
export _ModuleTable_;
===========================
step 3
lua ProjectDIR/src/lmod.in.lua shell --regression_testing is-loaded A
===========================
MODULEPATH=ProjectDIR/rt/is_cmd/mf/Core;
export MODULEPATH;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={A={fn="ProjectDIR/rt/is_cmd/mf/Core/A/1.0.lua",fullName="A/1.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="A",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/is_cmd/mf/Core",},systemBaseMPATH="ProjectDIR/rt/is_cmd/mf/Core",}';
export _ModuleTable_;
===========================
step 4
lua ProjectDIR/src/lmod.in.lua shell --regression_testing is-loaded AA
===========================
MODULEPATH=ProjectDIR/rt/is_cmd/mf/Core;
export MODULEPATH;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={A={fn="ProjectDIR/rt/is_cmd/mf/Core/A/1.0.lua",fullName="A/1.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="A",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/is_cmd/mf/Core",},systemBaseMPATH="ProjectDIR/rt/is_cmd/mf/Core",}';
export _ModuleTable_;
false
===========================
step 5
lua ProjectDIR/src/lmod.in.lua shell --regression_testing is-avail B
===========================
MODULEPATH=ProjectDIR/rt/is_cmd/mf/Core;
export MODULEPATH;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={A={fn="ProjectDIR/rt/is_cmd/mf/Core/A/1.0.lua",fullName="A/1.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="A",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/is_cmd/mf/Core",},systemBaseMPATH="ProjectDIR/rt/is_cmd/mf/Core",}';
export _ModuleTable_;
===========================
step 6
lua ProjectDIR/src/lmod.in.lua shell --regression_testing is-avail BB
===========================
MODULEPATH=ProjectDIR/rt/is_cmd/mf/Core;
export MODULEPATH;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={A={fn="ProjectDIR/rt/is_cmd/mf/Core/A/1.0.lua",fullName="A/1.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="A",wV="000000001.*zfinal",},},mpathA={"ProjectDIR/rt/is_cmd/mf/Core",},systemBaseMPATH="ProjectDIR/rt/is_cmd/mf/Core",}';
export _ModuleTable_;
false
1 change: 0 additions & 1 deletion src/Hub.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ function M.access(self, ...)


if (#a > 0) then
setWarningFlag()
LmodWarning{msg="w_Failed_2_Find",quote_comma_list=concatTbl(a,"\", \""),
module_list=concatTbl(a," ")}
end
Expand Down
6 changes: 5 additions & 1 deletion src/MT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,12 @@ end
-- collection is not found.
function M.reportContents(self, t)
dbg.start{"mt:reportContents(",t.fn,")"}
local f = io.open(t.fn,"r")
local a = {}
if (not t.fn) then
dbg.fini("mt:reportContents")
return a
end
local f = io.open(t.fn,"r")
if (not f) then
dbg.fini("mt:reportContents")
return a
Expand Down
5 changes: 0 additions & 5 deletions src/MainControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,6 @@ function M.warning(self, ...)
sA[#sA+1] = moduleStackTraceBack()
sA[#sA+1] = "\n"
io.stderr:write(concatTbl(sA,""),"\n")
setWarningFlag()
end
end

Expand Down Expand Up @@ -1127,7 +1126,6 @@ end
-- @param mA A array of MName objects.
function M.try_load(self, mA)
dbg.start{"MainControl:try_load(mA)"}
--deactivateWarning()
self:load(mA)
dbg.fini("MainControl:try_load")
end
Expand Down Expand Up @@ -1511,9 +1509,6 @@ function M.purge(self,t)
unload_usr_internal(mA, force)
s_purgeFlg = false

-- A purge should not set the warning flag.
clearWarningFlag()
dbg.print{"warningFlag: ", getWarningFlag(),"\n"}
dbg.fini("MainControl:Purge")
end

Expand Down
1 change: 0 additions & 1 deletion src/Spider.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,6 @@ function M.spiderSearch(self, dbT, providedByT, userSearchPat, helpFlg)
end

if (next(matchT) == nil) then
setWarningFlag()
LmodSystemError{msg="e_Failed_2_Find", name=origUserSearchPat}
end

Expand Down
4 changes: 2 additions & 2 deletions src/cmdfuncs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ function IsAvail(...)
for i = 1, argA.n do
local mname = MName:new("load", argA[i])
if (not mname:valid()) then
setWarningFlag()
setStatusFlag()
break
end
end
Expand All @@ -318,7 +318,7 @@ function IsLoaded(...)
for i = 1, argA.n do
local mname = MName:new("mt", argA[i])
if (not mname:isloaded()) then
setWarningFlag()
setStatusFlag()
break
end
end
Expand Down
4 changes: 4 additions & 0 deletions src/lmod.in.lua
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@ function main()
if (optionTbl.reportTimer) then
io.stderr:write(timer:report(),"\n")
end

if (getStatusFlag()) then
LmodErrorExit()
end
end

main()
Expand Down
5 changes: 5 additions & 0 deletions src/myGlobals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,11 @@ parseVersion = false
------------------------------------------------------------------------
s_warning = false

------------------------------------------------------------------------
-- s_status: When set return a non-zero status
------------------------------------------------------------------------
s_status = false

------------------------------------------------------------------------
-- s_haveWarnings: if warning are allowed (or ignored). For example
-- a try-load command turns off warnings.
Expand Down
16 changes: 5 additions & 11 deletions src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -868,23 +868,17 @@ function haveWarnings()
return s_haveWarnings
end

--------------------------------------------------------------------------
-- Reset warning flag to false.
function clearWarningFlag()
s_warning = false
end

--------------------------------------------------------------------------
-- Set warning flags to true.
function setWarningFlag()
dbg.print{"setting warning flag\n"}
s_warning = true
function setStatusFlag()
dbg.print{"setting status flag\n"}
s_status = true
end

--------------------------------------------------------------------------
-- Get warning flag value.
function getWarningFlag()
return s_warning
function getStatusFlag()
return s_status
end

local function l_restoreEnv(oldEnvT, newEnvT)
Expand Down

0 comments on commit 9d6e288

Please sign in to comment.