Closed SUPERCILEX closed 9 months ago
No docs. Internally we tend to have a variable like REGENERATE_GOLDEN
https://github.com/facebook/buck2/blob/6b06646a36b0ac8b33378fd4103e461e2cec20ba/starlark-rust/starlark_syntax/src/golden_test_template.rs#L24 and if that is set, we update the source, if not, we just fail. As long as you tag the rule as must run locally it should work.
So you can't touch the source code purly in buck? An example file says to use cargo to regenerate the file: https://github.com/facebook/buck2/blob/19678f98577799856f05ff9766d0c143d1c52e92/starlark-rust/starlark/src/typing/golden/zip.golden#L4
There are two reasons we recommend Cargo:
If you are using Buck2 to update golden files, the solution is probably to have a run command that actually applies the update. So you could do buck2 run :update-golden-tests
. Generally we hope a build
doesn't mutate the source directory, but a run
can do anything it likes.
Got it, thanks.
Are there docs on doing golden testing? So comparing generated output with something checked into the source tree, and using buck2 to update the source tree.