bazelbuild / bazelbuild/rules_rust

`CARGO_PKG_VERSION` is not set for `rust_test` targets

Open
#1,117 0 comments 0 reactions 0 assignees View on GitHub
bug needs-triage
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

Using this setup
```python
rust_library(
name = "my_lib",
srcs = glob(["src/**/*.rs"]),
version = "0.1.0",
)

rust_test(
name = "unit_test",
crate = ":my_lib",
)
```

And running a test like this

```rust
#[test]
fn check_version() {
assert_eq!(env!("CARGO_PKG_VERSION"), "0.1.0");
}
```

Produces a failure where `0.0.0 != 0.1.0` which shows `CARGO_PKG_VERSION` is not being set in `rust_test`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.