-- -*- lua -*-
local testName = "settarg"
testdescript = {
   owner   = "rtm",
   product = "modules",
   description = [[
	 Test initial module load
   ]],
   keywords = {testName,"settarg" },

   active = 1,
   testName = testName,
   job_submit_method = "INTERACTIVE",

   runScript = [[

     . $(projectDir)/rt/common_funcs.sh

     unsetMT
     unsetSTT
     clearTARG
     initStdEnvVars
     unset SETTARG_TAG1
     unset SETTARG_TAG2
     export MODULEPATH_ROOT=$(testDir)/mf
     export MODULEPATH=$(outputDir)/mf/Core:$MODULEPATH_ROOT/Core
     export TARG_RTM="Is Great"; 

     rm -fr _stderr.* _stdout.* err.* out.* .lmod.d settarg_rc.lua .settarg.lua

     cp $(projectDir)/settarg/settarg_rc.lua  settarg_rc.lua
     export LMOD_SETTARG_RC=$(outputDir)/settarg_rc.lua
     cp $(testDir)/.settarg.lua .


     mkdir -p mf/Core/settarg
     sed -e 's|@PKG@|$(projectDir)|g'                    \
         -e 's|@settarg_cmd@|settarg_cmd.in.lua|g'       \
         -e "s|@path_to_lua@|$LUA_EXEC|g"                \
          < $(projectDir)/MF/settarg.version.lua > mf/Core/settarg/1.0.lua

     export LMOD_SETTARG_FULL_SUPPORT=full
     export LMOD_SETTARG_TITLE_BAR=yes

     runLmod --version                              # 1
     runLmod load settarg                           # 2
     runSettargBash dbg                             # 3
     export SETTARG_TAG1="obj";
     export SETTARG_TAG2="__"; 
     runSettargBash opt                             # 4
     runSettargBash empty                           # 5
     runLmod load gcc mpich                         # 6
     runSettargBash                                 # 7
     runSettargBash f_f                             # 8
     runSettargBash b:b                             # 9
     runSettargBash -r f_f                          #10
     runSettargBash -r b:b                          #11
     runSettargBash f_f b:b                         #12
     runSettargBash --stt dbg                       #13
     runSettargBash --purge                         #14
     runBase echo "TARG_RTM: $TARG_RTM"             #15
     runLmod unload mpich                           #16
     runSettargBash                                 #17
     runLmod unload gcc                             #18
     runLmod load   cmplr/clang                     #19


     runLmod show settarg                           #20
     runLmod unload settarg                         #21

     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'},
   },

}
