Skip to content

Commit ec1e1c8

Browse files
authored
add test for scatter in loop (#1965)
1 parent 1eb83d1 commit ec1e1c8

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

tests/loop/scatter-inside-loop.cwl

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env cwl-runner
2+
cwlVersion: v1.2
3+
class: Workflow
4+
$namespaces:
5+
cwltool: "http://commonwl.org/cwltool#"
6+
requirements:
7+
InlineJavascriptRequirement: {}
8+
ScatterFeatureRequirement: {}
9+
SubworkflowFeatureRequirement: {}
10+
inputs:
11+
i1: int[]
12+
i2: int
13+
outputs:
14+
o1:
15+
type: int[]
16+
outputSource: scatter/o1
17+
steps:
18+
scatter:
19+
run:
20+
class: Workflow
21+
inputs:
22+
i1: int[]
23+
i2: int
24+
outputs:
25+
o1:
26+
type: int[]
27+
outputSource: subworkflow/o1
28+
steps:
29+
subworkflow:
30+
run:
31+
class: ExpressionTool
32+
inputs:
33+
i1: int
34+
i2: int
35+
outputs:
36+
o1: int
37+
expression: >
38+
${return {'o1': inputs.i1 + inputs.i2};}
39+
in:
40+
i1: i1
41+
i2: i2
42+
out: [o1]
43+
scatter: i1
44+
in:
45+
i1: i1
46+
i2: i2
47+
out: [o1]
48+
requirements:
49+
cwltool:Loop:
50+
loopWhen: $(inputs.i1[0] < 10)
51+
loop:
52+
i1: o1
53+
outputMethod: last

tests/test_loop.py

+13
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,19 @@ def test_loop_inside_scatter() -> None:
221221
assert json.loads(stream.getvalue()) == expected
222222

223223

224+
def test_scatter_inside_loop() -> None:
225+
"""Test a loop workflow with inside a scatter step."""
226+
stream = StringIO()
227+
params = [
228+
"--enable-ext",
229+
get_data("tests/loop/scatter-inside-loop.cwl"),
230+
get_data("tests/loop/loop-inside-scatter-job.yml"),
231+
]
232+
main(params, stdout=stream)
233+
expected = {"o1": [10, 11, 12, 13, 14]}
234+
assert json.loads(stream.getvalue()) == expected
235+
236+
224237
def test_nested_loops() -> None:
225238
"""Test a workflow with two nested loops."""
226239
stream = StringIO()

0 commit comments

Comments
 (0)