Debian Codegraph @

tests/functional/param_expand/02-param_val.t

raw
1 #!/usr/bin/env 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 # Check tasks and graph generated by parameter expansion.
19
20 . "$(dirname "$0")/test_header"
21 set_test_number 23
22
23 #------------------------------------------------------------------------------
24 cat >'flow.cylc' <<'__WORKFLOW__'
25 [task parameters]
26 i = cat, dog, fish
27 j = 1..5
28 [scheduling]
29 [[graph]]
30 R1 = """foo => bar<i,j>
31 bar<i=cat,j=3> => boo"""
32 [runtime]
33 [[foo, boo]]
34 script = true
35 [[FAM<i,j>]]
36 [[bar<i,j>]]
37 inherit = "FAM<i,j>"
38 [[bar<i=cat,j=3>]]
39 inherit = "FAM<i,j>" # implicit values here (takes i=cat,j=3)
40 __WORKFLOW__
41
42 TNAME=${TEST_NAME_BASE}-1
43 # validate
44 run_ok "${TNAME}" cylc validate .
45 # family graph
46 graph_workflow . "${TNAME}-graph-fam" --group="<all>"
47 cmp_ok "${TNAME}-graph-fam" "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/graph-fam-1.ref"
48 # task graph
49 graph_workflow . "${TNAME}-graph-exp"
50 cmp_ok "${TNAME}-graph-exp" "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/graph-exp-1.ref"
51 # inheritance graph
52 graph_workflow . "${TNAME}-graph-nam" -n
53 cmp_ok "${TNAME}-graph-nam" "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/graph-nam-1.ref"
54
55 #------------------------------------------------------------------------------
56 cat >'flow.cylc' <<'__WORKFLOW__'
57 [task parameters]
58 i = cat, dog, fish
59 j = 1..5
60 [scheduling]
61 [[graph]]
62 R1 = """foo => bar<i,j>
63 bar<i=cat,j=3> => boo"""
64 [runtime]
65 [[foo, boo]]
66 script = true
67 [[FAM<i,j>]]
68 [[bar<i,j>]]
69 inherit = "FAM<i,j>"
70 [[bar<i=cat,j=3>]]
71 inherit = "FAM<i=cat,j=3>" # same with explicit values
72 __WORKFLOW__
73
74 TNAME=${TEST_NAME_BASE}-2
75 # validate
76 run_ok "${TNAME}" cylc validate .
77 # family graph
78 graph_workflow . "${TNAME}-graph-fam" "--group=<all>"
79 cmp_ok "${TNAME}-graph-fam" "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/graph-fam-1.ref"
80 # task graph
81 graph_workflow . "${TNAME}-graph-exp"
82 cmp_ok "${TNAME}-graph-exp" "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/graph-exp-1.ref"
83 # inheritance graph
84 graph_workflow . "${TNAME}-graph-nam" -n
85 cmp_ok "${TNAME}-graph-nam" "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/graph-nam-1.ref"
86
87 #------------------------------------------------------------------------------
88 # Same, with white space in the parameter syntax.
89 cat >'flow.cylc' <<'__WORKFLOW__'
90 [task parameters]
91 i = cat, dog, fish
92 j = 1..5
93 [scheduling]
94 [[graph]]
95 R1 = """foo => bar< i ,j >
96 bar< i = cat , j = 3 > => boo"""
97 [runtime]
98 [[foo, boo]]
99 script = true
100 [[FAM<i,j>]]
101 [[bar<i,j>]]
102 inherit = "FAM< i, j>"
103 [[bar<i=cat,j=3>]]
104 inherit = "FAM<i = cat ,j=3>"
105 __WORKFLOW__
106
107 TNAME=${TEST_NAME_BASE}-3
108 # validate
109 run_ok "${TNAME}" cylc validate .
110 # family graph
111 graph_workflow . "${TNAME}-graph-fam" "--group=<all>"
112 cmp_ok "${TNAME}-graph-fam" "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/graph-fam-1.ref"
113 # task graph
114 graph_workflow . "${TNAME}-graph-exp"
115 cmp_ok "${TNAME}-graph-exp" "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/graph-exp-1.ref"
116 # inheritance graph
117 graph_workflow . "${TNAME}-graph-nam" -n
118 cmp_ok "${TNAME}-graph-nam" "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/graph-nam-1.ref"
119
120 #------------------------------------------------------------------------------
121 cat >'flow.cylc' <<'__WORKFLOW__'
122 [task parameters]
123 i = cat, dog, fish
124 j = 1..5
125 [scheduling]
126 [[graph]]
127 R1 = """foo => bar<i,j>
128 bar<i=cat,j=3> => boo"""
129 [runtime]
130 [[foo, boo]]
131 script = true
132 [[FAM<i,j>]]
133 [[bar<i,j>]]
134 inherit = "FAM<i,j>"
135 [[bar<i=cat,j=3>]]
136 inherit = "FAM<i=dog,j=1>" # different explicit values are legal
137 __WORKFLOW__
138
139 TNAME=${TEST_NAME_BASE}-4
140 # validate
141 run_ok "${TNAME}" cylc validate .
142 # family graph
143 graph_workflow . "${TNAME}-graph-fam" "--group=<all>"
144 cmp_ok "${TNAME}-graph-fam" "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/graph-fam-b.ref"
145 # task graph
146 graph_workflow . "${TNAME}-graph-exp"
147 cmp_ok "${TNAME}-graph-exp" "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/graph-exp-b.ref"
148 # inheritance graph
149 graph_workflow . "${TNAME}-graph-nam" -n
150 cmp_ok "${TNAME}-graph-nam" "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/graph-nam-b.ref"
151
152 #------------------------------------------------------------------------------
153 cat >'flow.cylc' <<'__WORKFLOW__'
154 [task parameters]
155 i = cat, dog, fish
156 j = 1..5
157 [scheduling]
158 [[graph]]
159 R1 = """foo => bar<i,j>
160 bar<i=cat,j=3> => boo"""
161 [runtime]
162 [[foo]]
163 script = true
164 [[FAM<i,j>]]
165 [[bar<i,j>]]
166 inherit = "FAM<i,j>"
167 [[bar<i=cat,j=3>]]
168 inherit = "FAM<i=dog,j=1>"
169 [[boo]]
170 inherit = "FAM<i=dog,j=1>" # OK (plain task can inherit from specific params)
171 __WORKFLOW__
172
173 run_ok "${TEST_NAME_BASE}-5" cylc validate .
174
175 #------------------------------------------------------------------------------
176 cat >'flow.cylc' <<'__WORKFLOW__'
177 [task parameters]
178 i = cat, dog, fish
179 j = 1..5
180 [scheduling]
181 [[graph]]
182 R1 = """foo => bar<i>_baz<j>"""
183 [runtime]
184 [[foo]]
185 script = true
186 [[BAR<i>]]
187 [[BAZ<j>]]
188 [[bar<i>_baz<j>]] # OK params separate
189 inherit = BAR<i>, BAZ<j>
190 __WORKFLOW__
191
192 run_ok "${TEST_NAME_BASE}-6" cylc validate .
193 cylc graph --reference . 1>'06.graph'
194 cmp_ok '06.graph' "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/06.graph.ref"
195
196 #------------------------------------------------------------------------------
197 cat >'flow.cylc' <<'__WORKFLOW__'
198 [task parameters]
199 i = cat, dog, fish
200 j = 1..5
201 [scheduling]
202 [[graph]]
203 R1 = """foo => bar<i,j>
204 bar<i=cat,j=3> => boo"""
205 [runtime]
206 [[foo, boo]]
207 script = true
208 [[FAM<i,j>]]
209 [[bar<i,j>]]
210 inherit = "FAM<i=frog,j>" # ERROR: no frog
211 [[bar<i=cat,j=3>]]
212 inherit = "FAM<i=dog,j=1>"
213 __WORKFLOW__
214
215 TNAME=${TEST_NAME_BASE}-err-1
216 run_fail "${TNAME}" cylc validate .
217 cmp_ok "${TNAME}.stderr" - << __ERR__
218 ParamExpandError: illegal value 'i=frog' in 'inherit = FAM<i=frog,j>'
219 __ERR__
220
221 #------------------------------------------------------------------------------
222 cat >'flow.cylc' <<'__WORKFLOW__'
223 [task parameters]
224 i = cat, dog, fish
225 j = 1..5
226 [scheduling]
227 [[graph]]
228 R1 = """foo => bar<i,j>
229 bar<i=cat,j=3> => boo"""
230 [runtime]
231 [[foo]]
232 script = true
233 [[FAM<i,j>]]
234 [[bar<i,j>]]
235 inherit = "FAM<i,j>"
236 [[bar<i=cat,j=3>]]
237 inherit = "FAM<i=dog,j=1>"
238 [[boo]]
239 inherit = "FAM<i,j=1>" # ERROR: i undefined here.
240 __WORKFLOW__
241
242 TNAME="${TEST_NAME_BASE}-err-2"
243 run_fail "${TNAME}" cylc validate .
244 cmp_ok "${TNAME}.stderr" - << __ERR__
245 ParamExpandError: parameter 'i' undefined in 'inherit = FAM<i,j=1>'
246 __ERR__