rust-analyzer / expect-test

Minimalistic snapshot testing for Rust.
Apache License 2.0
248 stars 22 forks source link

platform-agnostics expect_file! macro? #29

Closed mheiber closed 2 years ago

mheiber commented 2 years ago

afact, the expect_file! macro only works with hard-code "/" paths.

Is this the case? If so, would you accept a diff for providing a platform-agnostic API?

bjorn3 commented 2 years ago

It looks like it passes the path to PathBuf::from which on windows accepts both \ and / as path separator just like windows itself. What is the exact problem you have?

mheiber commented 2 years ago

It looks like it passes the path to PathBuf::from which on windows accepts both \ and / as path separator just like windows itself. What is the exact problem you have?

Thanks, this resolves my issue.

I didn't know whether Pathbuf::from on Windows worked with / and StackOverflow didn't seem to know either: https://stackoverflow.com/questions/70993253/are-forward-slashes-in-pathbuffromdir1-dir2-dir3-cross-platform-ok?noredirect=1#comment125520070_70993253. Thanks for teaching me both expect-test and the standard library!