aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-05-12 13:09:03 +0200
committerDavid Robillard <d@drobilla.net>2018-05-27 18:23:15 +0200
commit9143f8ece49e902dda34a5c99ae721543bfa0d33 (patch)
tree851aaf121fc1b8c4ca1700ba366018b13f4ffb5b
parent9767db1b2d1dffc4847f162c857cfcb0ab3141bc (diff)
downloadserd-9143f8ece49e902dda34a5c99ae721543bfa0d33.tar.gz
serd-9143f8ece49e902dda34a5c99ae721543bfa0d33.tar.bz2
serd-9143f8ece49e902dda34a5c99ae721543bfa0d33.zip
Factor out test output diffing
-rw-r--r--wscript20
1 files changed, 12 insertions, 8 deletions
diff --git a/wscript b/wscript
index ea5d2ba7..88ee2e7b 100644
--- a/wscript
+++ b/wscript
@@ -267,9 +267,15 @@ def earl_assertion(test, passed, asserter):
passed_str,
datetime.datetime.now().replace(microsecond=0).isoformat())
-def check_output(out_filename, check_filename, subst_from='', subst_to=''):
+def show_diff(from_lines, to_lines, from_filename, to_filename):
import difflib
import sys
+
+ for line in difflib.unified_diff(
+ from_lines, to_lines, fromfile=from_filename, tofile=to_filename):
+ sys.stderr.write(line)
+
+def check_output(out_filename, check_filename, subst_from='', subst_to=''):
if not os.access(out_filename, os.F_OK):
Logs.pprint('RED', 'FAIL: output %s is missing' % out_filename)
elif not file_equals(check_filename, out_filename, subst_from, subst_to):
@@ -277,12 +283,10 @@ def check_output(out_filename, check_filename, subst_from='', subst_to=''):
check_filename))
with io.open(out_filename, encoding='utf-8') as out_file:
with io.open(check_filename, encoding='utf-8') as check_file:
- diff = difflib.unified_diff(check_file.readlines(),
- out_file.readlines(),
- fromfile=check_filename,
- tofile=out_filename)
- for line in diff:
- sys.stderr.write(line)
+ show_diff(check_file.readlines(),
+ out_file.readlines(),
+ check_filename,
+ out_filename)
else:
return True
@@ -290,7 +294,7 @@ def check_output(out_filename, check_filename, subst_from='', subst_to=''):
def test_thru(ctx, base, path, check_filename, flags, isyntax, osyntax,
options='', quiet=False):
- in_filename = os.path.join(ctx.path.abspath(), path);
+ in_filename = os.path.join(ctx.path.abspath(), path)
out_filename = path + '.thru'
command = ('serdi_static %s %s -i %s -o %s -p foo "%s" "%s" | '