Skip to content

Commit 739b376

Browse files
authored
Fix scandeps with File object inside a seperately declared Directory object (#732)
* When scandeps merges a real directory with a synthetic directory literal, real directory takes precedence. * Add test for scandeps.
1 parent a150dfd commit 739b376

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

cwltool/process.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,8 +804,11 @@ def mergedirs(listing):
804804
for e in listing:
805805
if e["basename"] not in ents:
806806
ents[e["basename"]] = e
807-
elif e["class"] == "Directory" and e.get("listing"):
808-
ents[e["basename"]].setdefault("listing", []).extend(e["listing"])
807+
elif e["class"] == "Directory":
808+
if e.get("listing"):
809+
ents[e["basename"]].setdefault("listing", []).extend(e["listing"])
810+
if ents[e["basename"]]["location"].startswith("_:"):
811+
ents[e["basename"]]["location"] = e["location"]
809812
for e in six.itervalues(ents):
810813
if e["class"] == "Directory" and "listing" in e:
811814
e["listing"] = mergedirs(e["listing"])

tests/test_examples.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
import subprocess
55
from os import path
66
import sys
7+
import json
78
import logging
89

9-
from io import StringIO
10+
from io import StringIO, BytesIO
1011

1112
from cwltool.errors import WorkflowException
1213

@@ -296,6 +297,14 @@ def loadref(base, p):
296297
"location": "file:///example/bar.cwl"
297298
}], sc)
298299

300+
def test_trick_scandeps(self):
301+
if sys.version_info[0] < 3:
302+
stream = BytesIO()
303+
else:
304+
stream = StringIO()
305+
main(["--print-deps", "--debug", get_data("tests/wf/trick_defaults.cwl")], stdout=stream)
306+
self.assertNotEquals(json.loads(stream.getvalue())["secondaryFiles"][0]["location"][:2], "_:")
307+
299308

300309
class TestDedup(unittest.TestCase):
301310
def test_dedup(self):

tests/wf/trick_defaults.cwl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class: CommandLineTool
2+
cwlVersion: v1.0
3+
inputs:
4+
inp1:
5+
type: File
6+
default:
7+
class: File
8+
location: indir1/hello.txt
9+
inp2:
10+
type: Directory
11+
default:
12+
class: Directory
13+
location: indir1
14+
outputs: []
15+
baseCommand: true

0 commit comments

Comments
 (0)