utils: More aggressive output checking.

Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
This commit is contained in:
Tim 'mithro' Ansell 2019-01-30 16:58:53 +11:00
parent 73702cd660
commit 44117ebb0d
1 changed files with 8 additions and 5 deletions

View File

@ -48,6 +48,7 @@ sort sets (lists where the order doesn't matter).
"""
import os
import random
import re
import sys
@ -304,11 +305,13 @@ def sort_db(filename):
tosort.sort(key=cmp.cmp_key)
# Make sure the sort is stable
copy = tosort.copy()
copy.sort(key=cmp.cmp_key)
assert len(copy) == len(tosort)
for i in range(0, len(copy)):
assert copy[i] == tosort[i], "\n%r\n != \n%r\n" % (copy[i], tosort[i])
for i in range(0, 4):
copy = tosort.copy()
random.shuffle(copy)
copy.sort(key=cmp.cmp_key)
assert len(copy) == len(tosort)
for i in range(0, len(copy)):
assert copy[i] == tosort[i], "\n%r\n != \n%r\n" % (copy[i], tosort[i])
with open(filename, 'w') as f:
for _, l in tosort: