Skip to content

Commit ccb0548

Browse files
committed
Better fix for rust_doc_test
1 parent 171ec8d commit ccb0548

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

rust/private/rustdoc.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def rustdoc_compile_action(
4848
toolchain,
4949
crate_info,
5050
output = None,
51-
rustdoc_flags = []):
51+
rustdoc_flags = [],
52+
is_test = False):
5253
"""Create a struct of information needed for a `rustdoc` compile action based on crate passed to the rustdoc rule.
5354
5455
Args:
@@ -57,6 +58,7 @@ def rustdoc_compile_action(
5758
crate_info (CrateInfo): The provider of the crate passed to a rustdoc rule.
5859
output (File, optional): An optional output a `rustdoc` action is intended to produce.
5960
rustdoc_flags (list, optional): A list of `rustdoc` specific flags.
61+
is_test (bool, optional): If True, the action will be configured for `rust_doc_test` targets
6062
6163
Returns:
6264
struct: A struct of some `ctx.actions.run` arguments.
@@ -102,7 +104,7 @@ def rustdoc_compile_action(
102104
attr = ctx.attr,
103105
file = ctx.file,
104106
toolchain = toolchain,
105-
tool_path = toolchain.rust_doc.path,
107+
tool_path = toolchain.rust_doc.short_path if is_test else toolchain.rust_doc.path,
106108
cc_toolchain = cc_toolchain,
107109
feature_configuration = feature_configuration,
108110
crate_info = rustdoc_crate_info,

rust/private/rustdoc_test.bzl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ def _construct_writer_arguments(ctx, test_runner, action, crate_info, rust_toolc
5656
for var in action.env.keys():
5757
writer_args.add("--action_env={}".format(var))
5858

59-
# Ensure the rustdoc binary is always accessed via a relative path
60-
writer_args.add("--strip_substring={}/".format(
61-
rust_toolchain.rust_doc.root.path,
62-
))
63-
6459
# Since the test runner will be running from a runfiles directory, the
6560
# paths originally generated for the build action will not map to any
6661
# files. To ensure rustdoc can find the appropriate dependencies, the
@@ -121,6 +116,7 @@ def _rust_doc_test_impl(ctx):
121116
toolchain = find_toolchain(ctx),
122117
crate_info = crate_info,
123118
rustdoc_flags = rustdoc_flags,
119+
is_test = True,
124120
)
125121

126122
tools = action.tools + [ctx.executable._process_wrapper]

0 commit comments

Comments
 (0)