Debian Codegraph @

tests/functional/param_expand/01-basic.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 . "$(dirname "$0")/test_header"
20 set_test_number 39
21
22 cat >'flow.cylc' <<'__WORKFLOW__'
23 [task parameters]
24 i = cat, dog, fish
25 j = 1..5
26 k = 1..10..4
27 [scheduling]
28 [[graph]]
29 R1 = """
30 foo<i> => bar<j>
31 qux<j> => waz<k>
32 """
33 [runtime]
34 [[root]]
35 script = true
36 [[foo<i>]]
37 [[bar<j>]]
38 [[qux<j>]]
39 [[waz<k>]]
40 __WORKFLOW__
41 run_ok "${TEST_NAME_BASE}-01" cylc validate .
42 cylc graph --reference . >'01.graph'
43 cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/01.graph.ref" '01.graph'
44
45 cat >'flow.cylc' <<'__WORKFLOW__'
46 [task parameters]
47 i = 25, 30..35, 1..5, 110
48 [scheduling]
49 [[graph]]
50 R1 = """
51 foo<i> => bar<i>
52 """
53 [runtime]
54 [[root]]
55 script = true
56 [[foo<i>]]
57 [[bar<i>]]
58 __WORKFLOW__
59 run_ok "${TEST_NAME_BASE}-02" cylc validate .
60 cylc graph --reference . >'02.graph'
61 cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/02.graph.ref" '02.graph'
62
63 cat >'flow.cylc' <<'__WORKFLOW__'
64 [task parameters]
65 i = a-t, c-g
66 [scheduling]
67 [[graph]]
68 R1 = """
69 foo<i> => bar<i>
70 """
71 [runtime]
72 [[root]]
73 script = true
74 [[foo<i>]]
75 [[bar<i>]]
76 __WORKFLOW__
77 run_ok "${TEST_NAME_BASE}-03" cylc validate .
78 cylc graph --reference . >'03.graph'
79 cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/03.graph.ref" '03.graph'
80
81 cat >'flow.cylc' <<'__WORKFLOW__'
82 [task parameters]
83 i = 100, hundred, one-hundred, 99+1
84 [scheduling]
85 [[graph]]
86 R1 = """
87 foo<i> => bar<i>
88 """
89 [runtime]
90 [[root]]
91 script = true
92 [[foo<i>]]
93 [[bar<i>]]
94 __WORKFLOW__
95 run_ok "${TEST_NAME_BASE}-04" cylc validate .
96 cylc graph --reference . >'04.graph'
97 cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/04.graph.ref" '04.graph'
98
99 cat >'flow.cylc' <<'__WORKFLOW__'
100 [task parameters]
101 i = space is dangerous
102 [scheduling]
103 [[graph]]
104 R1 = """
105 foo<i> => bar<i>
106 """
107 [runtime]
108 [[root]]
109 script = true
110 [[foo<i>]]
111 [[bar<i>]]
112 __WORKFLOW__
113 run_fail "${TEST_NAME_BASE}-05" cylc validate .
114 cmp_ok "${TEST_NAME_BASE}-05.stderr" <<'__ERR__'
115 IllegalValueError: (type=parameter) [task parameters]i = space is dangerous - (space is dangerous: bad value)
116 __ERR__
117
118 cat >'flow.cylc' <<'__WORKFLOW__'
119 [task parameters]
120 i = mix, 1..10
121 [scheduling]
122 [[graph]]
123 R1 = """
124 foo<i> => bar<i>
125 """
126 [runtime]
127 [[root]]
128 script = true
129 [[foo<i>]]
130 [[bar<i>]]
131 __WORKFLOW__
132 run_fail "${TEST_NAME_BASE}-06" cylc validate .
133 cmp_ok "${TEST_NAME_BASE}-06.stderr" <<'__ERR__'
134 IllegalValueError: (type=parameter) [task parameters]i = mix, 1..10 - (mixing int range and str)
135 __ERR__
136
137 cat >'flow.cylc' <<'__WORKFLOW__'
138 [task parameters]
139 i = a, b #, c, d, e # comment
140 [scheduling]
141 [[graph]]
142 R1 = """
143 foo<i> => bar<i>
144 """
145 [runtime]
146 [[root]]
147 script = true
148 [[foo<i>]]
149 [[bar<i>]]
150 __WORKFLOW__
151 run_ok "${TEST_NAME_BASE}-07" cylc validate .
152 cylc graph --reference . >'07.graph'
153 cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/07.graph.ref" '07.graph'
154
155 cat >'flow.cylc' <<'__WORKFLOW__'
156 [task parameters]
157 i = 1..2 3..4
158 [scheduling]
159 [[graph]]
160 R1 = """
161 foo<i> => bar<i>
162 """
163 [runtime]
164 [[root]]
165 script = true
166 [[foo<i>]]
167 [[bar<i>]]
168 __WORKFLOW__
169 run_fail "${TEST_NAME_BASE}-08" cylc validate .
170 cmp_ok "${TEST_NAME_BASE}-08.stderr" <<'__ERR__'
171 IllegalValueError: (type=parameter) [task parameters]i = 1..2 3..4 - (1..2 3..4: bad value)
172 __ERR__
173
174 cat >'flow.cylc' <<'__WORKFLOW__'
175 [task parameters]
176 i =
177 [scheduling]
178 [[graph]]
179 R1 = """
180 foo<i> => bar<i>
181 """
182 [runtime]
183 [[root]]
184 script = true
185 [[foo<i>]]
186 [[bar<i>]]
187 __WORKFLOW__
188 run_fail "${TEST_NAME_BASE}-09" cylc validate .
189 cmp_ok "${TEST_NAME_BASE}-09.stderr" <<'__ERR__'
190 ParamExpandError: parameter i is not defined in foo<i>
191 __ERR__
192
193 cat >'flow.cylc' <<'__WORKFLOW__'
194 [scheduling]
195 [[graph]]
196 R1 = """
197 foo<i> => bar<i>
198 """
199 [runtime]
200 [[root]]
201 script = true
202 [[foo<i>]]
203 [[bar<i>]]
204 __WORKFLOW__
205 run_fail "${TEST_NAME_BASE}-10" cylc validate .
206 cmp_ok "${TEST_NAME_BASE}-10.stderr" <<'__ERR__'
207 ParamExpandError: parameter i is not defined in <i>: foo<i>=>bar<i>
208 __ERR__
209
210 cat >'flow.cylc' <<'__WORKFLOW__'
211 [task parameters]
212 j = +1..+5
213 [[templates]]
214 j = @%(j)03d
215 [scheduling]
216 [[graph]]
217 R1 = "foo<j> => bar<j>"
218 [runtime]
219 [[root]]
220 script = true
221 [[foo<j>]]
222 [[bar<j>]]
223 __WORKFLOW__
224 run_ok "${TEST_NAME_BASE}-11" cylc validate .
225 cylc graph --reference . >'11.graph'
226 cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/11.graph.ref" '11.graph'
227
228 cat >'flow.cylc' <<'__WORKFLOW__'
229 [task parameters]
230 j = 1..5
231 [[templates]]
232 j = +%%j%(j)03d
233 [scheduling]
234 [[graph]]
235 R1 = "foo<j> => bar<j>"
236 [runtime]
237 [[root]]
238 script = true
239 [[foo<j>]]
240 [[bar<j>]]
241 __WORKFLOW__
242 run_ok "${TEST_NAME_BASE}-12" cylc validate .
243 cylc graph --reference . >'12.graph'
244 cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/12.graph.ref" '12.graph'
245
246 # Parameter with various meta characters
247 cat >'flow.cylc' <<'__WORKFLOW__'
248 [task parameters]
249 p = -minus, +plus, @at, %percent
250 [[templates]]
251 p = %(p)s
252 [scheduling]
253 [[graph]]
254 R1 = "foo<p> => bar<p>"
255 [runtime]
256 [[root]]
257 script = true
258 [[foo<p>]]
259 [[bar<p>]]
260 __WORKFLOW__
261 run_ok "${TEST_NAME_BASE}-13" cylc validate .
262 cylc graph --reference . >'13.graph'
263 cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/13.graph.ref" '13.graph'
264
265 # Parameter as task name
266 cat >'flow.cylc' <<'__WORKFLOW__'
267 [task parameters]
268 i = 0..2
269 s = mercury, venus, earth, mars
270 [[templates]]
271 i = i%(i)d
272 s = %(s)s
273 [scheduling]
274 [[graph]]
275 R1 = """
276 foo => <i> => bar
277 foo => <s> => bar
278 """
279 [runtime]
280 [[foo, bar, <i>, <s>]]
281 script = true
282 __WORKFLOW__
283 run_ok "${TEST_NAME_BASE}-14" cylc validate .
284 cylc graph --reference . >'14.graph'
285 cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/14.graph.ref" '14.graph'
286
287 # Parameter in middle of family name
288 cat >'flow.cylc' <<'__WORKFLOW__'
289 [task parameters]
290 s = mercury, venus, earth, mars
291 [scheduling]
292 [[graph]]
293 R1 = X<s>Y
294 [runtime]
295 [[X<s>Y]]
296 script = true
297 [[x<s>y]]
298 inherit = X<s>Y
299 __WORKFLOW__
300 run_ok "${TEST_NAME_BASE}-15" cylc validate .
301 cylc graph --reference --group="<all>" . >'15.graph'
302 cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/15.graph.ref" '15.graph'
303
304 # -ve offset on RHS
305 cat >'flow.cylc' <<'__WORKFLOW__'
306 [task parameters]
307 m = cat, dog
308 [scheduling]
309 [[graph]]
310 R1 = "foo<m> => foo<m-1>"
311 [runtime]
312 [[root]]
313 script = true
314 [[foo<m>]]
315 __WORKFLOW__
316 run_ok "${TEST_NAME_BASE}-16" cylc validate .
317 cylc graph --reference . >'16.graph'
318 cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/16.graph.ref" '16.graph'
319
320 # +ve offset
321 cat >'flow.cylc' <<'__WORKFLOW__'
322 [task parameters]
323 m = cat, dog
324 [scheduling]
325 [[graph]]
326 R1 = "foo<m> => foo<m+1>"
327 [runtime]
328 [[root]]
329 script = true
330 [[foo<m>]]
331 __WORKFLOW__
332 run_ok "${TEST_NAME_BASE}-17" cylc validate .
333 cylc graph --reference . >'17.graph'
334 cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/17.graph.ref" '17.graph'
335
336 # Negative integers
337 cat >'flow.cylc' <<'__WORKFLOW__'
338 [task parameters]
339 m = -12..12..6
340 [scheduling]
341 [[graph]]
342 R1 = "foo<m>"
343 [runtime]
344 [[root]]
345 script = true
346 [[foo<m>]]
347 __WORKFLOW__
348 run_ok "${TEST_NAME_BASE}-18" cylc validate .
349 cylc graph --reference . >'18.graph'
350 cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/18.graph.ref" '18.graph'
351
352 # Reference by value, with -+ meta characters
353 cat >'flow.cylc' <<'__WORKFLOW__'
354 [task parameters]
355 lang = c++, fortran-2008
356 [[templates]]
357 lang = %(lang)s
358 [scheduling]
359 [[graph]]
360 R1 = "<lang=c++> => <lang = fortran-2008>"
361 [runtime]
362 [[<lang>]]
363 script = true
364 [[<lang=c++>]]
365 [[[environment]]]
366 CC = gcc
367 [[<lang = fortran-2008>]]
368 [[[environment]]]
369 FC = gfortran
370 __WORKFLOW__
371 run_ok "${TEST_NAME_BASE}-19" cylc validate --debug .
372 cylc graph --reference . >'19.graph'
373 cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/19.graph.ref" '19.graph'
374 # Note: This also demonstrates current badness of "cylc config"...
375 # Inconsistence between graph/runtime whitespace handling.
376 # Inconsistence between graph/runtime parameter expansion.
377 cylc config . >'19.cylc'
378 cmp_ok '19.cylc' <<'__FLOW_CONFIG__'
379 [task parameters]
380 lang = c++, fortran-2008
381 [[templates]]
382 lang = %(lang)s
383 [scheduling]
384 initial cycle point = 1
385 final cycle point = 1
386 cycling mode = integer
387 [[graph]]
388 R1 = <lang=c++> => <lang = fortran-2008>
389 [runtime]
390 [[root]]
391 [[c++]]
392 script = true
393 completion = succeeded
394 [[[environment]]]
395 CC = gcc
396 [[fortran-2008]]
397 script = true
398 completion = succeeded
399 [[[environment]]]
400 FC = gfortran
401 __FLOW_CONFIG__
402
403 exit