Skip to content

fix(tools): read test metadata as UTF-8 with path-aware decode errors - #589

Merged
LunaStev merged 1 commit into
wavefnd:masterfrom
Visio-Vanitas:fix-584-utf8-metadata
Sep 11, 2026
Merged

LunaStev merged 1 commit into
wavefnd:masterfrom
Visio-Vanitas:fix-584-utf8-metadata

Conversation

@Visio-Vanitas

Copy link
Copy Markdown
Contributor

Summary

Explicitly read Wave source files as UTF-8 in parse_test_metadata and catch decoding errors (UnicodeDecodeError) alongside OSError, wrapping them in ValueError with the case display path (or source path when omitted).

Motivation

Fixes #584.
Previously, parse_test_metadata in tools/test_contracts.py invoked Path.read_text() without specifying an encoding. Under an ASCII host locale, non-ASCII comments in UTF-8 Wave sources caused metadata discovery failures. Furthermore, decoding errors escaped the display path wrapper, resulting in error messages without case context.

Target and compatibility impact

None. This only affects Python test metadata parsing across platforms and locales.

Validation

  • Added unit test test_utf8_metadata_read_with_non_ascii_comments verifying UTF-8 non-ASCII comments parse cleanly.
  • Added unit test test_utf8_metadata_read_independent_of_ascii_host_locale exercising metadata discovery under simulated ASCII host locale (LC_ALL=C, PYTHONUTF8=0).
  • Added unit test test_invalid_utf8_bytes_reports_display_path_in_value_error checking that malformed UTF-8 wraps into ValueError with display path (and fallback source path) and preserves the UnicodeDecodeError cause.
  • Verified python3 -m py_compile tools/test_contracts.py tools/test_test_contracts.py.
  • Verified all unit tests pass with python3 -m unittest tools.test_case_manifest tools.test_test_contracts tools.test_process_tree.

Checklist

  • Commits include a DCO Signed-off-by line.
  • Tests cover new behavior or the PR explains why no test is needed.
  • User-facing changes include documentation or diagnostics updates.
  • The change preserves the license boundary between the compiler and std/.

Signed-off-by: Visio Vanitas <visiovanitas@atdove.dev>
@LunaStev

Copy link
Copy Markdown
Member

LGTM thanks

@LunaStev
LunaStev merged commit f411d2a into wavefnd:master Sep 11, 2026
24 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Read Wave test metadata as UTF-8 independently of the host locale

2 participants