Skip to content

Commit

Permalink
Support for directories with dashes for "make busted"
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Sep 6, 2024
1 parent eb664a5 commit e2937bb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
11 changes: 7 additions & 4 deletions spec/MName/MName_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local posix = require("posix")

require("strict")
require("utils")
require("string_utils")
initialize_lmod()
require("fileOps")

Expand Down Expand Up @@ -75,13 +76,14 @@ describe("Testing MName Class #MName.",
action = "match", fn = "%ProjDir%/spec/MName/mf/mpi/impi/64/5.0.3/048"},
}

local projDirE = projDir:escape()
for i = 1, #goldA do
local gold = goldA[i]
dbg.print{"RTM MName:new(\"load\", ",gold.value,",", gold.action,")\n"}
local mname = MName:new("load", gold.value, gold.action)
dbg.print{"RTM MName:sn()\n"}
local sn = mname:sn()
local fn = (mname:fn() or ""):gsub(projDir,"%%ProjDir%%")
local fn = (mname:fn() or ""):gsub(projDirE,"%%ProjDir%%")
local version = mname:version()
dbg.print{"RTM MName:fullName()\n"}
local fullName = mname:fullName()
Expand Down Expand Up @@ -116,7 +118,7 @@ describe("Testing MName Class #MName.",
local gold = goldA[i]
local mname = MName:new("load", gold.value, gold.action, gold.is, gold.ie)
local sn = mname:sn()
local fn = (mname:fn() or ""):gsub(projDir,"%%ProjDir%%")
local fn = (mname:fn() or ""):gsub(projDirE,"%%ProjDir%%")
local version = mname:version()
local fullName = mname:fullName()
local g_full = build_fullName(gold.sn, gold.version)
Expand Down Expand Up @@ -154,11 +156,12 @@ describe("Testing MName Class #MName.",
fn = "%ProjDir%/spec/MName/nv/bio/bt/3.9"},
}

local projDirE = projDir:escape()
for i = 1, #goldA do
local gold = goldA[i]
local mname = MName:new("load", gold.value, gold.action)
local sn = mname:sn()
local fn = (mname:fn() or ""):gsub(projDir,"%%ProjDir%%")
local fn = (mname:fn() or ""):gsub(projDirE,"%%ProjDir%%")
local version = mname:version()
local fullName = mname:fullName()
local g_full = build_fullName(gold.sn ,gold.version)
Expand All @@ -179,7 +182,7 @@ describe("Testing MName Class #MName.",
local gold = goldA[i]
local mname = MName:new("load", gold.value, gold.action, gold.is, gold.ie)
local sn = mname:sn()
local fn = (mname:fn() or ""):gsub(projDir,"%%ProjDir%%")
local fn = (mname:fn() or ""):gsub(projDirE,"%%ProjDir%%")
local version = mname:version()
local fullName = mname:fullName()
local g_full = build_fullName(gold.sn, gold.version)
Expand Down
26 changes: 17 additions & 9 deletions src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -643,15 +643,12 @@ function regular_cmp(x,y)
end





function sanizatizeTbl(rplmntA, inT, outT)
local function l_sanizatizeTbl(replaceA, inT, outT)
for k, v in pairs(inT) do
local key = k
if (type(k) == "string") then
for i = 1, #rplmntA do
local p = rplmntA[i]
for i = 1, #replaceA do
local p = replaceA[i]
local s1 = p[1]
local s2 = p[2]
key = key:gsub(s1,s2)
Expand All @@ -662,11 +659,11 @@ function sanizatizeTbl(rplmntA, inT, outT)
outT[key] = nil
elseif (type(v) == "table") then
outT[key] = {}
sanizatizeTbl(rplmntA, v, outT[key])
l_sanizatizeTbl(replaceA, v, outT[key])
v = outT[key]
elseif (type(v) == "string") then
for i = 1,#rplmntA do
local p = rplmntA[i]
for i = 1,#replaceA do
local p = replaceA[i]
local s1 = p[1]
local s2 = p[2]
v = v:gsub(s1,s2)
Expand All @@ -679,6 +676,17 @@ function sanizatizeTbl(rplmntA, inT, outT)
end
end

function sanizatizeTbl(rplmntA, inT, outT)
local replaceA = {}
for i = 1,#rplmntA do
local p = rplmntA[i]
replaceA[i] = { p[1]:escape(), p[2]}
end

l_sanizatizeTbl(replaceA, inT, outT)
end


--------------------------------------------------------------------------
-- Push the Lmod Version into the environment
function setenv_lmod_version()
Expand Down

0 comments on commit e2937bb

Please sign in to comment.