Skip to content

Commit b899a5f

Browse files
author
Anton Khodak
authored
Merge pull request #653 from common-workflow-language/fix/concat-vf
Fix wrong evaluation of two concatenated expressions in valueFrom
2 parents 4c69907 + f71c336 commit b899a5f

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

cwltool/expression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def interpolate(scan, rootvars,
185185
e = evaluator(scan[w[0] + 1:w[1]], jslib, rootvars, fullJS=fullJS,
186186
timeout=timeout, force_docker_pull=force_docker_pull,
187187
debug=debug, js_console=js_console)
188-
if w[0] == 0 and w[1] == len(scan):
188+
if w[0] == 0 and w[1] == len(scan) and len(parts) <= 1:
189189
return e
190190
leaf = json.dumps(e, sort_keys=True)
191191
if leaf[0] == '"':

tests/test_js_sandbox.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
from __future__ import absolute_import
2+
23
import unittest
34

5+
from mock import Mock
6+
7+
import cwltool
8+
import cwltool.factory
49
# we should modify the subprocess imported from cwltool.sandboxjs
510
from cwltool.sandboxjs import (check_js_threshold_version,
6-
minimum_node_version_str, subprocess)
7-
from mock import Mock, patch
11+
subprocess)
12+
from tests.util import get_data
813

914

1015
class Javascript_Sanity_Checks(unittest.TestCase):
@@ -33,3 +38,11 @@ def test_node_version(self):
3338

3439
def test_is_javascript_installed(self):
3540
pass
41+
42+
43+
class TestValueFrom(unittest.TestCase):
44+
45+
def test_value_from_two_concatenated_expressions(self):
46+
f = cwltool.factory.Factory()
47+
echo = f.make(get_data("tests/wf/vf-concat.cwl"))
48+
self.assertEqual(echo(), {u"out": u"a sting\n"})

tests/wf/vf-concat.cwl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cwlVersion: v1.0
2+
class: CommandLineTool
3+
requirements:
4+
- class: InlineJavascriptRequirement
5+
6+
baseCommand: echo
7+
inputs:
8+
- id: parameter
9+
type: string?
10+
inputBinding:
11+
valueFrom: $("a ")$("sting")
12+
outputs:
13+
out:
14+
type: string
15+
outputBinding:
16+
glob: output.txt
17+
loadContents: true
18+
outputEval: $(self[0].contents)
19+
stdout: output.txt

0 commit comments

Comments
 (0)