Provide better diffs for MP4 failures.
If the user has the GPAC MP4 tools installed, this will use that to provide a better, text-based diff of the MP4 files. This makes looking at test failures much better than just "binary files differ". Change-Id: Ifdca54c02226a9f0fe9ddcf9c6b28e960e568111
This commit is contained in:
parent
8913dbda85
commit
51fe84f9d5
|
@ -133,6 +133,15 @@ class DiffFilesPolicy(object):
|
||||||
|
|
||||||
output, error = self._GitDiff(expected_file, actual_file)
|
output, error = self._GitDiff(expected_file, actual_file)
|
||||||
|
|
||||||
|
# If this is an MP4 file, get a better looking diff.
|
||||||
|
if ((output or error) and
|
||||||
|
os.path.splitext(actual_file)[1] in {'.mp4', '.m4s'}):
|
||||||
|
new_output, new_error = self._Mp4Diff(
|
||||||
|
out_dir, expected_file, actual_file)
|
||||||
|
|
||||||
|
output = new_output or output
|
||||||
|
error = new_error or error
|
||||||
|
|
||||||
if output:
|
if output:
|
||||||
failure_messages += [output.decode('utf8')]
|
failure_messages += [output.decode('utf8')]
|
||||||
|
|
||||||
|
@ -160,6 +169,23 @@ class DiffFilesPolicy(object):
|
||||||
p = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
p = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||||
return p.communicate()
|
return p.communicate()
|
||||||
|
|
||||||
|
def _Mp4Diff(self, out_dir, file_a, file_b):
|
||||||
|
dump_a = os.path.join(out_dir, os.path.basename(file_a) + '.dump.expected')
|
||||||
|
dump_b = os.path.join(out_dir, os.path.basename(file_b) + '.dump.actual')
|
||||||
|
try:
|
||||||
|
cmd = ['mp4dump', '--verbosity', '2', file_a]
|
||||||
|
with open(dump_a, 'w') as f:
|
||||||
|
subprocess.check_call(cmd, stdout=f)
|
||||||
|
cmd = ['mp4dump', '--verbosity', '2', file_b]
|
||||||
|
with open(dump_b, 'w') as f:
|
||||||
|
subprocess.check_call(cmd, stdout=f)
|
||||||
|
except (OSError, subprocess.CalledProcessError):
|
||||||
|
# If the program isn't available or returns an error, just ignore it and
|
||||||
|
# use the normal diff.
|
||||||
|
return None, None
|
||||||
|
|
||||||
|
return self._GitDiff(dump_a, dump_b)
|
||||||
|
|
||||||
def _UpdateGold(self, out_dir, gold_dir):
|
def _UpdateGold(self, out_dir, gold_dir):
|
||||||
if os.path.exists(gold_dir):
|
if os.path.exists(gold_dir):
|
||||||
shutil.rmtree(gold_dir)
|
shutil.rmtree(gold_dir)
|
||||||
|
|
Loading…
Reference in New Issue