Skip to content

chore: remove magic files from test-fixtures for classifier unit tests#2435

Closed
spiffcs wants to merge 8 commits intomainfrom
remove-binary-assets-from-repo
Closed

chore: remove magic files from test-fixtures for classifier unit tests#2435
spiffcs wants to merge 8 commits intomainfrom
remove-binary-assets-from-repo

Conversation

@spiffcs
Copy link
Copy Markdown
Contributor

@spiffcs spiffcs commented Dec 15, 2023

Summary

This PR aims to remove the dependence on "magic file" being committed to the repository as a function of testing the binary cataloger.

This should allow contributors to show clearly the strings/content their new classifier contributions are being tested against rather than having to commit a magic file with the byte contents.

Example of a magic file

On main you can run:

$file -v syft/pkg/cataloger/binary/test-fixtures/classifiers/positive/go-1.14/go

file-5.41
magic file from /usr/share/file/magic

Change Summary

  • Remove mostly all positive case magic files from test fixtures
  • Update tests to assert on the contents of the string the individual classifiers were written against
    • note: this involves creating a temporary file and deleting after the test has run
  • Separate cases into dynamic and content sections of the test.

Notes for reviewer

  • I noticed that the byte diff for some of the deleted files showed a subtraction of bytes rather than the file being deleted. Is there some other motion we need here to fully delete the artifacts?

LaurentGoderre and others added 2 commits December 11, 2023 12:16
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
@spiffcs spiffcs marked this pull request as draft December 15, 2023 16:40
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
@spiffcs spiffcs marked this pull request as ready for review December 15, 2023 22:39
@spiffcs spiffcs changed the title chore: remove binary assets from repo chore: remove magic files from test-fixtures for classifier unit tests Dec 15, 2023
@spiffcs
Copy link
Copy Markdown
Contributor Author

spiffcs commented Dec 18, 2023

@LaurentGoderre - I'm closing this PR for now. There was some internal commentary on a different rework where we move everything over to the dynamic style if we make changes here.

In response, I'm going to just go through and get you're merged with the current pattern before we do this rework.

@spiffcs spiffcs closed this Dec 18, 2023
@spiffcs spiffcs deleted the remove-binary-assets-from-repo branch November 17, 2024 19:19
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.

2 participants