aboutsummaryrefslogtreecommitdiff
path: root/src/integration/config_file
diff options
context:
space:
mode:
authorJJ Liebig <jonathan.liebig@gmail.com>2026-09-17 22:43:35 +0200
committerGitHub <noreply@github.com>2026-09-17 22:43:35 +0200
commit14351f121f6fc8c84b7c6c6eda78ad210e93cfcb (patch)
treeab2773993ac4f012e8dc52f757a7109b3af8b4d5 /src/integration/config_file
parent101ccc20d3c6483a38ed9e0a1239b2ab908b1704 (diff)
test: skip windows symlink tests without symlink privilege (#4311)
Windows refuses file symlinks with ERROR_PRIVILEGE_NOT_HELD (1314) unless the test process is elevated or Developer Mode is enabled, which broke non-admin local runs. Share a helper that reports the missing privilege so the two symlink tests skip only the symlink-dependent assertions.
Diffstat (limited to 'src/integration/config_file')
-rw-r--r--src/integration/config_file/tests.rs18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/integration/config_file/tests.rs b/src/integration/config_file/tests.rs
index 916edc67..687767ee 100644
--- a/src/integration/config_file/tests.rs
+++ b/src/integration/config_file/tests.rs
@@ -1,4 +1,5 @@
use super::*;
+use crate::integration::test_support::symlink_file;
struct Directory(PathBuf);
@@ -103,15 +104,6 @@ fn hard_links_are_rejected_before_staging_and_rechecked_before_commit() {
assert_eq!(fs::read_dir(&dir.0).unwrap().count(), 2);
}
-#[cfg(unix)]
-fn symlink(target: &Path, link: &Path) {
- std::os::unix::fs::symlink(target, link).unwrap();
-}
-#[cfg(windows)]
-fn symlink(target: &Path, link: &Path) {
- std::os::windows::fs::symlink_file(target, link).unwrap();
-}
-
#[test]
fn symlink_chains_and_dangling_targets_preserve_links() {
let dir = Directory::new();
@@ -120,10 +112,12 @@ fn symlink_chains_and_dangling_targets_preserve_links() {
let target = other.join("preferences");
let intermediate = other.join("link");
let entry = dir.0.join("config");
- symlink(&target, &intermediate);
+ if !symlink_file(&target, &intermediate) {
+ return;
+ }
// A Windows reparse target needs native separators, unlike ordinary Win32 paths.
let relative_target = Path::new("other").join("link");
- symlink(&relative_target, &entry);
+ assert!(symlink_file(&relative_target, &entry));
let original_intermediate = fs::read_link(&intermediate).unwrap();
assert_eq!(
fs::metadata(&entry).unwrap_err().kind(),
@@ -142,7 +136,7 @@ fn symlink_chains_and_dangling_targets_preserve_links() {
assert_eq!(fs::read_link(&entry).unwrap(), relative_target);
let cycle = dir.0.join("cycle");
- symlink(Path::new("cycle"), &cycle);
+ assert!(symlink_file(Path::new("cycle"), &cycle));
assert!(write_config(&cycle, b"must not replace the link").is_err());
assert_eq!(fs::read_link(&cycle).unwrap(), Path::new("cycle"));
}