check type of snaggled file & copy to /bin or /lib64 accordingly#61
Merged
Conversation
It reports fails where scoped. (Fixes subtest shows pass, outer test shows fail, when subtest fails)
Reviewer's GuideRefactors internal assertion helpers, updates test data to dynamically route executables to /bin and libraries to /lib64, modifies Snaggle to branch linking based on file type, and adjusts tests to use the new assertions. Entity relationship diagram for dynamic routing of executables and libraries in testdata.goerDiagram
ELF {
string Name
string Path
string Interpreter
string[] Dependencies
}
binaryDetails {
ELF Elf
bool Exe
bool HasInterpreter
}
ELF ||--o{ binaryDetails : contains
binaryDetails ||--o{ files : generates
files {
string key
string value
}
Class diagram for updated assertion helpers in comparisons.goclassDiagram
class AssertSameFile {
+AssertSameFile(t *testing.T, path1 string, path2 string)
}
class AssertLinkedFile {
+AssertLinkedFile(t *testing.T, path1 string, path2 string)
}
AssertSameFile --> sameFile
AssertLinkedFile --> sameInode
Flow diagram for Snaggle file linking based on file typeflowchart TD
A["Snaggle(path, root)"] --> B["Check if file.IsExe()"]
B -- Yes --> C["link(path, binDir)"]
B -- No --> D["link(path, libDir)"]
C --> E["If file.Interpreter != ''"]
D --> E
E -- Yes --> F["link(file.Interpreter, libDir)"]
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Consider extracting the common error-checking and assertion logic from AssertSameFile and AssertLinkedFile into a shared helper to reduce duplication.
- In ExpectedOutput, the repeated construction of binBasePath and libBasePath could be factored into a small helper to make the code more declarative and avoid repetition.
- In Snaggle, you could compute targetDir based on file.IsExe() once and then invoke link in a single linkerrs.Go call, rather than branching around separate calls for cleaner control flow.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the common error-checking and assertion logic from AssertSameFile and AssertLinkedFile into a shared helper to reduce duplication.
- In ExpectedOutput, the repeated construction of binBasePath and libBasePath could be factored into a small helper to make the code more declarative and avoid repetition.
- In Snaggle, you could compute targetDir based on file.IsExe() once and then invoke link in a single linkerrs.Go call, rather than branching around separate calls for cleaner control flow.
## Individual Comments
### Comment 1
<location> `snaggle.go:158-161` </location>
<code_context>
linkerrs := new(errgroup.Group)
- linkerrs.Go(func() error { return link(path, binDir) })
+ if file.IsExe() {
+ linkerrs.Go(func() error { return link(path, binDir) })
+ } else {
+ linkerrs.Go(func() error { return link(path, libDir) })
+ }
// TODO: #50 make linking interpreter safer
</code_context>
<issue_to_address>
**suggestion:** The branching for linking could be refactored for maintainability.
Assign the target directory based on file type, then call linkerrs.Go once. This streamlines the code and simplifies future updates.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #61 +/- ##
==========================================
+ Coverage 73.86% 74.35% +0.49%
==========================================
Files 8 8
Lines 417 425 +8
==========================================
+ Hits 308 316 +8
Misses 77 77
Partials 32 32 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #56
Summary by Sourcery
Detect file type to link executables into /bin and libraries into /lib64, introduce a dedicated AssertLinkedFile helper, and update tests and ExpectedOutput accordingly
New Features:
Enhancements:
Tests: