test: make fs-safe symlink tests compatible with Windows#90271
test: make fs-safe symlink tests compatible with Windows#90271aniruddhaadak80 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Makes symlink-related fs-safe tests conditional on actual symlink capability (rather than OS-only checks), improving cross-platform reliability (notably on Windows where symlink creation may be restricted).
Changes:
- Add runtime probes to detect whether file and directory symlinks can be created.
- Replace
it.runIf(process.platform !== "win32")withit.skipIf(!canCreate*Symlinks)for symlink tests. - Use explicit symlink types for directory symlinks (
junctionon Windows,direlsewhere).
| const canCreateFileSymlinks = (() => { | ||
| const probeDir = fsSync.mkdtempSync(path.join(os.tmpdir(), "openclaw-fs-file-symlink-probe-")); | ||
| const targetFile = path.join(probeDir, "target.txt"); | ||
| const linkFile = path.join(probeDir, "link.txt"); | ||
| try { | ||
| fsSync.writeFileSync(targetFile, "target", "utf8"); | ||
| fsSync.symlinkSync(targetFile, linkFile, "file"); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } finally { | ||
| fsSync.rmSync(probeDir, { recursive: true, force: true }); | ||
| } | ||
| })(); |
| const canCreateDirectorySymlinks = (() => { | ||
| const probeDir = fsSync.mkdtempSync(path.join(os.tmpdir(), "openclaw-fs-dir-symlink-probe-")); | ||
| const targetDir = path.join(probeDir, "target"); | ||
| const linkDir = path.join(probeDir, "link"); | ||
| try { | ||
| fsSync.mkdirSync(targetDir); | ||
| fsSync.symlinkSync(targetDir, linkDir, process.platform === "win32" ? "junction" : "dir"); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } finally { | ||
| fsSync.rmSync(probeDir, { recursive: true, force: true }); | ||
| } | ||
| })(); |
|
Codex review: needs changes before merge. Reviewed July 5, 2026, 4:37 AM ET / 08:37 UTC. Summary PR surface: Tests +32. Total +32 across 1 file. Reproducibility: yes. at source level. Current main still hard-skips the affected fs-safe symlink tests on Windows, and the PR body includes Windows terminal output after the change. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Land the test-only portability change after guarding both probe cleanups to match the existing install-safe-path probe pattern and rerunning focused lint/test proof. Do we have a high-confidence way to reproduce the issue? Yes, at source level. Current main still hard-skips the affected fs-safe symlink tests on Windows, and the PR body includes Windows terminal output after the change. Is this the best way to solve the issue? Yes, with a small cleanup. Capability-gated symlink tests with Windows junctions are the narrow maintainable test-only fix, but the probe cleanup should be guarded before merge. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 53bd4dde6c00. Label changesLabel justifications:
Evidence reviewedPR surface: Tests +32. Total +32 across 1 file. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
ddee9ca to
4b26b1d
Compare
|
Rebased onto main. Ready for re-review. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
This pull request has been automatically marked as stale due to inactivity. |
Closes #90271
What Problem This Solves
The
fs-safesymlink-related tests previously hardcoded skips for Windows platforms (win32). This caused a loss of test coverage on Windows configurations where symlinking is actually supported (e.g. Developer Mode or elevated privileges).Why This Change Was Made
Instead of assuming
win32lacks symlink support, we dynamically probe for file and directory symlink capabilities viacanCreateFileSymlinksandcanCreateDirectorySymlinks. If the capability is present, the tests run, providing test coverage when possible. Additionally, it uses directoryjunctionon Windows for compatibility without Administrator privileges. Temporary directories are used for the probes to prevent test pollution.User Impact
No direct end-user impact. Improves test robustness and coverage for Windows contributors.
Evidence
The tests were run locally on a Windows host. The dynamic probing successfully skipped only the file symlink tests (due to host permissions) but passed the directory junction tests without dirtying the global state: