Skip to content

Commit 5229b37

Browse files
committed
Fix unstripped roots in multi-configuration builds
rustdoc_test fails when its crate dependency and its toolchain dependency are from different configurations, because the stripped roots did not include any toolchain files. This change simplifies the logic by collecting roots from all the inputs.
1 parent 22a4ecb commit 5229b37

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

rust/private/rustdoc_test.bzl

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ load("//rust/private:providers.bzl", "CrateInfo")
2020
load("//rust/private:rustdoc.bzl", "rustdoc_compile_action")
2121
load("//rust/private:utils.bzl", "dedent", "find_toolchain", "transform_deps")
2222

23-
def _construct_writer_arguments(ctx, test_runner, opt_test_params, action, crate_info):
23+
def _construct_writer_arguments(ctx, test_runner, opt_test_params, action):
2424
"""Construct arguments and environment variables specific to `rustdoc_test_writer`.
2525
2626
This is largely solving for the fact that tests run from a runfiles directory
@@ -32,7 +32,6 @@ def _construct_writer_arguments(ctx, test_runner, opt_test_params, action, crate
3232
test_runner (File): The test_runner output file declared by `rustdoc_test`.
3333
opt_test_params (File): An output file we can optionally use to store params for `rustdoc`.
3434
action (struct): Action arguments generated by `rustdoc_compile_action`.
35-
crate_info (CrateInfo): The provider of the crate who's docs are being tested.
3635
3736
Returns:
3837
tuple: A tuple of `rustdoc_test_writer` specific inputs
@@ -64,29 +63,13 @@ def _construct_writer_arguments(ctx, test_runner, opt_test_params, action, crate
6463

6564
# Collect and dedupe all of the file roots in a list before appending
6665
# them to args to prevent generating a large amount of identical args
67-
roots = []
68-
root = crate_info.output.root.path
69-
if not root in roots:
70-
roots.append(root)
71-
for dep in crate_info.deps.to_list() + crate_info.proc_macro_deps.to_list():
72-
dep_crate_info = getattr(dep, "crate_info", None)
73-
dep_dep_info = getattr(dep, "dep_info", None)
74-
if dep_crate_info:
75-
root = dep_crate_info.output.root.path
76-
if not root in roots:
77-
roots.append(root)
78-
if dep_dep_info:
79-
for direct_dep in dep_dep_info.direct_crates.to_list():
80-
root = direct_dep.dep.output.root.path
81-
if not root in roots:
82-
roots.append(root)
83-
for transitive_dep in dep_dep_info.transitive_crates.to_list():
84-
root = transitive_dep.output.root.path
85-
if not root in roots:
86-
roots.append(root)
87-
88-
for root in roots:
89-
writer_args.add("--strip_substring={}/".format(root))
66+
roots = {}
67+
for input in action.inputs.to_list():
68+
roots[input.root.path] = None
69+
70+
for root in roots.keys():
71+
if root:
72+
writer_args.add("--strip_substring={}/".format(root))
9073

9174
# Indicate that the rustdoc_test args are over.
9275
writer_args.add("--")
@@ -165,7 +148,6 @@ def _rust_doc_test_impl(ctx):
165148
test_runner = test_runner,
166149
opt_test_params = opt_test_params,
167150
action = action,
168-
crate_info = crate_info,
169151
)
170152

171153
# Allow writer environment variables to override those from the action.

0 commit comments

Comments
 (0)