rules_rust
rules_rust copied to clipboard
feat: Add `capture_output` attr to `rust_doc` rule
This PR adds a capture_output
attr to the rust_doc
rule, which if set to True
will redirect the output of stderr
into a file with the suffix of .rustdoc.out
.
Adding this unlocks the ability for users to define a bazel test rule that asserts their docs build without warnings. This is useful because it allows you to semi-automate the process of making sure your docs are up to date.
Hey @illicitonion, any chance you could review this PR too? No rush though :)
P.S. I tried to assign a reviewer but I don't seem to be able to
Adding this unlocks the ability for users to define a bazel test rule that asserts their docs build without warnings. This is useful because it allows you to semi-automate the process of making sure your docs are up to date.
Does rustdoc
really not have a flag to promote warnings to errors? It sounds like that's what you'd want instead of needing to parse a bunch of text in a bespoke action.
Does
rustdoc
really not have a flag to promote warnings to errors? It sounds like that's what you'd want instead of needing to parse a bunch of text in a bespoke action.
It does, you can pass -Dwarnings
to deny all warnings. The issue though is the rust_doc
rule is not declared as a test rule, so even if your rustdoc build fails, running bazel test //rustdoc_target
still passes.
I would love if there was a way to make a bazel test whose predicate is "test whether or not this other build target succeeds", but AFAICT there isn't.
It does, you can pass
-Dwarnings
to deny all warnings. The issue though is therust_doc
rule is not declared as a test rule, so even if your rustdoc build fails, runningbazel test //rustdoc_target
still passes.I would love if there was a way to make a bazel test whose predicate is "test whether or not this other build target succeeds", but AFAICT there isn't.
Don't build targets get built under bazel test //...
unless you're using --build_tests_only? Also, if you want a build target to be guaranteed to run in a test, couldn't you use @bazel_skylib//rules:build_test.bzl?