Skip to content
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
34 changes: 34 additions & 0 deletions tests/loop/opt-var-loop.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env cwl-runner
cwlVersion: v1.2
class: Workflow
$namespaces:
cwltool: "http://commonwl.org/cwltool#"
requirements:
InlineJavascriptRequirement: {}

inputs:
i1: 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 + 1};}
in:
i1: i1
out: [o1]
requirements:
cwltool:Loop:
loopWhen: $(inputs.i1 < 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 @@ -235,6 +235,19 @@ def test_scatter_inside_loop() -> None:
assert json.loads(stream.getvalue()) == expected


def test_loop_opt_variable() -> None:
"""Test a loop case with two variables but one is optional."""
stream = StringIO()
params = [
"--enable-ext",
get_data("tests/loop/opt-var-loop.cwl"),
get_data("tests/loop/single-var-loop-job.yml"),
]
main(params, stdout=stream)
expected = {"o1": 10}
assert json.loads(stream.getvalue()) == expected


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