fix: honor PATH when resolving Cross
Rust CI Cargo tests, coverage, and badge generation passed.
Gitea/rust_realease/pipeline/head This commit looks good
Details
Rust CI Cargo tests, coverage, and badge generation passed.
Gitea/rust_realease/pipeline/head This commit looks good
Details
This commit is contained in:
parent
685b6f6865
commit
131d1fa8dc
20
src/build.rs
20
src/build.rs
|
|
@ -101,9 +101,11 @@ fn cross_program() -> Option<&'static str> {
|
|||
}
|
||||
|
||||
fn cross_program_in(path: &std::ffi::OsStr) -> Option<&'static str> {
|
||||
["cross", "cargo-cross"]
|
||||
.into_iter()
|
||||
.find(|name| executable_in(name, path).is_some())
|
||||
env::split_paths(path).find_map(|directory| {
|
||||
["cross", "cargo-cross"]
|
||||
.into_iter()
|
||||
.find(|name| directory.join(name).is_file())
|
||||
})
|
||||
}
|
||||
|
||||
fn validate_cross_config(root: &Path) -> Result<(), Error> {
|
||||
|
|
@ -397,14 +399,16 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn cross_command_falls_back_to_cargo_cross() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let path = env::join_paths([temp.path()]).unwrap();
|
||||
fn cross_command_honors_path_order_and_falls_back_to_cargo_cross() {
|
||||
let first = tempfile::tempdir().unwrap();
|
||||
let later = tempfile::tempdir().unwrap();
|
||||
let path = env::join_paths([first.path(), later.path()]).unwrap();
|
||||
|
||||
fs::write(temp.path().join("cargo-cross"), "").unwrap();
|
||||
fs::write(first.path().join("cargo-cross"), "").unwrap();
|
||||
fs::write(later.path().join("cross"), "").unwrap();
|
||||
assert_eq!(cross_program_in(&path), Some("cargo-cross"));
|
||||
|
||||
fs::write(temp.path().join("cross"), "").unwrap();
|
||||
fs::write(first.path().join("cross"), "").unwrap();
|
||||
assert_eq!(cross_program_in(&path), Some("cross"));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue