Skip to content

fix: add Darwin platform support and fix Windows test failures#380

Merged
nicholas-fedor merged 1 commit intomainfrom
fix/cross-platform-test-support
Mar 4, 2026
Merged

fix: add Darwin platform support and fix Windows test failures#380
nicholas-fedor merged 1 commit intomainfrom
fix/cross-platform-test-support

Conversation

@nicholas-fedor
Copy link
Owner

@nicholas-fedor nicholas-fedor commented Mar 4, 2026

Add cross-platform support for Darwin (macOS) and fix Windows-specific test failures.

Problem

CI tests were failing on Darwin (macOS) and Windows platforms due to:

  • Missing Darwin implementation in the trash package (undefined: newTrasher)
  • Platform support checks explicitly excluding Darwin from buildinfo extraction
  • Windows test failures due to platform-specific path handling differences
  • Helper function generateUniqueName not accessible on Windows

Solution

  • Created Darwin-specific trash implementation following XDG specification
  • Extended platform support to include Darwin (macOS) alongside Linux and Windows
  • Refactored shared helper functions to be platform-agnostic
  • Fixed storage test to use universally invalid path (empty string)

Changes

  • internal/trash/trash_darwin.go - New file with macOS trash implementation
  • internal/trash/trash.go - Moved generateUniqueName() for cross-platform access
  • internal/trash/trash_linux.go - Removed duplicate generateUniqueName() function
  • internal/buildinfo/extractor.go - Added Darwin to isSupportedPlatform() and updated error message
  • internal/storage/storage_test.go - Fixed invalid path test to use empty string for consistent cross-platform behavior

Summary by CodeRabbit

Release Notes

  • New Features

    • Added macOS (Darwin) platform support with comprehensive trash management capabilities, including moving files to trash, restoring deleted items, and permanent removal.
  • Tests

    • Updated storage path validation test cases for improved error handling.

- Add trash_darwin.go with macOS XDG Trash implementation
- Update isSupportedPlatform() to include Darwin in buildinfo
- Move generateUniqueName() to common trash.go for cross-platform access
- Fix storage test to use empty string for invalid path validation
- Update error messages to reflect Darwin platform support
@nicholas-fedor nicholas-fedor enabled auto-merge (squash) March 4, 2026 15:15
@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 20d769ad-cc81-4671-baf7-85ee31621e2a

📥 Commits

Reviewing files that changed from the base of the PR and between 616cc59 and 902f824.

📒 Files selected for processing (5)
  • internal/buildinfo/extractor.go
  • internal/storage/storage_test.go
  • internal/trash/trash.go
  • internal/trash/trash_darwin.go
  • internal/trash/trash_linux.go

Walkthrough

This pull request adds Darwin/macOS platform support for file trash operations and updates platform detection. A reusable timestamp-based unique naming utility is extracted to a shared module, enabling its use in both Linux and Darwin implementations. A comprehensive Darwin-specific trash handler is introduced alongside platform support expansion in the buildinfo module.

Changes

Cohort / File(s) Summary
Platform Support
internal/buildinfo/extractor.go
Updated error message and platform detection to include Darwin alongside Linux and Windows support.
Trash Utilities
internal/trash/trash.go
Added shared generateUniqueName() helper function for creating unique trash entry names using integer timestamps.
Trash Implementation
internal/trash/trash_darwin.go
New Darwin-specific trash implementation supporting move, restore, list, delete, and metadata management with cross-device fallback and symlink preservation.
Trash Cleanup
internal/trash/trash_linux.go
Removed duplicate generateUniqueName() function in favor of shared implementation in trash.go.
Test Updates
internal/storage/storage_test.go
Modified TestNewBadgerStore to use empty string path for invalid-path test case instead of hard-to-create path.

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant Trash as Trash System
    participant FS as Filesystem
    participant Meta as Metadata (.trashinfo)
    
    rect rgba(100, 150, 200, 0.5)
    note over App,Meta: MoveToTrash Flow (Darwin)
    App->>Trash: MoveToTrash(filePath)
    Trash->>Trash: generateUniqueName(filename)
    Trash->>FS: Move file to trash directory
    alt Cross-device move fails
        Trash->>FS: Copy file to trash
        Trash->>FS: Delete original file
    end
    Trash->>Meta: Create .trashinfo metadata
    Trash-->>App: Success/Error
    end
    
    rect rgba(150, 200, 100, 0.5)
    note over App,Meta: Restore Flow (Darwin)
    App->>Trash: Restore(trashPath, originalPath)
    Trash->>Meta: Read .trashinfo metadata
    Trash->>FS: Check for collision at original location
    Trash->>FS: Create parent directories if needed
    Trash->>FS: Restore file to original location
    alt Cross-device restore fails
        Trash->>FS: Copy file from trash
        Trash->>FS: Delete from trash
    end
    Trash->>Meta: Remove .trashinfo metadata
    Trash-->>App: Success/Error
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/cross-platform-test-support

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nicholas-fedor nicholas-fedor merged commit 56c62e0 into main Mar 4, 2026
11 of 14 checks passed
@nicholas-fedor nicholas-fedor deleted the fix/cross-platform-test-support branch March 4, 2026 15:17
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.

1 participant