Skip to content

Commit 33d3ef1

Browse files
authored
build: Grab binary path from cargo (#1429)
The conformance test needs the path to a generated binary. This was calculated based on the path of the test binary. This assumption fails when the build dir is changed with `CARGO_BUILD_BUILD_DIR`. Take the path from the environment as Cargo will store it there.
1 parent d0b6199 commit 33d3ef1

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

conformance/tests/conformance.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,8 @@ use protobuf::conformance;
99
/// so that Cargo will build the proto-conformance binary.
1010
#[test]
1111
fn test_conformance() {
12-
// Get the path to the proto-conformance binary. Adapted from
13-
// https://github.com/rust-lang/cargo/blob/19fdb308cdbb25faf4f1e25a71351d8d603fa447/tests/cargotest/support/mod.rs#L306.
14-
let proto_conformance = env::current_exe()
15-
.map(|mut path| {
16-
path.pop();
17-
if path.ends_with("deps") {
18-
path.pop();
19-
}
20-
path.join("conformance")
21-
})
22-
.unwrap();
12+
let proto_conformance =
13+
env::var("CARGO_BIN_EXE_conformance").expect("Cargo must provide path to build binaries");
2314

2415
let status = Command::new(conformance::test_runner())
2516
.arg("--enforce_recommended")

0 commit comments

Comments
 (0)