-
Notifications
You must be signed in to change notification settings - Fork 85
Open
Description
scarb/utils/scarb-test-support/src/cargo.rs
Lines 7 to 34 in 72dc1bd
| .or_else(|| env::var_os(format!("CARGO_BIN_EXE_{name}"))) | |
| .map(PathBuf::from) | |
| .unwrap_or_else(|| lookup_cargo_bin(name)) | |
| } | |
| /// Look up the path to a cargo-built binary within an integration test. | |
| /// | |
| /// Makes assumptions about Cargo. | |
| fn lookup_cargo_bin(name: &str) -> PathBuf { | |
| let file_name = format!("{}{}", name, std::env::consts::EXE_SUFFIX); | |
| let target_dir = target_dir(); | |
| target_dir.join(file_name) | |
| } | |
| // Adapted from | |
| // https://github.com/rust-lang/cargo/blob/485670b3983b52289a2f353d589c57fae2f60f82/tests/testsuite/support/mod.rs#L507 | |
| fn target_dir() -> PathBuf { | |
| env::current_exe() | |
| .ok() | |
| .map(|mut path| { | |
| path.pop(); | |
| if path.ends_with("deps") { | |
| path.pop(); | |
| } | |
| path | |
| }) | |
| .unwrap() | |
| } |
CARGO_BIN_EXE_is on available at compile time (i.e. you needenv!to read it)lookup_cargo_binrelies on implementation details of cargo that will soon break (Movebuild-dirout of the workspace tocargo-cache-homeby default rust-lang/cargo#16147, Re-organize build-dir by package + hash, rather than artifact type rust-lang/cargo#15010)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Triage