Background & Motivation
During the state restoration phase (when --resume is used or when hydrating tests from a directory), wpt-gen currently only globs for *.html files in the tests_dir (html_files = list(tests_dir.glob('*.html')) in wptgen/engine.py). Web Platform Tests frequently utilize other file types, such as .js (e.g., .any.js tests) or .py (e.g., .headers or server-side scripts). Because the hydration logic explicitly filters for only .html files, these other critical test files are completely ignored and dropped from the workflow context when resuming, causing test loss.
Proposed Changes
wptgen/engine.py: Update the fallback state hydration logic (around line 137). Instead of specifically globbing for *.html, it should iterate over all files in the directory recursively (e.g., tests_dir.rglob('*')), filtering out directories.
- Add an explicit exclusion for known state/metadata files (e.g.,
generated_tests.json, .DS_Store) to prevent them from being accidentally loaded as test files.
- Update the variables and UI log message (currently
Hydrating {len(html_files)} tests...) to generically refer to files or test_files rather than html_files.
tests/test_engine.py: Add a unit test that simulates a state directory containing a mix of .html, .any.js, and .json files, verifying that the .js files are hydrated and the .json state files are ignored.
Acceptance Criteria
This issue description was drafted by Gemini
Background & Motivation
During the state restoration phase (when
--resumeis used or when hydrating tests from a directory),wpt-gencurrently only globs for*.htmlfiles in thetests_dir(html_files = list(tests_dir.glob('*.html'))inwptgen/engine.py). Web Platform Tests frequently utilize other file types, such as.js(e.g.,.any.jstests) or.py(e.g.,.headersor server-side scripts). Because the hydration logic explicitly filters for only.htmlfiles, these other critical test files are completely ignored and dropped from the workflow context when resuming, causing test loss.Proposed Changes
wptgen/engine.py: Update the fallback state hydration logic (around line 137). Instead of specifically globbing for*.html, it should iterate over all files in the directory recursively (e.g.,tests_dir.rglob('*')), filtering out directories.generated_tests.json,.DS_Store) to prevent them from being accidentally loaded as test files.Hydrating {len(html_files)} tests...) to generically refer tofilesortest_filesrather thanhtml_files.tests/test_engine.py: Add a unit test that simulates a state directory containing a mix of.html,.any.js, and.jsonfiles, verifying that the.jsfiles are hydrated and the.jsonstate files are ignored.Acceptance Criteria
wptgen/engine.pyis updated to include non-HTML WPT files (e.g.,.js,.py,.headers).generated_tests.json) are safely excluded during hydration.context.generated_tests.This issue description was drafted by Gemini