2 use std
::env
::consts
::EXE_SUFFIX
;
3 use std
::path
::{Path, PathBuf}
;
5 /// Used by `cargo install` tests to assert an executable binary
6 /// has been installed. Example usage:
8 /// assert_has_installed_exe(cargo_home(), "foo");
10 pub fn assert_has_installed_exe
<P
: AsRef
<Path
>>(path
: P
, name
: &'
static str) {
11 assert
!(check_has_installed_exe(path
, name
));
15 pub fn assert_has_not_installed_exe
<P
: AsRef
<Path
>>(path
: P
, name
: &'
static str) {
16 assert
!(!check_has_installed_exe(path
, name
));
19 fn check_has_installed_exe
<P
: AsRef
<Path
>>(path
: P
, name
: &'
static str) -> bool
{
20 path
.as_ref().join("bin").join(exe(name
)).is_file()
23 pub fn cargo_home() -> PathBuf
{
24 paths
::home().join(".cargo")
27 pub fn exe(name
: &str) -> String
{
28 format
!("{}{}", name
, EXE_SUFFIX
)