Debian Codegraph @

cylc/flow/etc/examples/extending-workflow/.validate

raw
1 #!/bin/bash
2 # THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
3 # Copyright (C) NIWA & British Crown (Met Office) & Contributors.
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 set -eux
19
20 test_simple () {
21 local ID
22 ID="$(< /dev/urandom tr -dc A-Za-z | head -c6)"
23
24 # lint
25 cylc lint ./simple
26
27 # copy into a temp directory
28 local SRC_DIR
29 SRC_DIR="$(mktemp -d)"
30 cp simple/flow.cylc "$SRC_DIR"
31
32 # speed things up with simulation mode
33 cat >>"${SRC_DIR}/flow.cylc" <<__HERE__
34 [runtime]
35 [[root]]
36 [[[simulation]]]
37 default run length = PT0S
38 __HERE__
39
40 # start the workflow
41 cylc vip \
42 --check-circular \
43 --no-run-name \
44 --no-detach \
45 --workflow-name "$ID" \
46 --mode=simulation \
47 "$SRC_DIR"
48
49 # it should have reached the 2002 cycle
50 grep '2002/a' "${HOME}/cylc-run/${ID}/log/scheduler/log"
51 if grep '2003/a' "${HOME}/cylc-run/${ID}/log/scheduler/log"; then
52 exit 1
53 fi
54
55 # edit the "stop after cycle point"
56 sed -i \
57 's/stop after cycle point.*/stop after cycle point = 2004/' \
58 "${SRC_DIR}/flow.cylc"
59
60 # continue the run
61 cylc vr \
62 --no-detach \
63 --mode=simulation \
64 --yes \
65 "$ID"
66
67 # it should have reached the 2004 cycle
68 grep '2004/a' "${HOME}/cylc-run/${ID}/log/scheduler/log"
69 if grep '2005/a' "${HOME}/cylc-run/${ID}/log/scheduler/log"; then
70 exit 1
71 fi
72
73 # clean up
74 cylc clean "$ID"
75
76 rm -r "${SRC_DIR}"
77 }
78
79
80 test_simple