Get a command to run the given tool with Cargo
(name: &'static str)
| 36 | |
| 37 | /// Get a command to run the given tool with Cargo |
| 38 | pub fn tool(name: &'static str) -> Command { |
| 39 | // XXX: Using nextest somewhat defeats this cache, because it runs each test in a separate |
| 40 | // process, so the cache has to be rebuilt each time. But having it at least makes me feel |
| 41 | // like I tried :/ |
| 42 | static TOOL_PATH_CACHE: LazyLock<Mutex<HashMap<&'static str, PathBuf>>> = |
| 43 | LazyLock::new(|| Mutex::new(HashMap::new())); |
| 44 | |
| 45 | let mut cache = TOOL_PATH_CACHE.lock().unwrap(); |
| 46 | // assert_cmd::cargo::cargo_bin is deprecated but cargo_bin! requires string literal, not &'static str |
| 47 | #[allow(deprecated)] |
| 48 | let path = cache |
| 49 | .entry(name) |
| 50 | // TODO: Support the various Python tools as well |
| 51 | .or_insert_with(|| assert_cmd::cargo::cargo_bin(name)); |
| 52 | |
| 53 | let mut cmd = Command::new(path); |
| 54 | cmd.arg("--log-level=TRACE"); |
| 55 | cmd |
| 56 | } |
no outgoing calls