Skip to content

Added new test on loop #1965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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