Skip to content

Confirm symlinks are snaggled correctly#90

Merged
MusicalNinjaDad merged 7 commits into
mainfrom
symlink
Nov 3, 2025
Merged

Confirm symlinks are snaggled correctly#90
MusicalNinjaDad merged 7 commits into
mainfrom
symlink

Conversation

@MusicalNinjaDad

@MusicalNinjaDad MusicalNinjaDad commented Nov 3, 2025

Copy link
Copy Markdown
Owner

Closes #64

Summary by Sourcery

Add symlink handling tests and assertions to confirm that snaggle resolves and copies symlinked binaries correctly without leaving symlinks in the output.

New Features:

  • Add NoSymlinks assertion to verify absence of symlinks in output directories

Enhancements:

  • Extend TestDetails with InSubdir and Symlink flags and refactor directory test generation to filter based on recursion mode

Tests:

  • Introduce a symlinked binary test case with supporting test data and path constant
  • Invoke NoSymlinks assertion in snaggle_test to ensure symlinks are resolved
  • Remove obsolete subdir_contents helper from tests

@sourcery-ai

sourcery-ai Bot commented Nov 3, 2025

Copy link
Copy Markdown

Reviewer's Guide

Enable and verify correct handling of symlinked binaries by extending the test framework with subdir and symlink flags, updating test-case generation logic, adding a NoSymlinks assertion, and wiring in test data and assertions to confirm no symlinks remain after snaggling.

Sequence diagram for symlink handling in test case generation

sequenceDiagram
    participant T["testing.T"]
    participant TestCases
    participant Asserter
    participant FileSystem
    T->>TestCases: Run test with symlinked binary
    TestCases->>FileSystem: Prepare test directory with symlink
    TestCases->>Asserter: Assert NoSymlinks after snaggling
    Asserter->>FileSystem: WalkDir to check for symlinks
    Asserter->>T: Report error if symlink found
Loading

ER diagram for new symlinked test data

erDiagram
    TESTDETAILS {
        string Name
        string Path
        binaryDetails Bin
        string SnagTo
        string SnagAs
        bool InSubdir
        bool Symlink
    }
    TESTDATA {
        string Path
    }
    TESTDETAILS ||--|| TESTDATA : uses
Loading

Class diagram for updated TestDetails struct

classDiagram
    class TestDetails {
        string Name
        string Path
        binaryDetails Bin
        string SnagTo
        string SnagAs
        bool InSubdir
        bool Symlink
    }
Loading

Class diagram for new Asserter.NoSymlinks method

classDiagram
    class Asserter {
        DirectoryContents(ExpectedContents map[string]string, dir string)
        NoSymlinks(dir string)
        LinkedFile(path1 string, path2 string)
    }
Loading

File-Level Changes

Change Details Files
Extend TestDetails and default tests with subdir and symlink support
  • Added InSubdir and Symlink fields to TestDetails
  • Inserted new defaultTests entries for 'subdir' and 'symlink' scenarios
  • Removed unused subdir_contents variable
internal/testing/testiterator.go
Revise TestCases logic to filter and clone tests based on recursion and subdirectory flags
  • Initialize bins slice differently for recursive vs non-recursive runs
  • Filter out InSubdir tests when not running recursively
  • Use slices.Clone to duplicate defaultTests for recursive cases
internal/testing/testiterator.go
Add and integrate NoSymlinks assertion in test suite
  • Implemented Asserter.NoSymlinks to walk directories and flag symlinks
  • Called Assert.NoSymlinks in snaggle_test.go to validate results
internal/testing/assertions.go
snaggle_test.go
Introduce new test path and test data for symlink scenario
  • Declared P_symlinked_id constant for symlinked file path
  • Added testdata file at internal/testdata/symlink/id2
internal/testpaths.go
internal/testdata/symlink/id2

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 3, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.89474% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.77%. Comparing base (bc8b26f) to head (59bdefc).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/testing/assertions.go 38.46% 4 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #90      +/-   ##
==========================================
- Coverage   74.36%   73.77%   -0.60%     
==========================================
  Files          12       12              
  Lines         593      610      +17     
==========================================
+ Hits          441      450       +9     
- Misses        108      112       +4     
- Partials       44       48       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sourcery-ai sourcery-ai 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.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@MusicalNinjaDad MusicalNinjaDad merged commit c03e3fc into main Nov 3, 2025
12 of 14 checks passed
@MusicalNinjaDad MusicalNinjaDad deleted the symlink branch November 3, 2025 17:46
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.

Snaggle symlinked binaries

1 participant