Skip to content

Commit b02fcaf

Browse files
committed
Merge remote-tracking branch 'origin/master' into singularity23_fix
2 parents 309919e + fd6e054 commit b02fcaf

File tree

6 files changed

+60
-4
lines changed

6 files changed

+60
-4
lines changed

cwltool/command_line_tool.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def rm_pending_output_callback(output_callbacks, jobcachepending,
440440
else:
441441
et["entryname"] = None
442442
et["writable"] = t.get("writable", False)
443-
if et[u"entry"]:
443+
if et[u"entry"] is not None:
444444
ls.append(et)
445445
else:
446446
initwd_item = builder.do_eval(t)
@@ -797,7 +797,12 @@ def collect_output(self,
797797
adjustFileObjs(r, revmap)
798798

799799
if not r and optional:
800-
return None
800+
# Don't convert zero or empty string to None
801+
if r in [0, '']:
802+
return r
803+
# For [] or None, return None
804+
else:
805+
return None
801806

802807
if (not empty_and_optional and isinstance(schema["type"], MutableMapping)
803808
and schema["type"]["type"] == "record"):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
'ruamel.yaml >= 0.12.4, <= 0.15.77',
5858
'rdflib >= 4.2.2, < 4.3.0',
5959
'shellescape >= 3.4.1, < 3.5',
60-
'schema-salad >= 4.1, < 5',
60+
'schema-salad >= 4.2, < 5',
6161
'mypy-extensions',
6262
'six >= 1.9.0', # >= 1.9.0 required by prov
6363
'psutil',

tests/test_examples.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,3 +920,14 @@ def test_v1_0_position_expression():
920920
['--debug', get_data(test_file), get_data(test_job)])
921921
assert "is not int" in stderr, stderr
922922
assert error_code == 1
923+
924+
925+
@windows_needs_docker
926+
def test_optional_numeric_output_0():
927+
test_file = "tests/wf/optional-numerical-output-0.cwl"
928+
error_code, stdout, stderr = get_main_output(
929+
[get_data(test_file)])
930+
931+
assert "completed success" in stderr
932+
assert error_code == 0
933+
assert json.loads(stdout)['out'] == 0

tests/test_iwdr.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from cwltool.main import main
44
from cwltool import load_tool
55
from .util import (get_data, get_windows_safe_factory, windows_needs_docker,
6-
needs_docker, temp_dir, needs_singularity)
6+
needs_docker, temp_dir, needs_singularity, get_main_output)
77

88
@windows_needs_docker
99
def test_newline_in_entry():
@@ -14,6 +14,16 @@ def test_newline_in_entry():
1414
echo = factory.make(get_data("tests/wf/iwdr-entry.cwl"))
1515
assert echo(message="hello") == {"out": "CONFIGVAR=hello\n"}
1616

17+
18+
@needs_docker
19+
def test_empty_file_creation():
20+
"""
21+
test that empty file can be created in InitialWorkingDirectory
22+
"""
23+
err_code, _, _ = get_main_output([get_data("tests/wf/iwdr-empty.cwl")])
24+
assert err_code == 0
25+
26+
1727
@needs_docker
1828
def test_iwdr_permutations():
1929
saved_tempdir = tempfile.tempdir

tests/wf/iwdr-empty.cwl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env cwl-runner
2+
3+
class: CommandLineTool
4+
cwlVersion: v1.0
5+
baseCommand: ["cat", "empty_file"]
6+
7+
requirements:
8+
InitialWorkDirRequirement:
9+
listing:
10+
- entryname: empty_file
11+
entry: ""
12+
13+
inputs: []
14+
outputs: []
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cwlVersion: v1.0
2+
class: CommandLineTool
3+
baseCommand:
4+
- echo
5+
- "0"
6+
stdout: a.txt
7+
requirements:
8+
- class: InlineJavascriptRequirement
9+
inputs: []
10+
outputs:
11+
out:
12+
type: float?
13+
outputBinding:
14+
glob: "a.txt"
15+
loadContents: true
16+
outputEval: "${\n return parseFloat(self[0].contents);\n}"

0 commit comments

Comments
 (0)