Permalink
Browse files

Fix XML diffing in the context of shed_diff.

  • Loading branch information...
jmchilton committed Nov 18, 2015
1 parent f3394e7 commit 83e227a7188988e65d9d965646070b49352b5cbe
Showing with 22 additions and 8 deletions.
  1. +5 −4 planemo/shed/__init__.py
  2. +3 −2 planemo/shed/diff.py
  3. +2 −1 planemo/xml/diff.py
  4. +12 −1 tests/test_shed_diff.py
@@ -338,18 +338,19 @@ def _diff_in(ctx, working, realized_repository, **kwds):

output = kwds.get("output", None)
raw = kwds.get("raw", False)
is_diff = 0
xml_diff = 0
if not raw:
if output:
with open(output, "w") as f:
is_diff = diff_and_remove(working, label_a, label_b, f)
xml_diff = diff_and_remove(working, label_a, label_b, f)
else:
is_diff = diff_and_remove(working, label_a, label_b, sys.stdout)
xml_diff = diff_and_remove(working, label_a, label_b, sys.stdout)

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


@@ -17,8 +17,9 @@ def diff_and_remove(working, label_a, label_b, f):
if filename in special:
a = os.path.join(dirpath, filename)
b = os.path.join(working, label_b, os.path.relpath(a, os.path.join(working, label_a)))
if os.path.exists(a) and os.path.exists(b):
deps_diff &= _shed_diff(a, b, f)
files_exist = os.path.exists(a) and os.path.exists(b)
if files_exist:
deps_diff |= _shed_diff(a, b, f)
os.remove(a)
os.remove(b)
return deps_diff
@@ -1,6 +1,7 @@

def diff(x1, x2, reporter=None):
return_val = 0 if xml_compare(x1, x2, reporter) else 1
compare = xml_compare(x1, x2, reporter)
return_val = 0 if compare else 1
return return_val


@@ -80,7 +80,18 @@ def test_shed_diff_raw(self):
diff_command.extend(self._shed_args(read_only=True))
self._check_exit_code(diff_command, exit_code=0)

def test_shed_diff_xml(self):
def test_shed_diff_xml_no_diff(self):
with self._isolate_repo("package_1"):
upload_command = [
"shed_upload", "--force_repository_creation",
]
upload_command.extend(self._shed_args())
self._check_exit_code(upload_command)
diff_command = ["shed_diff"]
diff_command.extend(self._shed_args(read_only=True))
self._check_exit_code(diff_command, exit_code=0)

def test_shed_diff_xml_diff(self):
with self._isolate_repo("package_1") as f:
upload_command = [
"shed_upload", "--force_repository_creation",

0 comments on commit 83e227a

Please sign in to comment.