Skip to content

Commit

Permalink
Add non-reg test for compile_data propagation in rust_doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Fariello committed Jan 6, 2023
1 parent 250aa2e commit 04b480d
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions test/unit/compile_data/compile_data_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
load("//rust:defs.bzl", "rust_common", "rust_library", "rust_test", "rust_doc")
load(
"//test/unit:common.bzl",
"assert_action_mnemonic",
)

def _target_has_compile_data(ctx, expected):
env = analysistest.begin(ctx)
Expand Down Expand Up @@ -42,10 +46,14 @@ def _wrapper_rule_propagates_and_joins_compile_data_test_impl(ctx):
)

def _compile_data_propagates_to_rust_doc_test_impl(ctx):
return _target_has_compile_data(
ctx,
["test/unit/compile_data/compile_data.txt"],
)
env = analysistest.begin(ctx)
target = analysistest.target_under_test(env)

actions = target.actions
action = actions[0]
assert_action_mnemonic(env, action, "Rustdoc")

return analysistest.end(env)

compile_data_propagates_to_crate_info_test = analysistest.make(_compile_data_propagates_to_crate_info_test_impl)
wrapper_rule_propagates_to_crate_info_test = analysistest.make(_wrapper_rule_propagates_to_crate_info_test_impl)
Expand All @@ -72,9 +80,19 @@ def _define_test_targets():
rustc_flags = ["--cfg=test_compile_data"],
)

rust_library(
name = "compile_data_env",
srcs = ["compile_data_env.rs"],
compile_data = ["compile_data.txt"],
rustc_env = {
"COMPILE_DATA_PATH": "$(location :compile_data.txt)",
},
edition = "2018",
)

rust_doc(
name = "compile_data_rust_doc",
crate = ":compile_data",
name = "compile_data_env_rust_doc",
crate = ":compile_data_env",
)

def compile_data_test_suite(name):
Expand Down Expand Up @@ -103,7 +121,7 @@ def compile_data_test_suite(name):

compile_data_propagates_to_rust_doc_test(
name = "compile_data_propagates_to_rust_doc_test",
target_under_test = ":compile_data",
target_under_test = ":compile_data_env_rust_doc",
)


Expand Down

0 comments on commit 04b480d

Please sign in to comment.