-
Notifications
You must be signed in to change notification settings - Fork 522
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
Add golden_file_test to public API #1893
Comments
To bike-shed the name a little: a lot of people ask "how do I check in generated sources" or "how do I get Bazel to write to the input directory" or questions like this. They're not thinking in terms of writing a test, at least to begin with. Also "golden" isn't a universal term. Jest calls similar files "snapshot" for example. Maybe Any thoughts? |
I can confirm that I have seen "golden" show up dozens of time in this project and never really known what it meant, but your comments here have made me realize this is probably what someone would need to get something like Betterer working within Bazel. Maybe a name that reflects this need for persistence by version control? Naming things is hard. |
|
The only thing I'm pretty sure of is that it should end with Let's have some votes with reasoning? Try to think of it from a number of perspectives including confused/novice users
also maybe the custom verb "accept" should be "copy" or "update" |
What about To me, I don't know if something like |
Having snapshot in the name is a good idea, I added option 10 above. |
Interesting! How would a bazel build rule depend on a test rule? Meaning, how would bazel know that it must run the test to ensure that the generated file is up to date? |
@joeljeske err no, the build rule depends on the generated file, which might be out-of-date. Only when the test runs do you find out. Your understanding is right. In slack we have some votes for |
okay I'm going with |
This is a new public API for checking in golden or snapshot files. If you used the private golden_file_test previously, you need to rename actual to generated, golden to src, and golden_debug to src_dbg Fixes bazel-contrib#1893
This is a new public API for checking in golden or snapshot files. If you used the private golden_file_test previously, you need to rename actual to generated, golden to src, and golden_debug to src_dbg Fixes bazel-contrib#1893
This is a new public API for checking in golden or snapshot files. If you used the private golden_file_test previously, you need to rename actual to generated, golden to src, and golden_debug to src_dbg Fixes #1893
Belated comment: the problems with adding this to bazel-skylib are:
I agree that it would be useful to have a |
Belated comment 2: found that Bazel uses msys2's |
Our golden_file_test
https://github.com/bazelbuild/rules_nodejs/blob/master/internal/golden_file_test/golden_file_test.bzl
is pretty useful and I've pointed a bunch of users to it, as a way to check build outputs into their source tree (in cases where they really have to do that, it's a hacky workaround for dev workflows that can't rely on files in
bazel-out
)It belongs in bazel-skylib bazelbuild/bazel-skylib#90 (comment) but it feels it will be hard to add there. We already have the public api
copy_to_bin
https://github.com/bazelbuild/rules_nodejs/blob/master/docs/Built-ins.md#copy_to_bin
which belonged in bazel-skylib but isn't getting merged there bazelbuild/bazel-skylib#217
So we could probably commit to making it public
The text was updated successfully, but these errors were encountered: