Skip to content

Commit 4f74d9b

Browse files
committed
Auto merge of #8469 - ehuss:long-filename-windows, r=alexcrichton
Disable long_file_names test if not supported on Windows. This test will fail on Windows if Cargo's target directory is over 80 characters long (as it is in rust's CI).
2 parents 729e567 + 35758d2 commit 4f74d9b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/testsuite/package.rs

+26
Original file line numberDiff line numberDiff line change
@@ -1857,6 +1857,32 @@ fn long_file_names() {
18571857
"012345678901234567890123456789012345678901234567890123456789",
18581858
"012345678901234567890123456789012345678901234567890123456789"
18591859
);
1860+
if cfg!(windows) {
1861+
// Long paths on Windows require a special registry entry that is
1862+
// disabled by default (even on Windows 10).
1863+
// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
1864+
// If the directory where Cargo runs happens to be more than 80 characters
1865+
// long, then it will bump into this limit.
1866+
//
1867+
// First create a directory to account for various paths Cargo will
1868+
// be using in the target directory (such as "target/package/foo-0.1.0").
1869+
let test_path = paths::root().join("test-dir-probe-long-path-support");
1870+
test_path.mkdir_p();
1871+
let test_path = test_path.join(long_name);
1872+
if let Err(e) = File::create(&test_path) {
1873+
use std::io::Write;
1874+
writeln!(
1875+
std::io::stderr(),
1876+
"\nSkipping long_file_names test, this OS or filesystem does not \
1877+
appear to support long file paths: {:?}\n{:?}",
1878+
e,
1879+
test_path
1880+
)
1881+
.unwrap();
1882+
return;
1883+
}
1884+
}
1885+
18601886
let p = project()
18611887
.file(
18621888
"Cargo.toml",

0 commit comments

Comments
 (0)