Skip to content

Commit 11dd5ec

Browse files
committed
expr refactor: improve test coverage
1 parent 3f4684d commit 11dd5ec

8 files changed

+374
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env cwl-runner
2+
cwlVersion: v1.0
3+
class: Workflow
4+
inputs:
5+
inp:
6+
type:
7+
type: array
8+
items:
9+
type: record
10+
name: instr
11+
fields:
12+
- name: instr
13+
type: string
14+
outputs:
15+
out:
16+
type:
17+
type: array
18+
items: string
19+
outputSource: step1/echo_out
20+
21+
requirements:
22+
- class: ScatterFeatureRequirement
23+
- class: StepInputExpressionRequirement
24+
25+
steps:
26+
step1:
27+
in:
28+
echo_unused: inp
29+
echo_in:
30+
valueFrom: $(inputs.echo_unused.instr)
31+
first:
32+
source: inp
33+
valueFrom: "$(self[0].instr)"
34+
out: [echo_out]
35+
scatter: echo_unused
36+
run:
37+
class: CommandLineTool
38+
hints:
39+
ResourceRequirement:
40+
ramMin: 8
41+
inputs:
42+
first:
43+
type: string
44+
inputBinding:
45+
position: 1
46+
echo_in:
47+
type: string
48+
inputBinding:
49+
position: 2
50+
echo_unused: Any
51+
outputs:
52+
echo_out:
53+
type: string
54+
outputBinding:
55+
glob: "step1_out"
56+
loadContents: true
57+
outputEval: $(self[0].contents)
58+
baseCommand: "echo"
59+
arguments:
60+
- "-n"
61+
- "foo"
62+
stdout: "step1_out"

testdata/step-valuefrom2-wf_v10.cwl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env cwl-runner
2+
class: Workflow
3+
cwlVersion: v1.0
4+
requirements:
5+
- class: StepInputExpressionRequirement
6+
- class: InlineJavascriptRequirement
7+
- class: MultipleInputFeatureRequirement
8+
9+
inputs:
10+
a: int
11+
b: int
12+
13+
outputs:
14+
val:
15+
type: string
16+
outputSource: step1/echo_out
17+
18+
steps:
19+
step1:
20+
run:
21+
id: echo
22+
class: CommandLineTool
23+
inputs:
24+
c:
25+
type: int
26+
inputBinding: {}
27+
outputs:
28+
echo_out:
29+
type: string
30+
outputBinding:
31+
glob: "step1_out"
32+
loadContents: true
33+
outputEval: $(self[0].contents)
34+
baseCommand: "echo"
35+
stdout: step1_out
36+
37+
in:
38+
c:
39+
source: [a, b]
40+
valueFrom: "$(self[0] + self[1])"
41+
out: [echo_out]

testdata/step-valuefrom2-wf_v11.cwl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env cwl-runner
2+
class: Workflow
3+
cwlVersion: v1.1
4+
requirements:
5+
- class: StepInputExpressionRequirement
6+
- class: InlineJavascriptRequirement
7+
- class: MultipleInputFeatureRequirement
8+
9+
inputs:
10+
a: int
11+
b: int
12+
13+
outputs:
14+
val:
15+
type: string
16+
outputSource: step1/echo_out
17+
18+
steps:
19+
step1:
20+
run:
21+
id: echo
22+
class: CommandLineTool
23+
inputs:
24+
c:
25+
type: int
26+
inputBinding: {}
27+
outputs:
28+
echo_out:
29+
type: string
30+
outputBinding:
31+
glob: "step1_out"
32+
loadContents: true
33+
outputEval: $(self[0].contents)
34+
baseCommand: "echo"
35+
stdout: step1_out
36+
37+
in:
38+
c:
39+
source: [a, b]
40+
valueFrom: "$(self[0] + self[1])"
41+
out: [echo_out]

testdata/step-valuefrom2-wf_v12.cwl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env cwl-runner
2+
class: Workflow
3+
cwlVersion: v1.2
4+
requirements:
5+
- class: StepInputExpressionRequirement
6+
- class: InlineJavascriptRequirement
7+
- class: MultipleInputFeatureRequirement
8+
9+
inputs:
10+
a: int
11+
b: int
12+
13+
outputs:
14+
val:
15+
type: string
16+
outputSource: step1/echo_out
17+
18+
steps:
19+
step1:
20+
run:
21+
id: echo
22+
class: CommandLineTool
23+
inputs:
24+
c:
25+
type: int
26+
inputBinding: {}
27+
outputs:
28+
echo_out:
29+
type: string
30+
outputBinding:
31+
glob: "step1_out"
32+
loadContents: true
33+
outputEval: $(self[0].contents)
34+
baseCommand: "echo"
35+
stdout: step1_out
36+
37+
in:
38+
c:
39+
source: [a, b]
40+
valueFrom: "$(self[0] + self[1])"
41+
out: [echo_out]

