Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc_test: Apply prefix stripping to proc_macro dependencies. #1952

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust/private/rustdoc_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _construct_writer_arguments(ctx, test_runner, opt_test_params, action, crate
root = crate_info.output.root.path
if not root in roots:
roots.append(root)
for dep in crate_info.deps.to_list():
for dep in crate_info.deps.to_list() + crate_info.proc_macro_deps.to_list():
dep_crate_info = getattr(dep, "crate_info", None)
dep_dep_info = getattr(dep, "dep_info", None)
if dep_crate_info:
Expand Down
9 changes: 9 additions & 0 deletions test/unit/rustdoc/procmacro_in_rustdoc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// A different answer that only exists if using procmacros.
/// ```
/// use rustdoc_proc_macro::make_answer;
/// make_answer!();
/// assert_eq!(answer(), 42);
/// ```
pub fn procmacro_answer() -> u32 {
24
}
22 changes: 22 additions & 0 deletions test/unit/rustdoc/rustdoc_unit_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ def _rustdoc_for_lib_with_proc_macro_test_impl(ctx):

return analysistest.end(env)

def _rustdoc_for_lib_with_proc_macro_in_docs_test_impl(ctx):
env = analysistest.begin(ctx)
tut = analysistest.target_under_test(env)

_common_rustdoc_checks(env, tut)

return analysistest.end(env)

def _rustdoc_for_bin_with_transitive_proc_macro_test_impl(ctx):
env = analysistest.begin(ctx)
tut = analysistest.target_under_test(env)
Expand Down Expand Up @@ -145,6 +153,7 @@ rustdoc_for_bin_with_cc_lib_test = analysistest.make(_rustdoc_for_bin_with_cc_li
rustdoc_for_bin_with_transitive_cc_lib_test = analysistest.make(_rustdoc_for_bin_with_transitive_cc_lib_test_impl)
rustdoc_for_proc_macro_test = analysistest.make(_rustdoc_for_proc_macro_test_impl)
rustdoc_for_lib_with_proc_macro_test = analysistest.make(_rustdoc_for_lib_with_proc_macro_test_impl)
rustdoc_for_lib_with_proc_macro_in_docs_test = analysistest.make(_rustdoc_for_lib_with_proc_macro_in_docs_test_impl)
rustdoc_for_bin_with_transitive_proc_macro_test = analysistest.make(_rustdoc_for_bin_with_transitive_proc_macro_test_impl)
rustdoc_for_lib_with_cc_lib_test = analysistest.make(_rustdoc_for_lib_with_cc_lib_test_impl)
rustdoc_with_args_test = analysistest.make(_rustdoc_with_args_test_impl)
Expand Down Expand Up @@ -234,6 +243,13 @@ def _define_targets():
crate_features = ["with_proc_macro"],
)

_target_maker(
rust_library,
name = "lib_with_proc_macro_in_docs",
srcs = ["procmacro_in_rustdoc.rs"],
proc_macro_deps = [":rustdoc_proc_macro"],
)

_target_maker(
rust_library,
name = "lib_nodep_with_proc_macro",
Expand Down Expand Up @@ -371,6 +387,11 @@ def rustdoc_test_suite(name):
target_under_test = ":rustdoc_proc_macro_doc",
)

rustdoc_for_lib_with_proc_macro_in_docs_test(
name = "rustdoc_for_lib_with_proc_macro_in_docs_test",
target_under_test = ":lib_with_proc_macro_in_docs_doc",
)

rustdoc_for_lib_with_proc_macro_test(
name = "rustdoc_for_lib_with_proc_macro_test",
target_under_test = ":lib_with_proc_macro_doc",
Expand Down Expand Up @@ -414,6 +435,7 @@ def rustdoc_test_suite(name):
":rustdoc_for_bin_with_cc_lib_test",
":rustdoc_for_bin_with_transitive_cc_lib_test",
":rustdoc_for_proc_macro_test",
":rustdoc_for_lib_with_proc_macro_in_docs_test",
":rustdoc_for_lib_with_proc_macro_test",
":rustdoc_for_lib_with_cc_lib_test",
":rustdoc_with_args_test",
Expand Down
Loading