Skip to content

Commit 4d11c0b

Browse files
criemenmalt3
authored andcommitted
Add integration test for external relative path deps (issue #3089)
This test reproduces the bug where crate_universe fails when a Cargo workspace member has a path dependency pointing outside the Cargo workspace root (but still inside the Bazel workspace). The test is expected to fail until the bug is fixed.
1 parent 3f4f431 commit 4d11c0b

16 files changed

Lines changed: 534 additions & 0 deletions

File tree

.bazelci/presubmit.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,12 @@ tasks:
637637
build_targets:
638638
- "@rust_toolchains//:all"
639639
- "//..."
640+
external_relative_path_deps:
641+
name: External relative path deps (issue 3089)
642+
platform: ubuntu2204
643+
working_directory: test/integration/external_relative_path_deps
644+
build_targets:
645+
- "//..."
640646
android_examples_ubuntu2204:
641647
name: Android Examples
642648
platform: ubuntu2204
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.0.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bazel-*
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Empty BUILD file for workspace root
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Test for external relative path dependencies (issue #3089)"""
2+
3+
module(
4+
name = "external_relative_path_deps_test",
5+
version = "0.0.0",
6+
)
7+
8+
bazel_dep(name = "rules_rust", version = "0.0.0")
9+
local_path_override(
10+
module_name = "rules_rust",
11+
path = "../../..",
12+
)
13+
14+
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
15+
rust.toolchain(edition = "2021")
16+
use_repo(rust, "rust_toolchains")
17+
18+
register_toolchains("@rust_toolchains//:all")
19+
20+
# Test: crate_universe with Cargo workspace where a member has a path dependency
21+
# that goes OUTSIDE the Cargo workspace root (but still inside the Bazel workspace).
22+
#
23+
# Structure:
24+
# external_crate/ <- Outside Cargo workspace
25+
# cargo_workspace/ <- Cargo workspace root
26+
# Cargo.toml <- [workspace] members = ["member"]
27+
# member/
28+
# Cargo.toml <- external_crate = { path = "../../external_crate" }
29+
#
30+
# This should work but currently fails because crate_universe doesn't copy
31+
# the external path dependency into the temp splicing directory.
32+
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
33+
crate.from_cargo(
34+
name = "crates",
35+
cargo_lockfile = "//cargo_workspace:Cargo.lock",
36+
manifests = ["//cargo_workspace:Cargo.toml"],
37+
)
38+
use_repo(crate, "crates")

test/integration/external_relative_path_deps/MODULE.bazel.lock

Lines changed: 382 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# External Relative Path Dependencies Test (Issue #3089)
2+
3+
This test validates that crate_universe correctly handles Cargo workspace members
4+
with path dependencies that point **outside the Cargo workspace root** (but still
5+
inside the Bazel workspace).
6+
7+
## Structure
8+
9+
```
10+
external_relative_path_deps/ # Bazel workspace root
11+
├── MODULE.bazel
12+
├── BUILD.bazel
13+
├── external_crate/ # Outside Cargo workspace, inside Bazel workspace
14+
│ ├── Cargo.toml
15+
│ └── src/lib.rs
16+
└── cargo_workspace/ # Cargo workspace root
17+
├── Cargo.toml # [workspace] with members = ["member"]
18+
├── Cargo.lock
19+
└── member/
20+
├── Cargo.toml # Has path = "../../external_crate"
21+
└── src/lib.rs
22+
```
23+
24+
## The Bug
25+
26+
When `cargo_workspace/member/Cargo.toml` has:
27+
```toml
28+
[dependencies]
29+
external_crate = { path = "../../external_crate" }
30+
```
31+
32+
crate_universe fails because it doesn't copy `external_crate` into the temp
33+
directory used for splicing.
34+
35+
## Running the test
36+
37+
```sh
38+
cd test/integration/external_relative_path_deps
39+
bazel build //cargo_workspace/member
40+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Empty WORKSPACE for Bazel compatibility
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
exports_files([
2+
"Cargo.toml",
3+
"Cargo.lock",
4+
])

test/integration/external_relative_path_deps/cargo_workspace/Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)