Skip to content

Commit

Permalink
Issue #679: adding atmost modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Apr 3, 2024
1 parent f3dca2f commit f4e647f
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.new
Expand Up @@ -138,3 +138,6 @@ Lmod 8.7+
(8.7.37) * Issue #698: Use the correct mname from Framestack when unregistering a "break" module
* Ignore backup files (*~ .*.swp etc) files in a modulerc.d directory.
* Issue #699: Fixed buildVersion_src to deal with (HEAD detached at x.y.z)
W.I.P:
(8.7.38) * Issue #697: Add warning if doing "module use --help"
* Make LMOD_IGNORE_CACHE use "yes/no" env var setting system.
3 changes: 2 additions & 1 deletion messageDir/en.lua
Expand Up @@ -307,11 +307,12 @@ to see if the module(s) are available across all compilers and MPI implementatio
%{border}
The following dependent module(s) are not currently loaded: %{missing}
%{border}
]==],
]==],
w_MPATH_Coll = "The system MODULEPATH has changed: please rebuild your saved collection.\n",
w_Mods_Not_Loaded = "The following modules were not loaded: %{module_list}\n\n",
w_No_Coll = "No collection named \"%{collection}\" found.",
w_No_dot_Coll = "It is illegal to have a `.' in a collection name. Please choose another name for: \"%{name}\".",
w_Possible_Bad_Dir = "Adding \"%{dir}\" to $MODULEPATH. Did you mean: \"module %{dir} use\"?",
w_SYS_DFLT_EMPTY = [==[
The system default contains no modules
(env var: LMOD_SYSTEM_DEFAULT_MODULES is empty)
Expand Down
12 changes: 11 additions & 1 deletion rt/use_unuse/err.txt
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.9 2022-02-02 11:25 -04:00
Modules based on Lua: Version 8.7.37 2024-03-17 13:11 -06:00
by Robert McLay mclay@tacc.utexas.edu
===========================
step 2
Expand Down Expand Up @@ -38,3 +38,13 @@ lua ProjectDIR/src/lmod.in.lua shell --regression_testing use ProjectDIR/rt/use_
step 9
lua ProjectDIR/src/lmod.in.lua shell --regression_testing unuse ProjectDIR/rt/use_unuse/mf/RTM2
===========================
===========================
step 10
lua ProjectDIR/src/lmod.in.lua shell --regression_testing use --help
===========================
Lmod Warning: Adding "--help" to $MODULEPATH. Did you mean: "module --help use"?
===========================
step 11
lua ProjectDIR/src/lmod.in.lua shell --regression_testing use -h
===========================
Lmod Warning: Adding "-h" to $MODULEPATH. Did you mean: "module -h use"?
20 changes: 20 additions & 0 deletions rt/use_unuse/out.txt
Expand Up @@ -82,3 +82,23 @@ unset __LMOD_REF_COUNT_MODULEPATH;
unset MODULEPATH;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={},}';
export _ModuleTable_;
===========================
step 10
lua ProjectDIR/src/lmod.in.lua shell --regression_testing use --help
===========================
__LMOD_REF_COUNT_MODULEPATH=OutputDIR/--help:1;
export __LMOD_REF_COUNT_MODULEPATH;
MODULEPATH=OutputDIR/--help;
export MODULEPATH;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"OutputDIR/--help",},}';
export _ModuleTable_;
===========================
step 11
lua ProjectDIR/src/lmod.in.lua shell --regression_testing use -h
===========================
__LMOD_REF_COUNT_MODULEPATH=OutputDIR/-h:1\;OutputDIR/--help:1;
export __LMOD_REF_COUNT_MODULEPATH;
MODULEPATH=OutputDIR/-h:OutputDIR/--help;
export MODULEPATH;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"OutputDIR/-h","OutputDIR/--help",},}';
export _ModuleTable_;
2 changes: 2 additions & 0 deletions rt/use_unuse/use_unuse.tdesc
Expand Up @@ -37,6 +37,8 @@ testdescript = {
unsetMT
runLmod use $(testDir)/mf/RTM2 # 8
runLmod unuse $(testDir)/mf/RTM2 # 9
runLmod use --help #10
runLmod use -h #11
HOME=$ORIG_HOME
Expand Down
1 change: 1 addition & 0 deletions src/MName.lua
Expand Up @@ -79,6 +79,7 @@ function M.new(self, sType, name, action, is, ie)
latest = Latest,
between = Between,
atleast = Between,
atmost = Between,
}
end

Expand Down
15 changes: 10 additions & 5 deletions src/cmdfuncs.lua
Expand Up @@ -1173,11 +1173,11 @@ end
-- possibly reloaded if a module.
function Use(...)
dbg.start{"Use(", concatTbl({...},", "),")"}
local mt = FrameStk:singleton():mt()
local a = {}
local mcp_old = mcp
local mcp = MCP
local op = mcp.prepend_path
local mt = FrameStk:singleton():mt()
local a = {}
local mcp_old = mcp
local mcp = MCP
local op = mcp.prepend_path

local argA = pack(...)
local iarg = 1
Expand All @@ -1199,6 +1199,11 @@ function Use(...)
iarg = iarg + 1
end
for _,v in ipairs(a) do
-- Produce warning if leading minus sign(s) are found.
if (v:find("^-+")) then
LmodWarning{msg="w_Possible_Bad_Dir",dir=v}
end

if (v:sub(1,1) ~= '/') then
local old = v
-- If relative convert to try to convert to absolute path
Expand Down
16 changes: 15 additions & 1 deletion src/modfuncs.lua
Expand Up @@ -567,7 +567,7 @@ function conflict(...)
end

--------------------------------------------------------------------------
-- A load and prereq modifier. It is used like this:
-- A load, prereq and conflict modifier. It is used like this:
-- load(atleast("gcc","4.8"))
-- @param m module name
-- @param is the starting version
Expand All @@ -580,6 +580,20 @@ function atleast(m, is)
return mname
end

--------------------------------------------------------------------------
-- A load, prereq and conflict modifier. It is used like this:
-- load(atleast("gcc","4.8"))
-- @param m module name
-- @param is the starting version
function atmost(m, ie)
dbg.start{"atmost(",m,", ",ie,")"}

local mname = MName:new("load", m, "atmost", false, ie)

dbg.fini("atleast")
return mname
end

--------------------------------------------------------------------------
-- A load and prereq modifier. It is used like this:
-- load(between("gcc","4.8","4.9"))
Expand Down
1 change: 1 addition & 0 deletions src/sandbox.lua
Expand Up @@ -113,6 +113,7 @@ local sandbox_env = {

--- Load Modify functions ---
atleast = atleast,
atmost = atmost,
between = between,
latest = latest,

Expand Down

0 comments on commit f4e647f

Please sign in to comment.