Skip to content

Commit 6bb7b89

Browse files
LanderOttomr-c
authored andcommitted
Added new loop test
1 parent 71360db commit 6bb7b89

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

tests/loop/opt-var-loop.cwl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
9+
inputs:
10+
i1: int
11+
outputs:
12+
o1:
13+
type: int
14+
outputSource: subworkflow/o1
15+
steps:
16+
subworkflow:
17+
run:
18+
class: ExpressionTool
19+
inputs:
20+
i1: int
21+
i2: int?
22+
outputs:
23+
o1: int
24+
expression: >
25+
${return {'o1': inputs.i1 + 1};}
26+
in:
27+
i1: i1
28+
out: [o1]
29+
requirements:
30+
cwltool:Loop:
31+
loopWhen: $(inputs.i1 < 10)
32+
loop:
33+
i1: o1
34+
outputMethod: last

tests/test_loop.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,19 @@ def test_scatter_inside_loop() -> None:
235235
assert json.loads(stream.getvalue()) == expected
236236

237237

238+
def test_loop_opt_variable() -> None:
239+
"""Test a loop case with two variables but one is optional."""
240+
stream = StringIO()
241+
params = [
242+
"--enable-ext",
243+
get_data("tests/loop/opt-var-loop.cwl"),
244+
get_data("tests/loop/single-var-loop-job.yml"),
245+
]
246+
main(params, stdout=stream)
247+
expected = {"o1": 10}
248+
assert json.loads(stream.getvalue()) == expected
249+
250+
238251
def test_nested_loops() -> None:
239252
"""Test a workflow with two nested loops."""
240253
stream = StringIO()

0 commit comments

Comments
 (0)