diff --git a/spec/MName/MName_spec.lua b/spec/MName/MName_spec.lua index 25c26e9a7..1761bc7d4 100644 --- a/spec/MName/MName_spec.lua +++ b/spec/MName/MName_spec.lua @@ -3,6 +3,7 @@ local posix = require("posix") require("strict") require("utils") +require("string_utils") initialize_lmod() require("fileOps") @@ -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() @@ -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) @@ -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) @@ -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) diff --git a/src/utils.lua b/src/utils.lua index 0c314ea97..35bd27d55 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -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) @@ -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) @@ -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()