Skip to content

Commit

Permalink
Issue #675: Adding test to show that remove_path works with module un…
Browse files Browse the repository at this point in the history
…load
  • Loading branch information
Robert McLay committed Nov 12, 2023
1 parent 1a06901 commit 807fa78
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 2 deletions.
18 changes: 18 additions & 0 deletions rt/path_play/err.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
===========================
step 1
lua ProjectDIR/src/lmod.in.lua shell --regression_testing --version
===========================
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 load A B
===========================
===========================
step 3
lua ProjectDIR/src/lmod.in.lua shell --regression_testing unload B
===========================
===========================
step 4
lua ProjectDIR/src/lmod.in.lua shell --regression_testing unload A
===========================
2 changes: 2 additions & 0 deletions rt/path_play/mf/Core/A/1.0.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
setenv("A","A")
remove_path("PATH","/path/to/remove")
2 changes: 2 additions & 0 deletions rt/path_play/mf/Core/B/2.0.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
setenv("B","B")
remove_path("PATH","/path/to/remove")
54 changes: 54 additions & 0 deletions rt/path_play/out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
===========================
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 B
===========================
A=A;
export A;
B=B;
export B;
LOADEDMODULES=A/1.0:B/2.0;
export LOADEDMODULES;
__LMOD_REF_COUNT_MODULEPATH=ProjectDIR/rt/path_play/mf/Core:1;
export __LMOD_REF_COUNT_MODULEPATH;
MODULEPATH=ProjectDIR/rt/path_play/mf/Core;
export MODULEPATH;
__LMOD_REF_COUNT_PATH=ProjectDIR/proj_mgmt:1\;PATH_to_TM:1;
export __LMOD_REF_COUNT_PATH;
PATH=ProjectDIR/proj_mgmt:PATH_to_TM;
export PATH;
_LMFILES_=ProjectDIR/rt/path_play/mf/Core/A/1.0.lua:ProjectDIR/rt/path_play/mf/Core/B/2.0.lua;
export _LMFILES_;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={A={fn="ProjectDIR/rt/path_play/mf/Core/A/1.0.lua",fullName="A/1.0",loadOrder=1,propT={},stackDepth=0,status="active",userName="A",wV="000000001.*zfinal",},B={fn="ProjectDIR/rt/path_play/mf/Core/B/2.0.lua",fullName="B/2.0",loadOrder=2,propT={},stackDepth=0,status="active",userName="B",wV="000000002.*zfinal",},},mpathA={"ProjectDIR/rt/path_play/mf/Core",},systemBaseMPATH="ProjectDIR/rt/path_play/mf/Core",}';
export _ModuleTable_;
===========================
step 3
lua ProjectDIR/src/lmod.in.lua shell --regression_testing unload B
===========================
unset B;
LOADEDMODULES=A/1.0;
export LOADEDMODULES;
MODULEPATH=ProjectDIR/rt/path_play/mf/Core;
export MODULEPATH;
PATH=ProjectDIR/proj_mgmt:PATH_to_TM;
export PATH;
_LMFILES_=ProjectDIR/rt/path_play/mf/Core/A/1.0.lua;
export _LMFILES_;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={A={fn="ProjectDIR/rt/path_play/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/path_play/mf/Core",},systemBaseMPATH="ProjectDIR/rt/path_play/mf/Core",}';
export _ModuleTable_;
===========================
step 4
lua ProjectDIR/src/lmod.in.lua shell --regression_testing unload A
===========================
unset A;
unset LOADEDMODULES;
MODULEPATH=ProjectDIR/rt/path_play/mf/Core;
export MODULEPATH;
PATH=ProjectDIR/proj_mgmt:PATH_to_TM;
export PATH;
unset _LMFILES_;
_ModuleTable_='_ModuleTable_={MTversion=3,depthT={},family={},mT={},mpathA={"ProjectDIR/rt/path_play/mf/Core",},systemBaseMPATH="ProjectDIR/rt/path_play/mf/Core",}';
export _ModuleTable_;
56 changes: 56 additions & 0 deletions rt/path_play/path_play.tdesc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
-- -*- lua -*-
local testName = "path_play"

testdescript = {
owner = "rtm",
product = "modules",
description = [[
path_play
]],
keywords = {testName },

active = true,
testName = testName,
job_submit_method = "INTERACTIVE",

runScript = [[
. $(projectDir)/rt/common_funcs.sh
unsetMT
initStdEnvVars
export MODULEPATH_ROOT=$(testDir)/mf
export MODULEPATH=$MODULEPATH_ROOT/Core
rm -fr _stderr.* _stdout.* err.* out.*
runLmod --version # 1
runLmod load A B # 2
runLmod unload B # 3
runLmod unload A # 3
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'},
},

}
4 changes: 2 additions & 2 deletions src/MainControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ end
-- Set an environment variable.
-- This function just sets the name with value in the current env.
function M.setenv_env(self, name, value, respect)
name = name:trim()
name = (name or ""):trim()
dbg.start{"MainControl:setenv_env(\"",name,"\", \"",value,"\", \"",
respect,"\")"}
posix.setenv(name, value, true)
Expand All @@ -351,7 +351,7 @@ end
-- @param value the environment variable value.
-- @param respect If true, then respect the old value.
function M.unsetenv(self, name, value, respect)
name = name:trim()
name = (name or ""):trim()
dbg.start{"MainControl:unsetenv(\"",name,"\", \"",value,"\")"}

l_check_for_valid_name("unsetenv",name)
Expand Down

0 comments on commit 807fa78

Please sign in to comment.