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

Conversation

JonWBedard
Copy link
Member

@JonWBedard JonWBedard commented Oct 7, 2022

f8b4d27

[run-webkit-tests] Support user specifying variant directly
https://bugs.webkit.org/show_bug.cgi?id=246228
rdar://100907445

Reviewed by Elliott Williams.

* Tools/Scripts/webkitpy/common/find_files.py:
(_normalized_find): Consider variants of a single test file.
(_normalized_find.sorted_paths_generator):
* Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy.py:
(LayoutTestFinder._expand_variants): Handle specific variant as argument.
* Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy_unittest.py:
(LayoutTestFinderTests.test_find_glob_query):

Canonical link: https://commits.webkit.org/255305@main

eb0d3f4

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios   πŸ›  mac   πŸ›  wpe   πŸ›  πŸ§ͺ win
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim   πŸ›  mac-debug   πŸ›  gtk   πŸ›  wincairo
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2 βœ… πŸ›  mac-AS-debug   πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ webkitpy   πŸ§ͺ api-ios   πŸ§ͺ api-mac   πŸ§ͺ api-gtk
  πŸ›  tv   πŸ§ͺ mac-wk1
βœ… πŸ›  tv-sim   πŸ§ͺ mac-wk2
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch   πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  watch-sim   πŸ§ͺ mac-wk2-stress

@JonWBedard JonWBedard self-assigned this Oct 7, 2022
@JonWBedard JonWBedard added Other Tools / Tests Tools in the Tools directory, build issues, test infrastructure, and bugs in test cases labels Oct 7, 2022
Copy link
Contributor

@emw-apple emw-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable. I tried refactoring a bit to make it easier for me to follow. If you're in a hurry, no need to take these suggestions.

Comment on lines 94 to 92
paths_to_walk = itertools.chain(*(sort_by_directory_key(_filter_test_variant(path, filesystem.glob)) for path in paths))
all_files = itertools.chain(*(sort_by_directory_key(
_filter_test_variant(path, lambda p: filesystem.files_under(p, skipped_directories, file_filter))
) for path in paths_to_walk))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested refactor:

def sorted_paths_generator(fs_selector):
    for test_selector in paths_to_walk:
        path, separator, variant = test_selector.partition('?')
        matching_tests = (matching_path + separator + variant for matching_path in fs_selector(path))
        if directory_sort_key:
            yield from sorted(matching_tests, key=directory_sort_key)
        else:
            yield from matching_tests

paths_to_walk = sorted_paths_generator(filesystem.glob)
all_files = sorted_paths_generator(lambda p: filesystem.files_under(p, skipped_directories, file_filter))

This would replace _filter_test_variant and the local sort_by_directory_key function altogether. Using str.partition instead of str.split removes a bunch of the conditional logic.

Comment on lines 172 to 169
if not passed_variant or variant.startswith(passed_variant):
expanded.append(f + variant)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the above suggestion:

Suggested change
if not passed_variant or variant.startswith(passed_variant):
expanded.append(f + variant)
if not passed_variant or variant.startswith(variant_separator + passed_variant):
expanded.append(f + variant)

Comment on lines 151 to 155
split = f.split('?')
passed_variant = None
if len(split) == 2:
f = split[0]
passed_variant = '?{}'.format(split[1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
split = f.split('?')
passed_variant = None
if len(split) == 2:
f = split[0]
passed_variant = '?{}'.format(split[1])
f, variant_separator, passed_variant = f.partition('?')

@JonWBedard JonWBedard force-pushed the eng/run-webkit-tests-Support-user-specifying-variant-directly branch from ff2ff7e to eb0d3f4 Compare October 8, 2022 00:21
@JonWBedard JonWBedard added the merge-queue Applied to send a pull request to merge-queue label Oct 8, 2022
https://bugs.webkit.org/show_bug.cgi?id=246228
rdar://100907445

Reviewed by Elliott Williams.

* Tools/Scripts/webkitpy/common/find_files.py:
(_normalized_find): Consider variants of a single test file.
(_normalized_find.sorted_paths_generator):
* Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy.py:
(LayoutTestFinder._expand_variants): Handle specific variant as argument.
* Tools/Scripts/webkitpy/layout_tests/controllers/layout_test_finder_legacy_unittest.py:
(LayoutTestFinderTests.test_find_glob_query):

Canonical link: https://commits.webkit.org/255305@main
@webkit-early-warning-system webkit-early-warning-system force-pushed the eng/run-webkit-tests-Support-user-specifying-variant-directly branch from eb0d3f4 to f8b4d27 Compare October 8, 2022 01:27
@webkit-commit-queue
Copy link
Collaborator

Committed 255305@main (f8b4d27): https://commits.webkit.org/255305@main

Reviewed commits have been landed. Closing PR #5149 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit f8b4d27 into WebKit:main Oct 8, 2022
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Oct 8, 2022
@JonWBedard JonWBedard deleted the eng/run-webkit-tests-Support-user-specifying-variant-directly branch October 11, 2022 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tools / Tests Tools in the Tools directory, build issues, test infrastructure, and bugs in test cases
Projects
None yet
4 participants