Skip to content

Commit ac5aa1e

Browse files
goffrieUebelAndre
andauthored
rustdoc: respect error_format config (#2166)
This makes it easier to make a test ensuring rustdoc doesn't emit warnings. --------- Co-authored-by: UebelAndre <[email protected]>
1 parent 4a5d7a1 commit ac5aa1e

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

rust/private/rustdoc.bzl

+3
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ rust_doc = rule(
321321
cfg = "exec",
322322
executable = True,
323323
),
324+
"_error_format": attr.label(
325+
default = Label("//:error_format"),
326+
),
324327
"_process_wrapper": attr.label(
325328
doc = "A process wrapper for running rustdoc on all platforms",
326329
default = Label("@rules_rust//util/process_wrapper"),

test/unit/rustdoc/rustdoc_unit_test.bzl

+21
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@ def _rustdoc_zip_output_test_impl(ctx):
111111

112112
return analysistest.end(env)
113113

114+
def _rustdoc_with_json_error_format_test_impl(ctx):
115+
env = analysistest.begin(ctx)
116+
tut = analysistest.target_under_test(env)
117+
118+
_common_rustdoc_checks(env, tut)
119+
120+
action = _get_rustdoc_action(env, tut)
121+
122+
assert_argv_contains(env, action, "--error-format=json")
123+
124+
return analysistest.end(env)
125+
114126
rustdoc_for_lib_test = analysistest.make(_rustdoc_for_lib_test_impl)
115127
rustdoc_for_bin_test = analysistest.make(_rustdoc_for_bin_test_impl)
116128
rustdoc_for_proc_macro_test = analysistest.make(_rustdoc_for_proc_macro_test_impl)
@@ -119,6 +131,9 @@ rustdoc_for_bin_with_transitive_proc_macro_test = analysistest.make(_rustdoc_for
119131
rustdoc_for_lib_with_cc_lib_test = analysistest.make(_rustdoc_for_lib_with_cc_lib_test_impl)
120132
rustdoc_with_args_test = analysistest.make(_rustdoc_with_args_test_impl)
121133
rustdoc_zip_output_test = analysistest.make(_rustdoc_zip_output_test_impl)
134+
rustdoc_with_json_error_format_test = analysistest.make(_rustdoc_with_json_error_format_test_impl, config_settings = {
135+
"@//:error_format": "json",
136+
})
122137

123138
def _target_maker(rule_fn, name, rustdoc_deps = [], **kwargs):
124139
rule_fn(
@@ -321,6 +336,11 @@ def rustdoc_test_suite(name):
321336
target_under_test = ":rustdoc_with_args",
322337
)
323338

339+
rustdoc_with_json_error_format_test(
340+
name = "rustdoc_with_json_error_format_test",
341+
target_under_test = ":lib_doc",
342+
)
343+
324344
native.filegroup(
325345
name = "lib_doc_zip",
326346
srcs = [":lib_doc.zip"],
@@ -340,6 +360,7 @@ def rustdoc_test_suite(name):
340360
":rustdoc_for_lib_with_proc_macro_test",
341361
":rustdoc_for_lib_with_cc_lib_test",
342362
":rustdoc_with_args_test",
363+
":rustdoc_with_json_error_format_test",
343364
":rustdoc_zip_output_test",
344365
],
345366
)

0 commit comments

Comments
 (0)