Changeset 283037 in webkit
- Timestamp:
- Sep 24, 2021, 5:58:41 AM (4 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r283035 r283037 1 2021-09-24 Sam Sneddon <gsnedders@apple.com> 2 3 LayoutTestFinder should return tests in order 4 https://bugs.webkit.org/show_bug.cgi?id=230684 5 6 Reviewed by Jonathan Bedard. 7 8 It has always been intended that LayoutTestFinder return tests in a deterministic order; 9 however, a bug in find_files means that directories found by glob aren't sorted, and hence 10 running run-webkit-tests with no arguments ends up running the top-level directories in a 11 non-deterministic order. 12 13 * Scripts/webkitpy/common/find_files.py: 14 (_normalized_find): 15 (_normalized_find.sort_by_directory_key): 16 * Scripts/webkitpy/common/find_files_unittest.py: 17 (TestWinNormalize.assert_filesystem_normalizes): 18 (TestWinNormalize.test_win): 19 (TestFindFiles): 20 (TestFindFiles.test_directory_sort_key): 21 (TestFindFiles.test_directory_sort_key_with_paths): 22 1 23 2021-09-24 Youenn Fablet <youenn@apple.com> 2 24 -
trunk/Tools/Scripts/webkitpy/common/find_files.py
r136545 r283037 74 74 """ 75 75 76 paths_to_walk = itertools.chain(*(filesystem.glob(path) for path in paths)) 76 def sort_by_directory_key(files_list): 77 if not directory_sort_key: 78 return files_list[:] 77 79 78 def sort_by_directory_key(files_list): 79 if directory_sort_key: 80 files_list.sort(key=directory_sort_key) 81 return files_list 80 return sorted(files_list, key=directory_sort_key) 81 82 paths_to_walk = itertools.chain(*(sort_by_directory_key(filesystem.glob(path)) for path in paths)) 82 83 83 84 all_files = itertools.chain(*(sort_by_directory_key(filesystem.files_under(path, skipped_directories, file_filter)) for path in paths_to_walk)) -
trunk/Tools/Scripts/webkitpy/common/find_files_unittest.py
r277853 r283037 27 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 28 29 import itertools 30 import random 29 31 import sys 30 32 import unittest … … 33 35 34 36 from webkitpy.common.system.filesystem import FileSystem 37 from webkitpy.common.system.filesystem_mock import MockFileSystem 35 38 36 39 … … 45 48 class TestWinNormalize(unittest.TestCase): 46 49 def assert_filesystem_normalizes(self, filesystem): 47 self.assertEqual(find_files._normalize(filesystem, "c:\\foo", 48 ['fast/html', 'fast/canvas/*', 'compositing/foo.html']), 49 ['c:\\foo\\fast\\html', 'c:\\foo\\fast\\canvas\\*', 'c:\\foo\\compositing\\foo.html']) 50 self.assertEqual( 51 find_files._normalize( 52 filesystem, 53 "c:\\foo", 54 ['fast/html', 'fast/canvas/*', 'compositing/foo.html'], 55 ), 56 [ 57 'c:\\foo\\fast\\html', 58 'c:\\foo\\fast\\canvas\\*', 59 'c:\\foo\\compositing\\foo.html', 60 ], 61 ) 50 62 51 63 def test_mocked_win(self): … … 61 73 return 62 74 self.assert_filesystem_normalizes(FileSystem()) 75 76 77 class TestFindFiles(unittest.TestCase): 78 def test_directory_sort_key(self): 79 filenames = [chr(o) for o in range(ord("a"), ord("z") + 1)] 80 fs = MockFileSystem( 81 files={c: "" for c in random.sample(filenames, len(filenames))} 82 ) 83 self.assertEqual( 84 list(find_files.find(fs, "", directory_sort_key=lambda x: x)), 85 sorted(filenames), 86 ) 87 88 def test_directory_sort_key_with_paths(self): 89 filenames = ["/".join(i) for i in itertools.product("abcde", "12345")] 90 fs = MockFileSystem( 91 files={c: "" for c in random.sample(filenames, len(filenames))} 92 ) 93 94 test_subset = random.sample("abcde", 3) 95 self.assertEqual( 96 list( 97 find_files.find( 98 fs, 99 "", 100 paths=[i + "/*" for i in test_subset], 101 directory_sort_key=lambda x: x, 102 ) 103 ), 104 ["/".join(i) for i in itertools.product(test_subset, "12345")], 105 )
Note:
See TracChangeset
for help on using the changeset viewer.