TESTS="user_env"

simulate_cmds="sbatch rm" # Simulate rm in order not to get job script deleted
read -r -d '' simulator_output <<'EOF'
rargs="/sbatch .*/"
output="Submitted batch job 1"

rargs="/rm .*/"
output=""
EOF

read -r -d '' general_arc_test_configuration <<EOF
[lrms]
slurm_bin_path=@PWD@/bin
EOF

function test_user_env() {
read -r -d '' job_description_input <<'EOF'
&(executable = "/bin/true")
(environment = ("TEST" "Testing")
               ("TEST2" "'Testing'"))
EOF

read -r -d '' job_script_patch <<'EOF'
--- a/basic-script.sh 2014-01-28 10:35:19.780083853 +0100
+++ b/basic-script.sh 2014-01-28 10:35:19.772083853 +0100
@@ -20,6 +20,8 @@
 . $script
 }
 # Setting environment variables as specified by user
+export 'TEST=Testing'
+export 'TEST2='\''Testing'\'''
 export 'GRID_GLOBAL_JOBID=@TEST_JOB_ID@'
 
 RUNTIME_JOB_DIR=@TEST_SESSION_DIR@/@TEST_JOB_ID@
EOF
echo "${job_script_patch}" | patch -sf -p1 -d ${SRCDIR} -o ${testdir}/expected_lrms_job_script.tmpl
}
