Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix glob! input_file on Windows #371

Merged
merged 2 commits into from Jun 16, 2023
Merged

Fix glob! input_file on Windows #371

merged 2 commits into from Jun 16, 2023

Conversation

smonicas
Copy link
Contributor

Fix #336
The issue is caused due to not canonicalize the stripped prefix when localizing the path.
For example in my environment i get "D:\\Rust\\insta" to strip from "\\\\?\\D:\\Rust\\insta\\tests\\inputs\\goodbye.txt" while when canonicalized becomes the correct prefix "\\\\?\\D:\\Rust\\insta".
I used unwrap with the assumption that if canonicalize fails the previous call to canonicalize would also fail and it doesn't arrive at the unwrap.

src/runtime.rs Outdated
@@ -315,7 +315,7 @@ impl<'a> SnapshotAssertionContext<'a> {
.canonicalize()
.ok()
.and_then(|s| {
s.strip_prefix(self.cargo_workspace.as_path())
s.strip_prefix(self.cargo_workspace.canonicalize().unwrap())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately canonicalize can fail quite commonly. Ideally the error here is swallowed.

@mitsuhiko mitsuhiko merged commit 1eab812 into mitsuhiko:master Jun 16, 2023
5 of 6 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.

glob! on Windows doesn't seem to include input_file
2 participants