Skip to content

Commit 62a9cdc

Browse files
committed
"when" expressions get an empty "self" variable
1 parent 073568f commit 62a9cdc

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

cwltool/workflow_job.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,6 @@ def valueFromFunc(
692692
None,
693693
None,
694694
{},
695-
context=cast(Optional[CWLObjectType], v),
696695
debug=runtimeContext.debug,
697696
js_console=runtimeContext.js_console,
698697
timeout=runtimeContext.eval_timeout,

tests/test_conditionals.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Tests related to CWL v1.2+ "when" expressions and conditional handling."""
2+
3+
import re
4+
5+
from .util import get_data, get_main_output
6+
7+
8+
def test_conditional_step_no_inputs() -> None:
9+
"""Confirm fix for bug that populated `self` object for `when` expressions."""
10+
err_code, _, stderr = get_main_output(
11+
[
12+
get_data("tests/wf/conditional_step_no_inputs.cwl"),
13+
]
14+
)
15+
result = json.loads(stdout)["required"]
16+
stderr = re.sub(r"\s\s+", " ", stderr)
17+
assert err_code == 0, stderr
18+
assert result is None
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env cwl-runner
2+
cwlVersion: v1.2
3+
class: Workflow
4+
5+
requirements:
6+
InlineJavascriptRequirement: {}
7+
8+
inputs: []
9+
10+
steps:
11+
step1:
12+
in: {}
13+
when: $(self !== null)
14+
run:
15+
class: ExpressionTool
16+
inputs: []
17+
requirements:
18+
InlineJavascriptRequirement: {}
19+
expression: |
20+
$({"result": "huzzah!"})
21+
outputs:
22+
result: string
23+
out: [ result ]
24+
25+
outputs:
26+
required:
27+
type: string
28+
outputSource: step1/result

0 commit comments

Comments
 (0)