diff --git a/src/main.rs b/src/main.rs index 679cfc8..9f0307c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,8 +42,8 @@ struct Args { } fn get_file_list(dir_path: &str, wildcard: &str) -> Vec { - let pattern = format!("{}/{}", dir_path, wildcard); - let dir_entries: Vec> = glob(&pattern).unwrap().collect(); + let pattern = Path::new(dir_path).join(wildcard); + let dir_entries: Vec> = glob(&pattern.to_string_lossy()).unwrap().collect(); dir_entries .into_iter() .filter_map(|entry| entry.ok()) @@ -137,10 +137,10 @@ fn full_name_test() { #[test] fn file_list_test() { - const DIRECTORY: &str = "src"; - const WILDCARD: &str = "*.rs"; + const DIRECTORY: &str = "."; + const WILDCARD: &str = "*.toml"; - assert_eq!(get_file_list(DIRECTORY, WILDCARD), vec!["main.rs"]); + assert_eq!(get_file_list(DIRECTORY, WILDCARD), vec!["Cargo.toml"]); } #[test]