()
| 339 | #[cfg(not(target_os = "windows"))] |
| 340 | #[test] |
| 341 | fn test_substitute_tilde() { |
| 342 | use std::{env, path::PathBuf}; |
| 343 | let original_home = home_dir(); |
| 344 | let test_home_path = if cfg!(windows) { |
| 345 | "C:\\Users\\user" |
| 346 | } else { |
| 347 | "/home/user" |
| 348 | }; |
| 349 | unsafe { |
| 350 | env::set_var( |
| 351 | if cfg!(windows) { "USERPROFILE" } else { "HOME" }, |
| 352 | test_home_path, |
| 353 | ); |
| 354 | } |
| 355 | let input = "~/Code/datafusion/benchmarks/data/tpch_sf1/part/part-0.parquet"; |
| 356 | let expected = PathBuf::from(test_home_path) |
| 357 | .join("Code") |
| 358 | .join("datafusion") |
| 359 | .join("benchmarks") |
| 360 | .join("data") |
| 361 | .join("tpch_sf1") |
| 362 | .join("part") |
| 363 | .join("part-0.parquet") |
| 364 | .to_string_lossy() |
| 365 | .to_string(); |
| 366 | let actual = substitute_tilde(input.to_string()); |
| 367 | assert_eq!(actual, expected); |
| 368 | unsafe { |
| 369 | match original_home { |
| 370 | Some(home_path) => env::set_var( |
| 371 | if cfg!(windows) { "USERPROFILE" } else { "HOME" }, |
| 372 | home_path.to_str().unwrap(), |
| 373 | ), |
| 374 | None => { |
| 375 | env::remove_var(if cfg!(windows) { "USERPROFILE" } else { "HOME" }) |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…