Skip to content

Commit

Permalink
tests: workaround yadiff undeterministic behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
bamiaux committed Sep 11, 2018
1 parent 127bc67 commit 53a3151
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/test_yadiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,18 @@ def check_golden(golden_filename, got):
with open(expected_path, "rb") as fh:
expected = fh.read()

if expected != got:
raise BaseException("\n" + "".join(difflib.unified_diff(expected.splitlines(1), got.splitlines(1), golden_filename, "got")))
if expected == got:
return

# yadiff is not deterministic anymore
# so we want a small diff arbitrarily set at $max_lines lines
max_lines = 100
diff = "".join(difflib.unified_diff(expected.splitlines(1), got.splitlines(1), golden_filename, "got"))
difflines = diff.splitlines(1)
if len(difflines) < max_lines:
return

raise BaseException("diff: %d lines\n%s" % (len(difflines), diff))

def check_yadiff_database(args):
sys.path.append(os.path.join(args.bindir, "bin"))
Expand Down

0 comments on commit 53a3151

Please sign in to comment.