use std::path::{Path, PathBuf};
use test_binary::{build_test_binary, build_test_binary_once, TestBinary, TestBinaryError};
build_test_binary_once!(multiple, "testbins");
fn assert_path_end<R: AsRef<Path>>(actual: R, expected_ending: &str) {
assert!(actual.as_ref().ends_with(expected_ending))
}
#[test]
fn test_builds() {
let result = build_test_binary("does-build", "testbins");
assert_path_end(result.unwrap(), "does-build");
}
#[test]
fn test_release() {
let result = TestBinary::relative_to_parent(
"does-build",
&PathBuf::from_iter(["testbins", "does-build", "Cargo.toml"]),
)
.with_profile("release")
.build();
assert_path_end(result.unwrap(), "does-build");
}
#[test]
fn test_doesnt_build() {
let result = build_test_binary("doesnt-build", "testbins");
assert!(matches!(result, Err(TestBinaryError::BuildError(_))));
}
#[test]
fn test_doesnt_exist() {
let result = build_test_binary("doesnt-exist", "testbins");
assert!(matches!(result, Err(TestBinaryError::CargoFailure(_))));
}
#[test]
fn test_multiple_calls_1() {
let result = path_to_multiple();
assert_path_end(result, "multiple");
}
#[test]
fn test_multiple_calls_2() {
let result = path_to_multiple();
assert_path_end(result, "multiple");
}
#[test]
fn test_multiple_calls_3() {
let result = path_to_multiple();
assert_path_end(result, "multiple");
}
#[test]
fn test_multiple_calls_4() {
let result = path_to_multiple();
assert_path_end(result, "multiple");
}
#[test]
fn test_features() {
let result = TestBinary::relative_to_parent(
"feature-test",
&PathBuf::from_iter(["testbins", "feature-test", "Cargo.toml"]),
)
.no_default_features()
.with_feature("working")
.build();
assert_path_end(result.unwrap(), "feature-test");
}