Bug 1127882: Sort the unified files list before splitting into multiple files, r=nfroyd

--HG--
extra : rebase_source : da8309728d29ed3a51d11536f962cf9255fb6f4f
This commit is contained in:
Joshua Cranmer 2015-02-09 08:45:15 -06:00
parent 442f276a75
commit 97fb09553f
2 changed files with 12 additions and 0 deletions

View File

@ -683,5 +683,14 @@ class TestGroupUnifiedFiles(unittest.TestCase):
for i, amount in enumerate(expected_amounts):
check_mapping(i, amount)
def test_unsorted_files(self):
unsorted_files = ['a%d.cpp' % i for i in range(11)]
sorted_files = sorted(unsorted_files)
mapping = list(group_unified_files(unsorted_files, 'Unified', 'cpp', 5))
self.assertEqual(mapping[0][1], sorted_files[0:5])
self.assertEqual(mapping[1][1], sorted_files[5:10])
self.assertEqual(mapping[2][1], sorted_files[10:])
if __name__ == '__main__':
main()

View File

@ -893,6 +893,9 @@ def group_unified_files(files, unified_prefix, unified_suffix,
files, and determining which original source files go in which unified
file."""
# Make sure the input list is sorted. If it's not, bad things could happen!
files = sorted(files)
# Our last returned list of source filenames may be short, and we
# don't want the fill value inserted by izip_longest to be an
# issue. So we do a little dance to filter it out ourselves.