testdata/step-valuefrom3-wf_v10.cwl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env cwl-runner
2+
class: Workflow
3+
cwlVersion: v1.0
4+
requirements:
5+
- class: StepInputExpressionRequirement
6+
- class: InlineJavascriptRequirement
7+
8+
inputs:
9+
a: int
10+
b: int
11+
12+
outputs:
13+
val:
14+
type: string
15+
outputSource: step1/echo_out
16+
17+
steps:
18+
step1:
19+
run:
20+
id: echo
21+
class: CommandLineTool
22+
inputs:
23+
c:
24+
type: int
25+
inputBinding: {}
26+
outputs:
27+
echo_out:
28+
type: string
29+
outputBinding:
30+
glob: "step1_out"
31+
loadContents: true
32+
outputEval: $(self[0].contents)
33+
baseCommand: "echo"
34+
stdout: step1_out
35+
36+
in:
37+
a: a
38+
b: b
39+
c:
40+
valueFrom: "$(inputs.a + inputs.b)"
41+
out: [echo_out]

testdata/step-valuefrom3-wf_v11.cwl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env cwl-runner
2+
class: Workflow
3+
cwlVersion: v1.1
4+
requirements:
5+
- class: StepInputExpressionRequirement
6+
- class: InlineJavascriptRequirement
7+
8+
inputs:
9+
a: int
10+
b: int
11+
12+
outputs:
13+
val:
14+
type: string
15+
outputSource: step1/echo_out
16+
17+
steps:
18+
step1:
19+
run:
20+
id: echo
21+
class: CommandLineTool
22+
inputs:
23+
c:
24+
type: int
25+
inputBinding: {}
26+
outputs:
27+
echo_out:
28+
type: string
29+
outputBinding:
30+
glob: "step1_out"
31+
loadContents: true
32+
outputEval: $(self[0].contents)
33+
baseCommand: "echo"
34+
stdout: step1_out
35+
36+
in:
37+
a: a
38+
b: b
39+
c:
40+
valueFrom: "$(inputs.a + inputs.b)"
41+
out: [echo_out]

testdata/step-valuefrom3-wf_v12.cwl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env cwl-runner
2+
class: Workflow
3+
cwlVersion: v1.2
4+
requirements:
5+
- class: StepInputExpressionRequirement
6+
- class: InlineJavascriptRequirement
7+
8+
inputs:
9+
a: int
10+
b: int
11+
12+
outputs:
13+
val:
14+
type: string
15+
outputSource: step1/echo_out
16+
17+
steps:
18+
step1:
19+
run:
20+
id: echo
21+
class: CommandLineTool
22+
inputs:
23+
c:
24+
type: int
25+
inputBinding: {}
26+
outputs:
27+
echo_out:
28+
type: string
29+
outputBinding:
30+
glob: "step1_out"
31+
loadContents: true
32+
outputEval: $(self[0].contents)
33+
baseCommand: "echo"
34+
stdout: step1_out
35+
36+
in:
37+
a: a
38+
b: b
39+
c:
40+
valueFrom: "$(inputs.a + inputs.b)"
41+
out: [echo_out]

tests/test_etools_to_clt.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,72 @@ def test_v1_2_workflow_top_level_sf_expr_array() -> None:
146146
)
147147

148148

149+
def test_v1_0_step_valuefrom_expr_multisource() -> None:
150+
"""Convert a valueFrom expression that has multiple sources."""
151+
result, modified = traverse0(
152+
parser.load_document(str(HERE / "../testdata/step-valuefrom2-wf_v10.cwl")),
153+
False,
154+
False,
155+
False,
156+
False,
157+
)
158+
159+
160+
def test_v1_1_step_valuefrom_expr_multisource() -> None:
161+
"""Convert a valueFrom expression that has multiple sources."""
162+
result, modified = traverse1(
163+
parser1.load_document(str(HERE / "../testdata/step-valuefrom2-wf_v11.cwl")),
164+
False,
165+
False,
166+
False,
167+
False,
168+
)
169+
170+
171+
def test_v1_2_step_valuefrom_expr_multisource() -> None:
172+
"""Convert a valueFrom expression that has multiple sources."""
173+
result, modified = traverse2(
174+
parser2.load_document(str(HERE / "../testdata/step-valuefrom2-wf_v12.cwl")),
175+
False,
176+
False,
177+
False,
178+
False,
179+
)
180+
181+
182+
def test_v1_0_step_valuefrom_expr_sibling_inputs() -> None:
183+
"""Convert a valueFrom expression from a step input that has uninvolved sibling inputs."""
184+
result, modified = traverse0(
185+
parser.load_document(str(HERE / "../testdata/step-valuefrom3-wf_v10.cwl")),
186+
False,
187+
False,
188+
False,
189+
False,
190+
)
191+
192+
193+
def test_v1_1_step_valuefrom_expr_sibling_inputs() -> None:
194+
"""Convert a valueFrom expression from a step input that has uninvolved sibling inputs."""
195+
result, modified = traverse1(
196+
parser1.load_document(str(HERE / "../testdata/step-valuefrom3-wf_v11.cwl")),
197+
False,
198+
False,
199+
False,
200+
False,
201+
)
202+
203+
204+
def test_v1_2_step_valuefrom_expr_sibling_inputs() -> None:
205+
"""Convert a valueFrom expression from a step input that has uninvolved sibling inputs."""
206+
result, modified = traverse2(
207+
parser2.load_document(str(HERE / "../testdata/step-valuefrom3-wf_v12.cwl")),
208+
False,
209+
False,
210+
False,
211+
False,
212+
)
213+
214+
149215
@pytest.fixture(scope="session")
150216
def cwl_v1_0_dir(
151217
tmp_path_factory: TempPathFactory,

0 commit comments

Comments
 (0)