mach: fix logic to override paths for legacy layout (#34467)

wptrunner internally derives the path to the MANIFEST.json file from the
`metadata_path` passed via `test_paths`. The current logic overrides
only the `metadata_path`, leaving the manifest_path pointing at the
wrong (non-legacy) layout's MANIFEST.json.

In #34436 we observed that the recent WPT imports create a transient
`.cache` diretory that wptrunner logic uses for optimization. This has
not been observed until #34436 because a [recent bump in MANIFEST.json's
schema version][1] triggered the creation of the cache. Because of the
above issue with incorrect path and the fact that we *first* trigger
`mach update-wpt` for legacy layout during WPT import, the MANIFEST.json
of non-legacy layout gets incorrectly migrated during the invocation of
`update-wpt` for legacy layout but the cache is still created under
legacy-layout's path as it is not based on `manifest_path`. The
subsequent invocation of `mach update-wpt` for non-legacy finds the
MANIFEST.json already migrated so the `.cache` directory is not
constucted.

This change simply replaces the whole object using the wptrunner's
`TestRoot` class constructor so that all derived paths are calculated
correctly. We also add the `.cache` folders to gitignore as it seems
like they are expected to be created during such version migrations.

[1]: https://github.com/web-platform-tests/wpt/pull/49406

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
Mukilan Thiyagarajan 2024-12-04 18:08:58 +05:30 committed by GitHub
parent 9028c8cf67
commit c6d7c5785a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 9 deletions

1
.gitignore vendored
View file

@ -12,6 +12,7 @@
/python/_venv*
/python/tidy/servo_tidy.egg-info
/tests/wpt/sync
/tests/wpt/**/**/.cache/
/tests/dromaeo/dromaeo
*.pkl
*.pyc

View file

@ -49,15 +49,15 @@ def create_parser():
def update_args_for_legacy_layout(kwargs: dict):
kwargs["test_paths"]["/"].metadata_path = os.path.join(
WPT_PATH, "meta-legacy-layout"
)
kwargs["test_paths"]["/_mozilla/"].metadata_path = os.path.join(
WPT_PATH, "mozilla", "meta-legacy-layout"
)
kwargs["test_paths"]["/_webgl/"].metadata_path = os.path.join(
WPT_PATH, "webgl", "meta-legacy-layout"
)
def override_metadata_path(url_base, metadata_path):
test_root = kwargs["test_paths"][url_base]
kwargs["test_paths"][url_base] = wptrunner.wptcommandline.TestRoot(
test_root.tests_path,
os.path.join(WPT_PATH, *metadata_path)
)
override_metadata_path("/", ["meta-legacy-layout"])
override_metadata_path("/_mozilla/", ["mozilla", "meta-legacy-layout"])
override_metadata_path("/_webgl/", ["webgl", "meta-legacy-layout"])
def run_tests():

View file

@ -123,6 +123,13 @@ directories = [
"./target",
"./support/crown/target",
"./third_party",
# Cache files generated by wptrunner which fail the EOF newlines check.
"./tests/wpt/meta/.cache",
"./tests/wpt/meta-legacy-layout/.cache",
"./tests/wpt/mozilla/meta/.cache",
"./tests/wpt/mozilla/meta-legacy-layout/.cache",
"./tests/wpt/webgl/meta/.cache",
"./tests/wpt/webgl/meta-legacy-layout/.cache",
]
# Directories that are checked for correct file extension