Skip to content

The agent that grows with you

test(scratch): os.utime follow_symlinks is POSIX-only — guard it so the worktree test can age its tree on Windows too

Sharpefd74c42e5437
diff --git a/tests/test_scratch_dir.py b/tests/test_scratch_dir.py
index d4cce2e7c5c..cae2076c80d 100644
--- a/tests/test_scratch_dir.py
+++ b/tests/test_scratch_dir.py
@@ -381,7 +381,11 @@ def test_prune_releases_git_worktree_registration_of_idle_entry(tmp_path):
ancient = time.time() - 30 * 3600
for dirpath, dirnames, filenames in os.walk(tree.parent):
for name in dirnames + filenames:
- os.utime(os.path.join(dirpath, name), (ancient, ancient), follow_symlinks=False)
+ try:
+ os.utime(os.path.join(dirpath, name), (ancient, ancient), follow_symlinks=False)
+ except NotImplementedError:
+ # Windows: os.utime has no follow_symlinks parameter.
+ os.utime(os.path.join(dirpath, name), (ancient, ancient))
os.utime(tree.parent, (ancient, ancient))
assert prune_scratch_dir(scratch) == 1
listing = subprocess.run(["git", "worktree", "list", "--porcelain"], cwd=repo, capture_output=True,