cargo/tests/cargotest/install.rs
Alex Crichton 763ba535eb Shared the test suite into multiple binaries
Compiling everything in one binary was getting annoying as it just took forever
to build, instead shard it all up so we can build just particular test suites at
a time.
2016-05-25 21:25:13 -07:00

31 lines
752 B
Rust

use std::fmt;
use std::path::{PathBuf, Path};
use hamcrest::{Matcher, MatchResult, existing_file};
use support::paths;
pub use self::InstalledExe as has_installed_exe;
pub fn cargo_home() -> PathBuf {
paths::home().join(".cargo")
}
pub struct InstalledExe(pub &'static str);
fn exe(name: &str) -> String {
if cfg!(windows) {format!("{}.exe", name)} else {name.to_string()}
}
impl<P: AsRef<Path>> Matcher<P> for InstalledExe {
fn matches(&self, path: P) -> MatchResult {
let path = path.as_ref().join("bin").join(exe(self.0));
existing_file().matches(&path)
}
}
impl fmt::Display for InstalledExe {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "installed exe `{}`", self.0)
}
}