[meta]
    title = "job script torture test"

    description = """Any task job script may fail regardless of user runtime
settings if changes to cylc re-order the job script sections badly: e.g.
"cylc task started" must be called after the CYLC_ environment variables
are exported. Additionally, users may rely on the order of variable
definition in each environment and script section: e.g. suite
bin directory must go in PATH before the task runtime environment is
defined because suite bin commands could be used in variable assignment
expressions."""

[cylc]
    [[reference test]]
        live mode suite timeout = PT30S
        dummy mode suite timeout = PT30S
        simulation mode suite timeout = PT30S

[scheduling]
    [[dependencies]]
        graph = "foo"
[runtime]
    [[foo]]
        init-script = """
echo "HELLO FROM INIT-SCRIPT"
# define a variable
export VAR_IS=is"""
        pre-script = """
echo "HELLO FROM PRE-SCRIPT"
# init-script must be done:
echo VAR_IS is $VAR_IS
# user environment must be done:
echo E_ONE is $E_ONE
echo E_TWO is $E_TWO
echo E_THR is $E_THR
echo E_FOU is $E_FOU
echo E_FIV is $E_FIV
# define a variable
export VAR_PreCS=precs"""
        script = """
echo "HELLO FROM SCRIPT"
# init-script must be done:
echo VAR_IS is $VAR_IS
# pre-script must be done:
echo VAR_PreCS is $VAR_PreCS
# environment must be done:
echo E_ONE is $E_ONE
echo E_TWO is $E_TWO
echo E_THR is $E_THR
echo E_FOU is $E_FOU
echo E_FIV is $E_FIV
# define a variable
export VAR_CS=var_cs"""
        post-script = """
echo "HELLO FROM POST-SCRIPT"
# init-script must be done:
echo VAR_IS is $VAR_IS
# pre-script must be done:
echo VAR_PreCS is $VAR_PreCS
# script must be done:
echo VAR_CS is $VAR_CS
# environment must be done:
echo E_ONE is $E_ONE
echo E_TWO is $E_TWO
echo E_THR is $E_THR
echo E_FOU is $E_FOU
echo E_FIV is $E_FIV
echo VAR_IS is $VAR_IS
echo VAR_PreCS is $VAR_PreCS
echo VAR_CS is $VAR_CS
# define a variable
export VAR_PostCS=postcs"""
        [[[environment]]]
            # path to cylc must be available:
            E_ONE = $(( RANDOM % 10 ))
            # init-script must be done:
            E_TWO = $VAR_IS
            # cylc-defined variables must be done:
            E_THR = $CYLC_SUITE_SHARE_PATH
            E_FOU = $CYLC_TASK_NAME
            # the suite bin must be in $PATH already:
            E_FIV = $( foo.sh )
        [[[remote]]]
            # force use of ssh job submission to disconnect local tasks
            # from the submitting suite environment.
            host = localhost
