Skip to content

Commit 77ce75c

Browse files
authored
Avoid unreliable assert_cmd::cargo::cargo_bin (#2489)
assert-rs/assert_cmd#257
1 parent 6002f6e commit 77ce75c

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

tests/dist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn basic_compile(tmpdir: &Path, sccache_cfg_path: &Path, sccache_cached_cfg_path
5454
}
5555

5656
fn rust_compile(tmpdir: &Path, sccache_cfg_path: &Path, sccache_cached_cfg_path: &Path) -> Output {
57-
let sccache_path = assert_cmd::cargo::cargo_bin("sccache").into_os_string();
57+
let sccache_path = env!("CARGO_BIN_EXE_sccache");
5858
let envs: Vec<(_, &OsStr)> = vec![
5959
("RUSTC_WRAPPER", sccache_path.as_ref()),
6060
("CARGO_TARGET_DIR", "target".as_ref()),

tests/harness/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ pub fn prune_command(mut cmd: Command) -> Command {
140140
}
141141

142142
pub fn sccache_command() -> Command {
143-
prune_command(Command::new(assert_cmd::cargo::cargo_bin("sccache")))
143+
prune_command(Command::new(env!("CARGO_BIN_EXE_sccache")))
144144
}
145145

146146
pub fn cargo_command() -> Command {
@@ -149,7 +149,7 @@ pub fn cargo_command() -> Command {
149149

150150
#[cfg(feature = "dist-server")]
151151
pub fn sccache_dist_path() -> PathBuf {
152-
assert_cmd::cargo::cargo_bin("sccache-dist")
152+
env!("CARGO_BIN_EXE_sccache-dist").into()
153153
}
154154

155155
pub fn sccache_client_cfg(

tests/helpers/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ use std::process::{Command, Stdio};
1515
pub static CRATE_DIR: Lazy<PathBuf> =
1616
Lazy::new(|| Path::new(file!()).parent().unwrap().join("../test-crate"));
1717
pub static CARGO: Lazy<OsString> = Lazy::new(|| std::env::var_os("CARGO").unwrap());
18-
pub static SCCACHE_BIN: Lazy<PathBuf> = Lazy::new(|| assert_cmd::cargo::cargo_bin("sccache"));
18+
pub static SCCACHE_BIN: Lazy<&Path> = Lazy::new(|| Path::new(env!("CARGO_BIN_EXE_sccache")));
19+
1920
/// Ensures the logger is only initialized once. Panics if initialization fails.
2021
static LOGGER: Lazy<Result<(), Infallible>> = Lazy::new(|| {
2122
env_logger::Builder::new()

tests/oauth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn config_with_dist_auth(
6464
}
6565

6666
fn sccache_command() -> Command {
67-
Command::new(assert_cmd::cargo::cargo_bin("sccache"))
67+
Command::new(env!("CARGO_BIN_EXE_sccache"))
6868
}
6969

7070
fn retry<F: FnMut() -> Option<T>, T>(interval: Duration, until: Duration, mut f: F) -> Option<T> {

tests/sccache_rustc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ use std::{
1818
struct StopServer;
1919
impl Drop for StopServer {
2020
fn drop(&mut self) {
21-
let _ = Command::cargo_bin("sccache")
22-
.unwrap()
21+
let _ = Command::from_std(std::process::Command::new(env!("CARGO_BIN_EXE_sccache")))
2322
.arg("--stop-server")
2423
.ok();
2524
}

0 commit comments

Comments
 (0)