Skip to content

test: skip symlink tests instead of erroring when the platform can't create symlinks - #2648

Open
rajarshidattapy wants to merge 1 commit into
Graphify-Labs:v8from
rajarshidattapy:fix/skip-symlink-tests-without-privilege
Open

test: skip symlink tests instead of erroring when the platform can't create symlinks#2648
rajarshidattapy wants to merge 1 commit into
Graphify-Labs:v8from
rajarshidattapy:fix/skip-symlink-tests-without-privilege

Conversation

@rajarshidattapy

Copy link
Copy Markdown
Contributor

Fixes #2642.

The bug

Creating a symlink on Windows needs an elevated process or Developer Mode. Fifteen tests call
Path.symlink_to() / os.symlink() unguarded, so on a default Windows developer machine they
raise OSError: [WinError 1314] A required privilege is not held by the client and are
reported as failures.

At 15 of 42 failures on a clean checkout, this was the single largest block of noise in the
suite — enough that a Windows run isn't usable as a signal.

Fix

The capability-probing fixture pair from the issue, in tests/conftest.py: a session-scoped
_can_symlink probe plus a requires_symlinks gate, taken as a parameter by the 15 tests.

Probed rather than inferred from sys.platform, as the issue specifies — an elevated shell or
Developer Mode can create symlinks on Windows, and those runs must keep the coverage.

Results

before:  42 failed, 4120 passed, 16 skipped
after:   27 failed, 4252 passed, 31 skipped

The failure-set diff is exact: the 15 converted are precisely the reported ones, and zero new
failures
.

Verifying the gate opens as well as closes

A guard that always skips would "fix" the count while silently deleting the coverage — the more
expensive failure of the two. Exercising the fixture functions directly:

probe on this machine -> False
  _can_symlink=True  -> runs the test
  _can_symlink=False -> SKIP (symlink creation unavailable on this machine ...)
probe leaked temp entries: none

Scope

There are 17 unguarded symlink call sites, not 15. The extra two are already skipif-decorated
for unrelated reasons and were left alone:

test existing skip reason
test_build_merge_hyperedges_and_prune.py::test_prune_matches_across_symlinked_root "POSIX symlink semantics"
test_watch.py::test_rebuild_code_incremental_rename_preserves_symlink_source_path "symlink setup differs on Windows"

Three further tests (test_cache.py, two in test_detect.py) already use the repo's existing
try/except + pytest.skip idiom. Left as-is rather than churn working code, though
requires_symlinks is the better pattern for anyone touching them later.

Design note

requires_symlinks is a parameter rather than a try/except wrapper around each call on purpose:
the guard stays visible in the signature, and an OSError raised by the code under test
stays a real failure instead of being swallowed into a skip. The probe creates one file symlink
— Windows gates file and directory symlinks behind the same SeCreateSymbolicLinkPrivilege, so
a separate directory probe would add nothing.

Test infrastructure only; no product code touched. #2478 remains the tracker for the genuine
junction/symlink scan-root defect.

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).


Graphify review — findings

This PR adds two new pytest fixtures to tests/conftest.py: a session-scoped _can_symlink that probes whether the machine can actually create symlinks, and a requires_symlinks fixture that skips a test when it can't. It then adds requires_symlinks as a parameter to the various existing tests across test_atomic_writes.py, test_detect.py, test_extract.py, and test_image_vision.py that create symlinks. The stated intent is to make symlink-dependent tests skip cleanly (e.g., on non-elevated Windows) rather than fail. The change is confined to test files and fixtures; no non-test code is touched.

No blocking issues surfaced.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 715 functions depend on the 715 functions this change touches.

Health — grade A; no new coupling hotspots.

Verification — 715 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 715 function(s) in the blast radius were not formally verified this run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

15 symlink tests error out instead of skipping on Windows without SeCreateSymbolicLinkPrivilege

1 participant