Skip to content

Commit 3c02b51

Browse files
authoredMar 20, 2022
Rollup merge of #95114 - ChrisDenton:symlink-test, r=the8472
Skip a test if symlink creation is not possible If someone running tests on Windows does not have Developer Mode enabled then creating symlinks will fail which in turn would cause this test to fail. This can be a stumbling block for contributors.
2 parents 4767cce + 68c03cd commit 3c02b51

File tree

1 file changed

+9
-2
lines changed
  • library/std/src/sys/windows/process

1 file changed

+9
-2
lines changed
 

‎library/std/src/sys/windows/process/tests.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,15 @@ fn windows_exe_resolver() {
186186
let temp = tmpdir();
187187
let mut exe_path = temp.path().to_owned();
188188
exe_path.push("exists.exe");
189-
symlink("<DOES NOT EXIST>".as_ref(), &exe_path).unwrap();
190189

191190
// A broken symlink should still be resolved.
192-
assert!(resolve_exe(OsStr::new("exists.exe"), empty_paths, Some(temp.path().as_ref())).is_ok());
191+
// Skip this check if not in CI and creating symlinks isn't possible.
192+
let is_ci = env::var("CI").is_ok();
193+
let result = symlink("<DOES NOT EXIST>".as_ref(), &exe_path);
194+
if is_ci || result.is_ok() {
195+
result.unwrap();
196+
assert!(
197+
resolve_exe(OsStr::new("exists.exe"), empty_paths, Some(temp.path().as_ref())).is_ok()
198+
);
199+
}
193200
}

0 commit comments

Comments
 (0)
Please sign in to comment.