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

#[files] produces incorrect test names on Windows #287

Open
GermanCoding opened this issue Nov 26, 2024 · 0 comments
Open

#[files] produces incorrect test names on Windows #287

GermanCoding opened this issue Nov 26, 2024 · 0 comments

Comments

@GermanCoding
Copy link

GermanCoding commented Nov 26, 2024

Steps to reproduce

  1. cargo new reproducer && cd reproducer && cargo add --dev rstest
  2. main.rs
fn main() {
    println!("Hello, world!");
}

#[cfg(test)]
mod test {
	use rstest::rstest;
	use std::path::PathBuf;
	
	#[rstest]
	fn wrong_testname(#[files("src/main.rs")] _p: PathBuf) {}
}
  1. Run this test on Linux & Windows. Compare names of the generated test cases.

Expected output

cargo test

running 1 test
test test::wrong_testname::_p_1_src_main_rs ... ok

This is what happens when running on Linux.

Actual output

However, when running on Windows 11, this happens:

cargo test

running 1 test
test test::wrong_testname::_p_1__UP_D_Rust_projectsreproducersrcmain_rs ... ok

The test seems to use the full path up from the drive's root, not from the crate's base directory. It is also missing some _ in place of path separators.

@GermanCoding GermanCoding changed the title #[files] produces invalid test names on Windows #[files] produces incorrect test names on Windows Nov 26, 2024
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

No branches or pull requests

1 participant