Skip to content

Fix state hydration to support non-HTML Web Platform Tests (e.g., .js, .py) #331

@DanielRyanSmith

Description

@DanielRyanSmith

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

  • State hydration logic in wptgen/engine.py is updated to include non-HTML WPT files (e.g., .js, .py, .headers).
  • Known metadata files (e.g., generated_tests.json) are safely excluded during hydration.
  • Resuming a session successfully loads generated JavaScript or Python test files back into context.generated_tests.
  • Unit tests are updated to verify hydration of diverse file types.

This issue description was drafted by Gemini

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions