From 44117ebb0dd7675c41db0e1aa000491082e41518 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 30 Jan 2019 16:58:53 +1100 Subject: [PATCH] utils: More aggressive output checking. Signed-off-by: Tim 'mithro' Ansell --- utils/sort_db.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/utils/sort_db.py b/utils/sort_db.py index 09580ea2..ba4fc562 100755 --- a/utils/sort_db.py +++ b/utils/sort_db.py @@ -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: