Use correct env for rust_test#3764
Conversation
This expands the `rust_test` environment make variables directly instead of using the "build script" helper. The build script helper is incorrect here and this leads issues in Bazel 8.
b60486c to
b401d8f
Compare
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
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
illicitonion
left a comment
There was a problem hiding this comment.
Makes sense, thank you!
illicitonion
left a comment
There was a problem hiding this comment.
Please could you add a test showing this working, which failed without it?
|
@illicitonion it's been a while, though interestingly I cannot reproduce anymore. Something might have changed in Bazel between the version I originally tried (8.X) and two more recent releases I tried which don't require the patch (8.4.2 & 8.5.1). Or maybe I just hallucinated the whole thing :) I don't think it's a bad idea to reuse the same implementation as |
|
I'll close for now, but if anyone can repro, please do shout and we can reopen! Thanks! |
|
@illicitonion well, I guess you just had to close the PR for me to run into the issue again 😛 I've created a repro here. Without the changes in this PR, the test fails. With the patch, it succeeds. The setup is not ideal because I'm pulling the whole wasm test spec (I extracted the repro from this repo). I'm not familiar with the test setup for rules_rust; can I let you take it from here? |
|
Thanks for the repro! This was super useful! The root cause here is that In a test, you always want a rootpath. So instead of using the confusingly defined diff --git i/test/test_env/BUILD.bazel w/test/test_env/BUILD.bazel
index f2cd0dc8c..8b46d80d0 100644
--- i/test/test_env/BUILD.bazel
+++ w/test/test_env/BUILD.bazel
@@ -73,6 +73,6 @@ rust_test(
srcs = ["tests/test_env_locations_external.rs"],
data = ["@wasm_spec_testsuite//:memory64_wast_files"],
env = {
- "THE_FILES": "$(locations @wasm_spec_testsuite//:memory64_wast_files)",
+ "THE_FILES": "$(rootpaths @wasm_spec_testsuite//:memory64_wast_files)",
},
)Does this work for you? |
There is a better (more correct) fix for the issue, which is to replace the underspecified `$(locations)` with `$(rootpaths)`: bazelbuild/rules_rust#3764
It does, thank you very much for taking the time to look into this — and confirm it was a chair-to-keyboard interface error :) |
There is a better (more correct) fix for the issue, which is to replace the underspecified `$(locations)` with `$(rootpaths)`: bazelbuild/rules_rust#3764
This expands the
rust_testenvironment make variables directly instead of using the "build script" helper. The build script helper is incorrect here and this leads issues in Bazel 8.Note: this was inspired by rules_shell.