Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support binary files in generated_file_test #3184

Closed
longlho opened this issue Jan 3, 2022 · 2 comments · Fixed by #3217
Closed

support binary files in generated_file_test #3184

longlho opened this issue Jan 3, 2022 · 2 comments · Fixed by #3217

Comments

@longlho
Copy link
Contributor

longlho commented Jan 3, 2022

🚀 feature request

Relevant Rules

generated_file_test

Description

We have the use case of checking in assets like fonts/png/tar files and it'd be great if generated_file_test supports binary files as well. Right now it reads file as utf-8 encoding and during write as well which messes stuff up.

Happy to put in a PR if you want.

Describe the solution you'd like

generated_file_test supports binary files as well.

Describe alternatives you've considered

Write my own implementation?

@alexeagle
Copy link
Collaborator

We have is_binary in the repo already, but it has false positives.

The simplest answer is to use bazel-skylib directly. I added a failure_message attribute to diff_test https://docs.aspect.dev/bazelbuild/bazel-skylib/1.1.1/docs/diff_test.html
so you can just use the pattern directly, paired with an sh_binary to copy the file.
See https://blog.aspect.dev/bazel-can-write-to-the-source-folder

@longlho
Copy link
Contributor Author

longlho commented Jan 10, 2022

thanks for the pointer. That works!

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 a pull request may close this issue.

2 participants