Skip to content

Commit

Permalink
add test for scatter in loop (#1965)
Browse files Browse the repository at this point in the history
  • Loading branch information
LanderOtto authored Jan 12, 2024
1 parent 1eb83d1 commit ec1e1c8
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/loop/scatter-inside-loop.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env cwl-runner
cwlVersion: v1.2
class: Workflow
$namespaces:
cwltool: "http://commonwl.org/cwltool#"
requirements:
InlineJavascriptRequirement: {}
ScatterFeatureRequirement: {}
SubworkflowFeatureRequirement: {}
inputs:
i1: int[]
i2: int
outputs:
o1:
type: int[]
outputSource: scatter/o1
steps:
scatter:
run:
class: Workflow
inputs:
i1: int[]
i2: int
outputs:
o1:
type: int[]
outputSource: subworkflow/o1
steps:
subworkflow:
run:
class: ExpressionTool
inputs:
i1: int
i2: int
outputs:
o1: int
expression: >
${return {'o1': inputs.i1 + inputs.i2};}
in:
i1: i1
i2: i2
out: [o1]
scatter: i1
in:
i1: i1
i2: i2
out: [o1]
requirements:
cwltool:Loop:
loopWhen: $(inputs.i1[0] < 10)
loop:
i1: o1
outputMethod: last
13 changes: 13 additions & 0 deletions tests/test_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,19 @@ def test_loop_inside_scatter() -> None:
assert json.loads(stream.getvalue()) == expected


def test_scatter_inside_loop() -> None:
"""Test a loop workflow with inside a scatter step."""
stream = StringIO()
params = [
"--enable-ext",
get_data("tests/loop/scatter-inside-loop.cwl"),
get_data("tests/loop/loop-inside-scatter-job.yml"),
]
main(params, stdout=stream)
expected = {"o1": [10, 11, 12, 13, 14]}
assert json.loads(stream.getvalue()) == expected


def test_nested_loops() -> None:
"""Test a workflow with two nested loops."""
stream = StringIO()
Expand Down

0 comments on commit ec1e1c8

Please sign in to comment.