Files
gentoo-utils-gitea/tests/profile/read_mock_profile.rs
John Turner 789a68ff36
Some checks failed
Gentoo Utils / build-oci-image (push) Successful in 10s
Gentoo Utils / grep (push) Failing after 2m2s
Gentoo Utils / check-format (push) Failing after 2m6s
Gentoo Utils / docs (push) Failing after 2m5s
Gentoo Utils / build (push) Failing after 5s
Gentoo Utils / test (push) Has been skipped
Gentoo Utils / fuzz (push) Has been skipped
read arch.list
2025-12-22 08:47:09 +00:00

90 lines
2.1 KiB
Rust

use std::env::args;
use gentoo_utils::{atom::Atom, repo::Repo, useflag::UseFlag};
use itertools::Itertools;
fn main() {
let repo_path = args()
.nth(1)
.expect("expected path to mockrepo as first argument");
let repo = Repo::new(&repo_path).expect("failed to read repo");
let global_package_mask = repo
.package_mask()
.iter()
.map(Atom::to_string)
.sorted()
.collect::<Vec<_>>();
assert_eq!(global_package_mask, vec!["app-editors/vim"]);
assert_eq!(
repo.arch_list()
.iter()
.map(|arch| arch.get())
.collect::<Vec<_>>(),
vec!["amd64", "aarch64"]
);
let profile = repo
.evaluate_profile("gentoo-desktop")
.expect("failed to evaluate profile");
let r#use = profile.make_defaults()["USE"]
.split_ascii_whitespace()
.sorted()
.collect::<Vec<_>>();
assert_eq!(r#use, vec!["emacs", "selinux",]);
let packages = profile
.packages()
.iter()
.map(Atom::to_string)
.sorted()
.collect::<Vec<_>>();
assert_eq!(
packages,
vec!["app-editors/emacs", "sec-policy/selinux-base"]
);
let packages_mask = profile
.package_mask()
.iter()
.map(Atom::to_string)
.sorted()
.collect::<Vec<_>>();
assert_eq!(packages_mask, vec!["app-editors/vim"]);
let emacs_use = profile
.package_use()
.iter()
.find_map(|(atom, flags)| {
if atom.clone().into_cp().to_string() == "app-editors/emacs" {
Some(flags)
} else {
None
}
})
.unwrap()
.iter()
.map(UseFlag::to_string)
.sorted()
.collect::<Vec<_>>();
assert_eq!(emacs_use, vec!["gui"]);
let use_force = profile
.use_force()
.iter()
.map(UseFlag::to_string)
.sorted()
.collect::<Vec<_>>();
assert_eq!(use_force, vec!["base", "caps", "default", "gui"]);
assert!(profile.use_mask().is_empty());
}