Rollup merge of #94650 - ChrisDenton:windows-absolute-fix, r=dtolnay

Relax tests for Windows dos device names

Windows 11 no longer turn paths ending with dos device names into device paths.

E.g. `C:\path\to\COM1.txt` used to get turned into `\\.\COM1`. Whereas now this path is left as is.

Note though that if the given path is an exact (case-insensitive) match for the string `COM1` then it'll still be converted to `\\.\COM1`.
This commit is contained in:
Dylan DPC 2022-03-19 14:50:24 +01:00 committed by GitHub
commit d1ef570a2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1739,11 +1739,11 @@ fn test_windows_absolute() {
let relative = r"a\b";
let mut expected = crate::env::current_dir().unwrap();
expected.push(relative);
assert_eq!(absolute(relative).unwrap(), expected);
assert_eq!(absolute(relative).unwrap().as_os_str(), expected.as_os_str());
macro_rules! unchanged(
($path:expr) => {
assert_eq!(absolute($path).unwrap(), Path::new($path));
assert_eq!(absolute($path).unwrap().as_os_str(), Path::new($path).as_os_str());
}
);
@ -1759,11 +1759,11 @@ fn test_windows_absolute() {
// Verbatim paths are always unchanged, no matter what.
unchanged!(r"\\?\path.\to/file..");
assert_eq!(absolute(r"C:\path..\to.\file.").unwrap(), Path::new(r"C:\path..\to\file"));
assert_eq!(absolute(r"C:\path\to\COM1").unwrap(), Path::new(r"\\.\COM1"));
assert_eq!(absolute(r"C:\path\to\COM1.txt").unwrap(), Path::new(r"\\.\COM1"));
assert_eq!(absolute(r"C:\path\to\COM1 .txt").unwrap(), Path::new(r"\\.\COM1"));
assert_eq!(absolute(r"C:\path\to\cOnOuT$").unwrap(), Path::new(r"\\.\cOnOuT$"));
assert_eq!(
absolute(r"C:\path..\to.\file.").unwrap().as_os_str(),
Path::new(r"C:\path..\to\file").as_os_str()
);
assert_eq!(absolute(r"COM1").unwrap().as_os_str(), Path::new(r"\\.\COM1").as_os_str());
}
#[bench]