6 #[cfg_attr(any(target_os = "emscripten", target_env = "sgx"), ignore)]
7 fn test_self_exe_path() {
8 let path = current_exe();
10 let path = path.unwrap();
12 // Hard to test this function
13 assert!(path.is_absolute());
18 assert!((!Path::new("test-path").is_absolute()));
20 #[cfg(not(target_env = "sgx"))]
21 current_dir().unwrap();
26 fn split_paths_windows() {
27 use crate::path::PathBuf;
29 fn check_parse(unparsed: &str, parsed: &[&str]) -> bool {
30 split_paths(unparsed).collect::<Vec<_>>()
31 == parsed.iter().map(|s| PathBuf::from(*s)).collect::<Vec<_>>()
34 assert!(check_parse("", &mut [""]));
35 assert!(check_parse(r#""""#, &mut [""]));
36 assert!(check_parse(";;", &mut ["", "", ""]));
37 assert!(check_parse(r"c:\", &mut [r"c:\"]));
38 assert!(check_parse(r"c:\;", &mut [r"c:\", ""]));
39 assert!(check_parse(r"c:\;c:\Program Files\", &mut [r"c:\", r"c:\Program Files\"]));
40 assert!(check_parse(r#"c:\;c:\"foo"\"#, &mut [r"c:\", r"c:\foo\"]));
41 assert!(check_parse(r#"c:\;c:\"foo;bar"\;c:\baz"#, &mut [r"c:\", r"c:\foo;bar\", r"c:\baz"]));
46 fn split_paths_unix() {
47 use crate::path::PathBuf;
49 fn check_parse(unparsed: &str, parsed: &[&str]) -> bool {
50 split_paths(unparsed).collect::<Vec<_>>()
51 == parsed.iter().map(|s| PathBuf::from(*s)).collect::<Vec<_>>()
54 assert!(check_parse("", &mut [""]));
55 assert!(check_parse("::", &mut ["", "", ""]));
56 assert!(check_parse("/", &mut ["/"]));
57 assert!(check_parse("/:", &mut ["/", ""]));
58 assert!(check_parse("/:/usr/local", &mut ["/", "/usr/local"]));
63 fn join_paths_unix() {
64 use crate::ffi::OsStr;
66 fn test_eq(input: &[&str], output: &str) -> bool {
67 &*join_paths(input.iter().cloned()).unwrap() == OsStr::new(output)
70 assert!(test_eq(&[], ""));
71 assert!(test_eq(&["/bin", "/usr/bin", "/usr/local/bin"], "/bin:/usr/bin:/usr/local/bin"));
72 assert!(test_eq(&["", "/bin", "", "", "/usr/bin", ""], ":/bin:::/usr/bin:"));
73 assert!(join_paths(["/te:st"].iter().cloned()).is_err());
78 fn join_paths_windows() {
79 use crate::ffi::OsStr;
81 fn test_eq(input: &[&str], output: &str) -> bool {
82 &*join_paths(input.iter().cloned()).unwrap() == OsStr::new(output)
85 assert!(test_eq(&[], ""));
86 assert!(test_eq(&[r"c:\windows", r"c:\"], r"c:\windows;c:\"));
87 assert!(test_eq(&["", r"c:\windows", "", "", r"c:\", ""], r";c:\windows;;;c:\;"));
88 assert!(test_eq(&[r"c:\te;st", r"c:\"], r#""c:\te;st";c:\"#));
89 assert!(join_paths([r#"c:\te"st"#].iter().cloned()).is_err());
95 format!("Args {{ inner: {:?} }}", args().collect::<Vec<_>>()),
96 format!("{:?}", args())
99 format!("ArgsOs {{ inner: {:?} }}", args_os().collect::<Vec<_>>()),
100 format!("{:?}", args_os())