-- -*- lua -*-

testdescript = {
   owner   = "rtm",
   product = "modules",
   description = [[
	 Test initial module load
   ]],
   keywords = {"perl" },

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

   runScript = [[

     . $(projectDir)/rt/common_funcs.sh

     unsetMT
     initStdEnvVars
     MODULEPATH_ROOT=$(testDir)/mf;     export MODULEPATH_ROOT
     MODULEPATH="$(testDir)/mf/Core";   export MODULEPATH

     rm -fr _stderr.* _stdout.* err.* out.* .lmod.d init

     mkdir init
     sed -e 's|@PKG@/libexec/lmod|lua $(projectDir)/src/lmod.in.lua|g' \
              < $(projectDir)/init/perl > init/perl

cat > $(testName).pl << EOF
#!/usr/bin/env perl
use strict;

require "$(outputDir)/init/perl";

module("load foobar");

print "\\\$ENV{FOOBAR}: ".\$ENV{"FOOBAR"}."\n";

print STDERR "\navail:\n";
module("avail");
print STDERR "\nlist\n";
module("list");
print  STDERR "\nunload foobar\n";
module("unload foobar");
print  STDERR "\nlist\n";
module("list");
print "\\\$ENV{FOOBAR}: ".\$ENV{"FOOBAR"}."\n";
EOF




     chmod +x $(testName).pl
     ./$(testName).pl  > _stdout.000 2> _stderr.000

     HOME=$ORIG_HOME
     cleanUp _stdout.000 out.txt
     cleanUp _stderr.000 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'},
   },

}
