2 Commits

Author SHA1 Message Date
f279e07367 add package.mask entry to mock repo
All checks were successful
Gentoo Utils / build-oci-image (pull_request) Successful in 5s
Gentoo Utils / build (pull_request) Successful in 1m35s
2025-12-13 03:01:07 +00:00
ea2aa940ea add mockrepo tests
All checks were successful
Gentoo Utils / build-oci-image (pull_request) Successful in 8s
Gentoo Utils / build (pull_request) Successful in 37s
2025-12-12 04:48:30 +00:00
10 changed files with 43 additions and 57 deletions

View File

@@ -1 +0,0 @@
base

View File

@@ -0,0 +1 @@
../../base

View File

@@ -1,2 +0,0 @@
USE="selinux"
SELINUX_TYPE="sys.subj.portage"

View File

@@ -1 +0,0 @@
*sec-policy/selinux-base

View File

@@ -1 +0,0 @@
app-editors/emacs -default

View File

@@ -1,3 +0,0 @@
../base
../features/selinux
../features/emacs/gui

View File

@@ -1,46 +1,42 @@
use std::env::args;
use std::env;
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 repo_path = env::args().nth(1).expect("expected path to mock repo");
let repo = Repo::new(&repo_path).expect("failed to open repo");
let profile = repo
.evaluate_profile("gentoo-desktop")
.evaluate_profile("features/emacs/gui")
.expect("failed to evaluate profile");
let r#use = profile.make_defaults()["USE"]
.split_ascii_whitespace()
.sorted()
.collect::<Vec<_>>();
assert_eq!(r#use, vec!["base", "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"]
profile.make_defaults()["USE"]
.split_ascii_whitespace()
.sorted()
.collect::<Vec<_>>(),
vec!["base", "emacs"]
);
let packages_mask = profile
.package_mask()
.iter()
.map(Atom::to_string)
.sorted()
.collect::<Vec<_>>();
assert_eq!(
profile
.packages()
.iter()
.map(Atom::to_string)
.collect::<Vec<_>>(),
vec!["app-editors/emacs"]
);
assert_eq!(packages_mask, vec!["app-editors/vim"]);
assert_eq!(
profile
.package_mask()
.iter()
.map(Atom::to_string)
.collect::<Vec<_>>(),
vec!["app-editors/vim"]
);
let emacs_use = profile
let emacs_package_use = profile
.package_use()
.iter()
.find_map(|(atom, flags)| {
@@ -50,22 +46,22 @@ fn main() {
None
}
})
.unwrap()
.iter()
.map(UseFlag::to_string)
.sorted()
.collect::<Vec<_>>();
.expect("failed to read package.use settings for app-editors/emacs");
assert_eq!(emacs_use, vec!["gui"]);
assert_eq!(
emacs_package_use
.iter()
.map(UseFlag::to_string)
.collect::<Vec<_>>(),
vec!["default", "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());
assert_eq!(
profile
.use_force()
.iter()
.map(UseFlag::to_string)
.collect::<Vec<_>>(),
vec!["default", "gui"]
);
}