diff --git a/tests/tests/main.rs b/tests/tests/main.rs index cb69755..80f0121 100644 --- a/tests/tests/main.rs +++ b/tests/tests/main.rs @@ -70,16 +70,21 @@ fn init_twice() { assert!(project.fuzz_target_path("fuzz_target_1").is_file()); // Second init should fail. + #[cfg(not(target_family = "windows"))] + let expected_err = "File exists (os error 17)"; + #[cfg(target_family = "windows")] + let expected_err = "Cannot create a file when that file already exists. (os error 183)"; + project .cargo_fuzz() .arg("init") .assert() - .stderr(predicates::str::contains("File exists (os error 17)").and( - predicates::str::contains(format!( + .stderr( + predicates::str::contains(expected_err).and(predicates::str::contains(format!( "failed to create directory {}", project.fuzz_dir().display() - )), - )) + ))), + ) .failure(); } @@ -134,6 +139,12 @@ fn add_twice() { .assert() .success(); assert!(project.fuzz_target_path("new_fuzz_target").is_file()); + + #[cfg(not(target_family = "windows"))] + let expected_err = "File exists (os error 17)"; + #[cfg(target_family = "windows")] + let expected_err = "The file exists. (os error 80)"; + project .cargo_fuzz() .arg("add") @@ -141,7 +152,7 @@ fn add_twice() { .assert() .stderr( predicate::str::contains("could not add target") - .and(predicate::str::contains("File exists (os error 17)")), + .and(predicate::str::contains(expected_err)), ) .failure(); } diff --git a/tests/tests/project.rs b/tests/tests/project.rs index f9abbf7..53822c6 100644 --- a/tests/tests/project.rs +++ b/tests/tests/project.rs @@ -4,6 +4,7 @@ use std::io::Write; use std::path::{Path, PathBuf}; use std::process::Command; use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; +use toml; pub fn target_tests() -> PathBuf { let mut path = env::current_exe().unwrap(); @@ -107,12 +108,12 @@ impl ProjectBuilder { r#" [[bin]] name = "{name}" - path = "{path}" + path = {path} test = false doc = false "#, name = name, - path = path.display(), + path = toml::to_string(&path).unwrap(), ) .unwrap();