Skip to content

Commit 7c7ae24

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

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Tests related to CWL v1.2+ "when" expressions and conditional handling."""
2+
3+
import json
4+
import re
5+
6+
from .util import get_data, get_main_output
7+
8+
9+
def test_conditional_step_no_inputs() -> None:
10+
"""Confirm fix for bug that populated `self` object for `when` expressions."""
11+
err_code, stdout, stderr = get_main_output(
12+
[
13+
get_data("tests/wf/conditional_step_no_inputs.cwl"),
14+
]
15+
)
16+
result = json.loads(stdout)["required"]
17+
stderr = re.sub(r"\s\s+", " ", stderr)
18+
assert err_code == 0, stderr
19+
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)