1 use super::make_command_line;
3 use crate::ffi::{OsStr, OsString};
4 use crate::process::Command;
7 fn test_make_command_line() {
8 fn test_wrapper(prog: &str, args: &[&str], force_quotes: bool) -> String {
9 let command_line = &make_command_line(
11 &args.iter().map(|a| OsString::from(a)).collect::<Vec<OsString>>(),
15 String::from_utf16(command_line).unwrap()
18 assert_eq!(test_wrapper("prog", &["aaa", "bbb", "ccc"], false), "\"prog\" aaa bbb ccc");
21 test_wrapper("C:\\Program Files\\blah\\blah.exe", &["aaa"], false),
22 "\"C:\\Program Files\\blah\\blah.exe\" aaa"
25 test_wrapper("C:\\Program Files\\blah\\blah.exe", &["aaa", "v*"], false),
26 "\"C:\\Program Files\\blah\\blah.exe\" aaa v*"
29 test_wrapper("C:\\Program Files\\blah\\blah.exe", &["aaa", "v*"], true),
30 "\"C:\\Program Files\\blah\\blah.exe\" \"aaa\" \"v*\""
33 test_wrapper("C:\\Program Files\\test", &["aa\"bb"], false),
34 "\"C:\\Program Files\\test\" aa\\\"bb"
36 assert_eq!(test_wrapper("echo", &["a b c"], false), "\"echo\" \"a b c\"");
38 test_wrapper("echo", &["\" \\\" \\", "\\"], false),
39 "\"echo\" \"\\\" \\\\\\\" \\\\\" \\"
42 test_wrapper("\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}", &[], false),
43 "\"\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}\""
47 // On Windows, environment args are case preserving but comparisons are case-insensitive.
50 fn windows_env_unicode_case() {
85 // Test that `cmd.env` matches `env::set_var` when setting two strings that
86 // may (or may not) be case-folded when compared.
87 for (a, b) in test_cases.iter() {
88 let mut cmd = Command::new("cmd");
94 for (key, value) in cmd.get_envs() {
97 value.map(|s| s.to_string_lossy().into_owned()),
98 "command environment mismatch: {} {}",