use super :: *;
use assert_fs ::prelude :: *;
fn arrange(source: &str) -> assert_fs ::TempDir
{
let root_path = std ::path ::Path ::new(env!("CARGO_MANIFEST_DIR"));
let assets_relative_path = std ::path ::Path ::new(ASSET_PATH);
let assets_path = root_path.join(assets_relative_path);
let temp = assert_fs ::TempDir ::new().unwrap();
temp.copy_from(assets_path.join(source), &[ "**"]).unwrap();
temp
}
#[ test ]
fn package_no_features()
{
let temp = arrange("three_packages/b");
let options = willbe ::action ::features ::FeaturesOptions ::former()
.crate_dir(willbe ::CrateDir ::try_from(temp.path().to_owned()).unwrap())
.form();
let report = willbe ::action ::features ::orphan ::features(options).unwrap().to_string();
assert!(report.contains("Package _three_packages_b : "));
}
#[ test ]
fn package_features()
{
let temp = arrange("three_packages_with_features/b");
let options = willbe ::action ::features ::FeaturesOptions ::former()
.crate_dir(willbe ::CrateDir ::try_from(temp.path().to_owned()).unwrap())
.form();
let report = willbe ::action ::features ::orphan ::features(options).unwrap().to_string();
assert!(report.contains("Package _three_packages_with_features_b : "));
assert!(report.contains("\t_three_packages_with_features_c"));
assert!(report.contains("\tboo"));
assert!(report.contains("\tdefault"));
assert!(report.contains("\tenabled"));
}
#[ test ]
fn package_features_with_features_deps()
{
let temp = arrange("three_packages_with_features/b");
let options = willbe ::action ::features ::FeaturesOptions ::former()
.crate_dir(willbe ::CrateDir ::try_from(temp.path().to_owned()).unwrap())
.with_features_deps(true)
.form();
let report = willbe ::action ::features ::orphan ::features(options).unwrap().to_string();
assert!(report.contains("Package _three_packages_with_features_b : "));
assert!(report.contains("\t_three_packages_with_features_c : [dep:_three_packages_with_features_c]"));
assert!(report.contains("\tboo : [_three_packages_with_features_c]"));
assert!(report.contains("\tdefault : [boo]"));
assert!(report.contains("\tenabled : []"));
}
#[ test ]
fn workspace_no_features()
{
let temp = arrange("three_packages");
let options = willbe ::action ::features ::FeaturesOptions ::former()
.crate_dir(willbe ::CrateDir ::try_from(temp.path().to_owned()).unwrap())
.form();
let report = willbe ::action ::features ::orphan ::features(options).unwrap().to_string();
assert!(report.contains(
"\
Package _three_packages_b : \
"
));
assert!(report.contains(
"\
Package _three_packages_c : \
"
));
assert!(report.contains(
"\
Package _three_packages_d : \
"
));
}
#[ test ]
fn workspace_features()
{
let temp = arrange("three_packages_with_features");
let options = willbe ::action ::features ::FeaturesOptions ::former()
.crate_dir(willbe ::CrateDir ::try_from(temp.path().to_owned()).unwrap())
.form();
let report = willbe ::action ::features ::orphan ::features(options).unwrap().to_string();
assert!(report.contains("Package _three_packages_with_features_b : "));
assert!(report.contains("\t_three_packages_with_features_c"));
assert!(report.contains("\tboo"));
assert!(report.contains("\tdefault"));
assert!(report.contains("\tenabled"));
assert!(report.contains("Package _three_packages_with_features_c : "));
assert!(report.contains("\tdefault"));
assert!(report.contains("\tenabled"));
assert!(report.contains("\tfoo"));
assert!(report.contains("Package _three_packages_with_features_d : "));
assert!(report.contains("\tenabled"));
}
#[ test ]
fn workspace_features_with_features_deps()
{
let temp = arrange("three_packages_with_features");
let options = willbe ::action ::features ::FeaturesOptions ::former()
.crate_dir(willbe ::CrateDir ::try_from(temp.path().to_owned()).unwrap())
.with_features_deps(true)
.form();
let report = willbe ::action ::features ::orphan ::features(options).unwrap().to_string();
assert!(report.contains("Package _three_packages_with_features_b : "));
assert!(report.contains("\t_three_packages_with_features_c : [dep:_three_packages_with_features_c]"));
assert!(report.contains("\tboo : [_three_packages_with_features_c]"));
assert!(report.contains("\tdefault : [boo]"));
assert!(report.contains("\tenabled : []"));
assert!(report.contains("Package _three_packages_with_features_c : "));
assert!(report.contains("\tdefault : [foo]"));
assert!(report.contains("\tenabled : []"));
assert!(report.contains("\tfoo : []"));
assert!(report.contains("Package _three_packages_with_features_d : "));
assert!(report.contains("\tenabled : []"));
}