From 807fa787fb90fcf4442551cd34506803714a0823 Mon Sep 17 00:00:00 2001 From: Robert McLay Date: Sun, 12 Nov 2023 11:48:48 -0700 Subject: [PATCH] Issue #675: Adding test to show that remove_path works with module unload --- rt/path_play/err.txt | 18 +++++++++++ rt/path_play/mf/Core/A/1.0.lua | 2 ++ rt/path_play/mf/Core/B/2.0.lua | 2 ++ rt/path_play/out.txt | 54 ++++++++++++++++++++++++++++++++ rt/path_play/path_play.tdesc | 56 ++++++++++++++++++++++++++++++++++ src/MainControl.lua | 4 +-- 6 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 rt/path_play/err.txt create mode 100644 rt/path_play/mf/Core/A/1.0.lua create mode 100644 rt/path_play/mf/Core/B/2.0.lua create mode 100644 rt/path_play/out.txt create mode 100644 rt/path_play/path_play.tdesc diff --git a/rt/path_play/err.txt b/rt/path_play/err.txt new file mode 100644 index 000000000..871684c77 --- /dev/null +++ b/rt/path_play/err.txt @@ -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 mclay@tacc.utexas.edu +=========================== +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 +=========================== diff --git a/rt/path_play/mf/Core/A/1.0.lua b/rt/path_play/mf/Core/A/1.0.lua new file mode 100644 index 000000000..e77fb069e --- /dev/null +++ b/rt/path_play/mf/Core/A/1.0.lua @@ -0,0 +1,2 @@ +setenv("A","A") +remove_path("PATH","/path/to/remove") diff --git a/rt/path_play/mf/Core/B/2.0.lua b/rt/path_play/mf/Core/B/2.0.lua new file mode 100644 index 000000000..65e72a33e --- /dev/null +++ b/rt/path_play/mf/Core/B/2.0.lua @@ -0,0 +1,2 @@ +setenv("B","B") +remove_path("PATH","/path/to/remove") diff --git a/rt/path_play/out.txt b/rt/path_play/out.txt new file mode 100644 index 000000000..b73fc0584 --- /dev/null +++ b/rt/path_play/out.txt @@ -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_; diff --git a/rt/path_play/path_play.tdesc b/rt/path_play/path_play.tdesc new file mode 100644 index 000000000..984147220 --- /dev/null +++ b/rt/path_play/path_play.tdesc @@ -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'}, + }, + +} diff --git a/src/MainControl.lua b/src/MainControl.lua index 4cffca8d8..0ada7442d 100644 --- a/src/MainControl.lua +++ b/src/MainControl.lua @@ -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) @@ -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)