Skip to content

Commit 83e227a

Browse files
committed
Fix XML diffing in the context of shed_diff.
1 parent f3394e7 commit 83e227a

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

planemo/shed/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,18 +338,19 @@ def _diff_in(ctx, working, realized_repository, **kwds):
338338

339339
output = kwds.get("output", None)
340340
raw = kwds.get("raw", False)
341-
is_diff = 0
341+
xml_diff = 0
342342
if not raw:
343343
if output:
344344
with open(output, "w") as f:
345-
is_diff = diff_and_remove(working, label_a, label_b, f)
345+
xml_diff = diff_and_remove(working, label_a, label_b, f)
346346
else:
347-
is_diff = diff_and_remove(working, label_a, label_b, sys.stdout)
347+
xml_diff = diff_and_remove(working, label_a, label_b, sys.stdout)
348348

349349
cmd = 'cd "%s"; diff -r %s %s' % (working, label_a, label_b)
350350
if output:
351351
cmd += " >> '%s'" % output
352-
exit = shell(cmd) or is_diff
352+
raw_diff = shell(cmd)
353+
exit = raw_diff or xml_diff
353354
return exit
354355

355356

planemo/shed/diff.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ def diff_and_remove(working, label_a, label_b, f):
1717
if filename in special:
1818
a = os.path.join(dirpath, filename)
1919
b = os.path.join(working, label_b, os.path.relpath(a, os.path.join(working, label_a)))
20-
if os.path.exists(a) and os.path.exists(b):
21-
deps_diff &= _shed_diff(a, b, f)
20+
files_exist = os.path.exists(a) and os.path.exists(b)
21+
if files_exist:
22+
deps_diff |= _shed_diff(a, b, f)
2223
os.remove(a)
2324
os.remove(b)
2425
return deps_diff

planemo/xml/diff.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
def diff(x1, x2, reporter=None):
3-
return_val = 0 if xml_compare(x1, x2, reporter) else 1
3+
compare = xml_compare(x1, x2, reporter)
4+
return_val = 0 if compare else 1
45
return return_val
56

67

tests/test_shed_diff.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,18 @@ def test_shed_diff_raw(self):
8080
diff_command.extend(self._shed_args(read_only=True))
8181
self._check_exit_code(diff_command, exit_code=0)
8282

83-
def test_shed_diff_xml(self):
83+
def test_shed_diff_xml_no_diff(self):
84+
with self._isolate_repo("package_1"):
85+
upload_command = [
86+
"shed_upload", "--force_repository_creation",
87+
]
88+
upload_command.extend(self._shed_args())
89+
self._check_exit_code(upload_command)
90+
diff_command = ["shed_diff"]
91+
diff_command.extend(self._shed_args(read_only=True))
92+
self._check_exit_code(diff_command, exit_code=0)
93+
94+
def test_shed_diff_xml_diff(self):
8495
with self._isolate_repo("package_1") as f:
8596
upload_command = [
8697
"shed_upload", "--force_repository_creation",

0 commit comments

Comments
 (0)