Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[run-webkit-tests] Support user specifying variant directly #5149

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions Tools/Scripts/webkitpy/common/find_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,21 @@ def _normalized_find(filesystem, paths, skipped_directories, file_filter, direct
Glob patterns are ok.
"""

def sort_by_directory_key(files_list):
if not directory_sort_key:
return files_list[:]

return sorted(files_list, key=directory_sort_key)

paths_to_walk = itertools.chain(*(sort_by_directory_key(filesystem.glob(path)) for path in paths))

all_files = itertools.chain(*(sort_by_directory_key(filesystem.files_under(path, skipped_directories, file_filter)) for path in paths_to_walk))
sort_fn = (lambda lst: sorted(lst, key=directory_sort_key)) if directory_sort_key else (lambda lst: lst[:])

def sorted_paths_generator(path, function):
base_path, separator, variant = path.partition('?')
if not separator:
return sort_fn(function(base_path))
# This isn't perfect, you won't be able glob the variant parts of the test name,
# but this is ultimately a design flaw stemming from a layout test not being a file
result = ['{}{}{}'.format(part, separator, variant) for part in function(base_path)]
if result:
return sort_fn(result)
return sort_fn(function(path))

paths_to_walk = itertools.chain(*(sorted_paths_generator(path, filesystem.glob) for path in paths))
all_files = itertools.chain(*(sorted_paths_generator(
path, lambda p: filesystem.files_under(p, skipped_directories, file_filter),
) for path in paths_to_walk))
return all_files
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def _expand_variants(self, files):
if ".any." not in f:
expanded.append(f)
continue
f, variant_separator, passed_variant = f.partition('?')
opened_file = fs.open_text_file_for_reading(f)
try:
first_line = opened_file.readline()
Expand All @@ -164,7 +165,8 @@ def _expand_variants(self, files):
variants.append(variant)
if variants:
for variant in variants:
expanded.append(f + variant)
if not passed_variant or variant.startswith(variant_separator + passed_variant):
expanded.append(f + variant)
else:
expanded.append(f)
except UnicodeDecodeError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ def test_find_glob_c(self):
tests = [t.test_path for t in finder.find_tests_by_path(['failures/expected/i[m]age.html'])]
self.assertEqual(tests, ['failures/expected/image.html'])

def test_find_glob_query(self):
finder = self.finder
tests = [t.test_path for t in finder.find_tests_by_path(['failures/expected/image.html?variant'])]
self.assertEqual(tests, ['failures/expected/image.html?variant'])

def test_find_glob_mixed_file_type_sorted(self):
finder = self.finder
# this should expand the *, sort the result, then recurse;
Expand Down