Skip to content

Commit 2ae3ea0

Browse files
committed
fix: use correct env for rust_test
This introduces a rules_rust patch to work around issues in how the `rust_test` environment is set up. This issue leads to wasm_spec test failures in Bazel 8 where the test runner cannot find the spec files. See also: bazelbuild/rules_rust#3764
1 parent 1a1cb8c commit 2ae3ea0

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

bazel/rules_rust_rust_test.patch

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# rules_rust uses a wrapper that causes issues:
2+
# https://github.com/bazelbuild/rules_rust/pull/3764
3+
diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl
4+
index 2f695cbbb..118076c25 100644
5+
--- a/rust/private/rust.bzl
6+
+++ b/rust/private/rust.bzl
7+
@@ -511,12 +511,14 @@ def _rust_test_impl(ctx):
8+
)
9+
data = getattr(ctx.attr, "data", [])
10+
11+
- env = expand_dict_value_locations(
12+
- ctx,
13+
- getattr(ctx.attr, "env", {}),
14+
- data,
15+
- {},
16+
- )
17+
+ env = {
18+
+ key: ctx.expand_make_variables(
19+
+ "env",
20+
+ ctx.expand_location(value, ctx.attr.data, short_paths = True),
21+
+ {},
22+
+ )
23+
+ for key, value in ctx.attr.env.items()
24+
+ }
25+
if toolchain.llvm_cov and ctx.configuration.coverage_enabled:
26+
if not toolchain.llvm_profdata:
27+
fail("toolchain.llvm_profdata is required if toolchain.llvm_cov is set.")

bazel/rust.MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ archive_override(
1010
patches = [
1111
"//bazel:rules_rust_strip_level.patch",
1212
"//bazel:rules_rust_package_alias.patch",
13+
"//bazel:rules_rust_rust_test.patch",
1314
],
1415
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.67.0/rules_rust-0.67.0.tar.gz"],
1516
)

0 commit comments

Comments
 (0)