Skip to content

Commit 229565c

Browse files
author
Peter Amstutz
committed
cwltest order-independent directory compare.
1 parent d2270a7 commit 229565c

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

cwltool/cwltest.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,30 @@ def compare(a, b): # type: (Any, Any) -> bool
3737
# ignore empty collections
3838
b = {k: v for k, v in b.iteritems()
3939
if not isinstance(v, (list, dict)) or len(v) > 0}
40+
elif a.get("class") == "Directory":
41+
if len(a["listing"]) != len(b["listing"]):
42+
return False
43+
for i in a["listing"]:
44+
found = False
45+
for j in b["listing"]:
46+
try:
47+
if compare(i, j):
48+
found = True
49+
break
50+
except:
51+
pass
52+
if not found:
53+
raise CompareFail(u"%s not in %s" % (json.dumps(i, indent=4, sort_keys=True), json.dumps(b, indent=4, sort_keys=True)))
4054

4155
a = {k: v for k, v in a.iteritems()
42-
if k not in ("path", "location")}
56+
if k not in ("path", "location", "listing")}
4357
b = {k: v for k, v in b.iteritems()
44-
if k not in ("path", "location")}
58+
if k not in ("path", "location", "listing")}
4559

4660
if len(a) != len(b):
4761
raise CompareFail(u"expected %s\ngot %s" % (json.dumps(a, indent=4, sort_keys=True), json.dumps(b, indent=4, sort_keys=True)))
4862
for c in a:
49-
if a.get("class") != "File" or c not in ("path", "location"):
63+
if a.get("class") != "File" or c not in ("path", "location", "listing"):
5064
if c not in b:
5165
raise CompareFail(u"%s not in %s" % (c, b))
5266
if not compare(a[c], b[c]):

0 commit comments

Comments
 (0)