🧪 Add unit tests for path_to_string_lossy utility#55
🧪 Add unit tests for path_to_string_lossy utility#55bashandbone wants to merge 6 commits intomainfrom
Conversation
- Added `test_path_to_string_lossy_valid` to verify standard UTF-8 path conversion. - Added `test_path_to_string_lossy_invalid` (Unix-only) to verify replacement character insertion for invalid UTF-8 paths. - Verified test logic with a standalone script using `rustc --test`. Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR adds unit test coverage for the path_to_string_lossy utility in src/utilities.rs, validating behavior for both UTF-8-clean paths and (Unix-only) paths containing invalid bytes.
Changes:
- Add a unit test verifying lossy conversion returns the same string for valid UTF-8 paths.
- Add a Unix-only unit test verifying invalid path bytes are converted with the Unicode replacement character.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fn test_path_to_string_lossy_valid() { | ||
| let path = std::path::Path::new("valid_utf8"); | ||
| assert_eq!(path_to_string_lossy(path), "valid_utf8"); | ||
| } |
There was a problem hiding this comment.
path_to_string_lossy() currently always prints the "non-UTF-8" warning via eprintln! even when the input path is valid UTF-8. This new test will therefore emit a misleading warning (and adds noise when running tests with --nocapture). Consider changing path_to_string_lossy to only warn when the conversion is actually lossy (e.g., when to_string_lossy() returns an owned Cow, or when path.to_str() is None).
There was a problem hiding this comment.
@copilot please address and correct this issue you identified
There was a problem hiding this comment.
I've addressed the issue by modifying path_to_string_lossy to only print a warning when an actual lossy conversion occurs. I've also added unit tests for both valid and invalid UTF-8 paths to ensure the behavior is correct and doesn't regress.
There was a problem hiding this comment.
Fixed in commit 4250cd4. path_to_string_lossy now checks path.to_str() first and returns early for valid UTF-8 paths without any warning. The warning is only emitted when to_str() returns None (i.e., the path truly contains non-UTF-8 bytes and the conversion is lossy).
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…tring_lossy - Modified `path_to_string_lossy` to only print a warning when non-UTF-8 characters are actually encountered. - Added `test_path_to_string_lossy_valid` to verify standard UTF-8 path conversion without warnings. - Added `test_path_to_string_lossy_invalid` (Unix-only) to verify replacement character insertion and warning for invalid UTF-8 paths. Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
Agent-Logs-Url: https://github.com/bashandbone/submod/sessions/a023ba1c-1244-47d8-b1b3-1bdae676b748 Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
Agent-Logs-Url: https://github.com/bashandbone/submod/sessions/a023ba1c-1244-47d8-b1b3-1bdae676b748 Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
🎯 What: The testing gap addressed for
path_to_string_lossyutility function.📊 Coverage: Added tests for both valid UTF-8 paths and invalid UTF-8 paths (verifying replacement character insertion).
✨ Result: Increased test coverage for path utility functions in
src/utilities.rs.PR created automatically by Jules for task 16782817780805708676 started by @bashandbone