fix(tools): read test metadata as UTF-8 with path-aware decode errors - #589
Merged
Merged
Conversation
Signed-off-by: Visio Vanitas <visiovanitas@atdove.dev>
Member
|
LGTM thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Explicitly read Wave source files as UTF-8 in
parse_test_metadataand catch decoding errors (UnicodeDecodeError) alongsideOSError, wrapping them inValueErrorwith the case display path (or source path when omitted).Motivation
Fixes #584.
Previously,
parse_test_metadataintools/test_contracts.pyinvokedPath.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
test_utf8_metadata_read_with_non_ascii_commentsverifying UTF-8 non-ASCII comments parse cleanly.test_utf8_metadata_read_independent_of_ascii_host_localeexercising metadata discovery under simulated ASCII host locale (LC_ALL=C,PYTHONUTF8=0).test_invalid_utf8_bytes_reports_display_path_in_value_errorchecking that malformed UTF-8 wraps intoValueErrorwith display path (and fallback source path) and preserves theUnicodeDecodeErrorcause.python3 -m py_compile tools/test_contracts.py tools/test_test_contracts.py.python3 -m unittest tools.test_case_manifest tools.test_test_contracts tools.test_process_tree.Checklist
Signed-off-byline.std/.