Skip to content

Commit fd6e054

Browse files
bogdang989Peter Amstutz
bogdang989
authored and
Peter Amstutz
committed
Allow creating empty files in initwd (#1118)
* Allow creating empty files in initwd * Add test for empty file in initwdr.
1 parent 0baf06d commit fd6e054

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

cwltool/command_line_tool.py

+1-1
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)

tests/test_iwdr.py

+11-1
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

+14
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: []

0 commit comments

Comments
 (0)