rust_test(crate=foo) inherits foo.aliases (#2965)

Inline tests compile the same set of source files as the original crate.
The set of aliases required will be the same or occasionally a superset.
We shouldn't make users repeat them across targets.
This commit is contained in:
Sam McCall 2024-10-28 17:04:57 +01:00 committed by GitHub
parent c603a7710d
commit a6426e06d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 5 deletions

View File

@ -346,6 +346,8 @@ def _rust_test_impl(ctx):
ctx.attr.rustc_env, ctx.attr.rustc_env,
data_paths, data_paths,
)) ))
aliases = dict(crate.aliases)
aliases.update(ctx.attr.aliases)
# Build the test binary using the dependency's srcs. # Build the test binary using the dependency's srcs.
crate_info_dict = dict( crate_info_dict = dict(
@ -355,7 +357,7 @@ def _rust_test_impl(ctx):
srcs = depset(srcs, transitive = [crate.srcs]), srcs = depset(srcs, transitive = [crate.srcs]),
deps = depset(deps, transitive = [crate.deps]), deps = depset(deps, transitive = [crate.deps]),
proc_macro_deps = depset(proc_macro_deps, transitive = [crate.proc_macro_deps]), proc_macro_deps = depset(proc_macro_deps, transitive = [crate.proc_macro_deps]),
aliases = ctx.attr.aliases, aliases = aliases,
output = output, output = output,
rustc_output = generate_output_diagnostics(ctx, output), rustc_output = generate_output_diagnostics(ctx, output),
edition = crate.edition, edition = crate.edition,

View File

@ -41,10 +41,6 @@ rust_test(
rust_test( rust_test(
name = "mod3_test", name = "mod3_test",
aliases = {
":mod1": "alias_a",
":mod2": "alias_b",
},
crate = ":mod3", crate = ":mod3",
edition = "2018", edition = "2018",
) )