1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
-- -*- lua -*-
testdescript = {
owner = "rtm",
product = "modules",
description = [[
Test initial module load
]],
keywords = {"python" },
active = 1,
testName = "python",
job_submit_method = "INTERACTIVE",
runScript = [[
. $(projectDir)/rt/common_funcs.sh
unsetMT
initStdEnvVars
MODULEPATH_ROOT=$(testDir)/mf; export MODULEPATH_ROOT
MODULEPATH="$MODULEPATH_ROOT/Core"; export MODULEPATH
rm -rf init .cache .config
mkdir init
sed -e "s|'@PKG@/libexec/lmod'|'lua','$(projectDir)/src/lmod.in.lua'|g" \
-e 's|@redirect@|no|g' \
< $(projectDir)/init/env_modules_python.py.in > init/env_modules_python.py
cat > $(testName).py << 'EOF'
#!/bin/sh
# -*- python -*-
################################################################################
# This file is python 2/3 bilingual.
# The line """:" starts a comment in python and is a no-op in shell.
""":"
# Shell code to find and run a suitable python interpreter.
for cmd in python3 python python2; do
command -v > /dev/null $cmd && exec $cmd $0 "$@"
done
echo "Error: Could not find a valid python interpreter --> exiting!" >&2
exit 2
":""" # this line ends the python comment and is a no-op in shell.
################################################################################
from __future__ import print_function
import os, sys
sys.path.insert(0,"$(outputDir)/init/")
from env_modules_python import module
module("load","foobar bar")
module("load","A","B")
print ("os.environ['FOOBAR']: ",'"' + os.environ['FOOBAR'] + '"')
print ("os.environ['M']: ", '"' + os.environ['M'] + '"')
module("avail");
os.environ['LMOD_REDIRECT'] = 'yes'
module("avail");
module("load","bad")
EOF
remove_generated_lmod_files
chmod +x $(testName).py
./$(testName).py > _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'},
},
}
|