diff options
| author | Yonggang Luo <luoyonggang@gmail.com> | 2020-10-08 22:26:31 +0000 |
|---|---|---|
| committer | Yonggang Luo <luoyonggang@gmail.com> | 2021-02-17 17:54:04 +0000 |
| commit | fa23ddf6e6932b0caa6ee14bd479264398a3a2a7 (patch) | |
| tree | 8a6836facce8391bf03150f7634d7649c5b8cd5d /library/std/src/sys/windows/process | |
| parent | ee88f46bb5e27c4d9f30326e69ff2298dcbeecb1 (diff) | |
| download | rust-fa23ddf6e6932b0caa6ee14bd479264398a3a2a7.tar.gz rust-fa23ddf6e6932b0caa6ee14bd479264398a3a2a7.zip | |
Expose force_quotes on Windows.
Quotes the arg and not quotes the arg have different effect on Windows when the program called are msys2/cygwin program. Refer to https://github.com/msys2/MSYS2-packages/issues/2176 Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Diffstat (limited to 'library/std/src/sys/windows/process')
| -rw-r--r-- | library/std/src/sys/windows/process/tests.rs | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/library/std/src/sys/windows/process/tests.rs b/library/std/src/sys/windows/process/tests.rs index 81627ad139b..8830ae049c6 100644 --- a/library/std/src/sys/windows/process/tests.rs +++ b/library/std/src/sys/windows/process/tests.rs @@ -3,29 +3,41 @@ use crate::ffi::{OsStr, OsString}; #[test] fn test_make_command_line() { - fn test_wrapper(prog: &str, args: &[&str]) -> String { + fn test_wrapper(prog: &str, args: &[&str], force_quotes: bool) -> String { let command_line = &make_command_line( OsStr::new(prog), &args.iter().map(|a| OsString::from(a)).collect::<Vec<OsString>>(), + force_quotes, ) .unwrap(); String::from_utf16(command_line).unwrap() } - assert_eq!(test_wrapper("prog", &["aaa", "bbb", "ccc"]), "\"prog\" aaa bbb ccc"); + assert_eq!(test_wrapper("prog", &["aaa", "bbb", "ccc"], false), "\"prog\" aaa bbb ccc"); assert_eq!( - test_wrapper("C:\\Program Files\\blah\\blah.exe", &["aaa"]), + test_wrapper("C:\\Program Files\\blah\\blah.exe", &["aaa"], false), "\"C:\\Program Files\\blah\\blah.exe\" aaa" ); assert_eq!( - test_wrapper("C:\\Program Files\\test", &["aa\"bb"]), + test_wrapper("C:\\Program Files\\blah\\blah.exe", &["aaa", "v*"], false), + "\"C:\\Program Files\\blah\\blah.exe\" aaa v*" + ); + assert_eq!( + test_wrapper("C:\\Program Files\\blah\\blah.exe", &["aaa", "v*"], true), + "\"C:\\Program Files\\blah\\blah.exe\" \"aaa\" \"v*\"" + ); + assert_eq!( + test_wrapper("C:\\Program Files\\test", &["aa\"bb"], false), "\"C:\\Program Files\\test\" aa\\\"bb" ); - assert_eq!(test_wrapper("echo", &["a b c"]), "\"echo\" \"a b c\""); - assert_eq!(test_wrapper("echo", &["\" \\\" \\", "\\"]), "\"echo\" \"\\\" \\\\\\\" \\\\\" \\"); + assert_eq!(test_wrapper("echo", &["a b c"], false), "\"echo\" \"a b c\""); + assert_eq!( + test_wrapper("echo", &["\" \\\" \\", "\\"], false), + "\"echo\" \"\\\" \\\\\\\" \\\\\" \\" + ); assert_eq!( - test_wrapper("\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}", &[]), + test_wrapper("\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}", &[], false), "\"\u{03c0}\u{042f}\u{97f3}\u{00e6}\u{221e}\"" ); } |
