Skip to content

Commit 3a25d8a

Browse files
committed
add negative test for v1.0
1 parent b5364d4 commit 3a25d8a

File tree

5 files changed

+46
-8
lines changed

5 files changed

+46
-8
lines changed

cwltool/builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ def bind_input(self,
195195
discover_secondaryFiles, # type: bool
196196
lead_pos=None, # type: Optional[Union[int, List[int]]]
197197
tail_pos=None, # type: Optional[List[int]]
198-
cwl_version=None # type: Optional[Text]
199198
): # type: (...) -> List[MutableMapping[Text, Any]]
200199

201200
if tail_pos is None:
@@ -213,7 +212,8 @@ def bind_input(self,
213212
bp = list(aslist(lead_pos))
214213
if "position" in binding:
215214
position = binding["position"]
216-
if isinstance(position, str) and cwl_version != "v1.0":
215+
if isinstance(position, str): # no need to test the CWL Version
216+
# the schema for v1.0 only allow ints
217217
binding['position'] = self.do_eval(position, context=datum)
218218
bp.append(binding['position'])
219219
else:

cwltool/process.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -703,13 +703,9 @@ def inc(d): # type: (List[int]) -> None
703703
tmpdir,
704704
stagedir)
705705

706-
cwl_version = self.metadata.get(
707-
"http://commonwl.org/cwltool#original_cwlVersion", None)
708-
709706
bindings.extend(builder.bind_input(
710707
self.inputs_record_schema, job,
711-
discover_secondaryFiles=getdefault(runtime_context.toplevel, False),
712-
cwl_version=cwl_version))
708+
discover_secondaryFiles=getdefault(runtime_context.toplevel, False)))
713709

714710
if self.tool.get("baseCommand"):
715711
for index, command in enumerate(aslist(self.tool["baseCommand"])):
@@ -727,7 +723,9 @@ def inc(d): # type: (List[int]) -> None
727723
arg = copy.deepcopy(arg)
728724
if arg.get("position"):
729725
position = arg.get("position")
730-
if isinstance(position, str) and cwl_version != "v1.0":
726+
if isinstance(position, str): # no need to test the
727+
# CWLVersion as the v1.0
728+
# schema only allows ints
731729
position = builder.do_eval(position)
732730
if position is None:
733731
position = 0

tests/echo-position-expr-job.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
one: 1
2+
two: 2

tests/echo-position-expr.cwl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env cwl-runner
2+
3+
class: CommandLineTool
4+
cwlVersion: v1.0
5+
requirements:
6+
InlineJavascriptRequirement: {}
7+
inputs:
8+
one:
9+
type: int
10+
inputBinding:
11+
position: $(self)
12+
two:
13+
type: int
14+
inputBinding:
15+
valueFrom: sensation!
16+
position: ${return self+1;}
17+
arguments:
18+
- position: ${return 2;}
19+
valueFrom: singular
20+
- position: ${return null;}
21+
valueFrom: 🕺
22+
outputs:
23+
out:
24+
type: string
25+
outputBinding:
26+
glob: out.txt
27+
loadContents: true
28+
outputEval: $(self[0].contents)
29+
baseCommand: echo
30+
stdout: out.txt

tests/test_examples.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,3 +887,11 @@ def test_bad_basecommand_docker():
887887
["--debug", "--default-container", "debian", get_data(test_file)])
888888
assert "permanentFail" in stderr, stderr
889889
assert error_code == 1
890+
891+
def test_v1_0_position_expression():
892+
test_file = "tests/echo-position-expr.cwl"
893+
test_job = "tests/echo-position-expr-job.yml"
894+
error_code, stdout, stderr = get_main_output(
895+
[get_data(test_file), get_data(test_job)])
896+
assert "is not int" in stderr, stderr
897+
assert error_code == 1

0 commit comments

Comments
 (0)