-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathmod.rs
More file actions
45 lines (37 loc) · 1.58 KB
/
Copy pathmod.rs
File metadata and controls
45 lines (37 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Shared test utilities for tracker-client integration tests.
use std::path::PathBuf;
/// Resolves the path to the `tracker_client` binary for integration tests.
///
/// Resolution order:
/// 1. `NEXTEST_BIN_EXE_tracker_client` env var (set by cargo-nextest)
/// 2. `CARGO_BIN_EXE_tracker_client` env var (set by cargo test)
/// 3. Compile-time `CARGO_BIN_EXE_tracker_client` macro
/// 4. Sibling binary next to the test executable (fallback for non-standard runners)
#[must_use]
pub fn resolve_tracker_client_binary() -> PathBuf {
if let Some(path) = std::env::var_os("NEXTEST_BIN_EXE_tracker_client") {
return path.into();
}
if let Some(path) = std::env::var_os("CARGO_BIN_EXE_tracker_client") {
return path.into();
}
let compile_time_path = PathBuf::from(env!("CARGO_BIN_EXE_tracker_client"));
if compile_time_path.exists() {
return compile_time_path;
}
let current_exe = std::env::current_exe().expect("Failed to determine current test executable path");
let profile_dir = current_exe
.parent()
.and_then(std::path::Path::parent)
.expect("Failed to determine Cargo profile directory from test executable path");
let mut candidate = profile_dir.join("tracker_client");
if cfg!(windows) {
candidate.set_extension("exe");
}
if candidate.exists() {
return candidate;
}
panic!(
"Unable to locate tracker_client binary. Tried NEXTEST_BIN_EXE_tracker_client, CARGO_BIN_EXE_tracker_client, compile-time CARGO_BIN_EXE_tracker_client, and sibling binary near test executable"
);
}