add mockrepo tests
All checks were successful
Gentoo Utils / build-oci-image (pull_request) Successful in 9s
Gentoo Utils / build (pull_request) Successful in 43s

This commit is contained in:
2025-12-12 04:15:12 +00:00
parent bcd15ac50e
commit e5e2c98e81
12 changed files with 74 additions and 0 deletions

View File

@@ -1 +1,7 @@
tests += {meson.current_source_dir() / 'read_all_profiles.rs': []} tests += {meson.current_source_dir() / 'read_all_profiles.rs': []}
tests += {
meson.current_source_dir() / 'read_mock_profile.rs': [
meson.current_source_dir() / 'mockrepo',
],
}

View File

@@ -0,0 +1 @@
USE="base"

View File

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

View File

@@ -0,0 +1 @@
..

View File

@@ -0,0 +1 @@
gui

View File

@@ -0,0 +1 @@
USE="emacs"

View File

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

View File

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

View File

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

View File

@@ -0,0 +1 @@
default

View File

@@ -0,0 +1 @@
mockrepo

View File

@@ -0,0 +1,58 @@
use std::env;
use gentoo_utils::{atom::Atom, repo::Repo, useflag::UseFlag};
use itertools::Itertools;
fn main() {
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("features/emacs/gui")
.expect("failed to evaluate profile");
assert_eq!(
profile.make_defaults()["USE"]
.split_ascii_whitespace()
.sorted()
.collect::<Vec<_>>(),
vec!["base", "emacs"]
);
assert_eq!(
profile
.packages()
.iter()
.map(Atom::to_string)
.collect::<Vec<_>>(),
vec!["app-editors/emacs"]
);
let emacs_package_use = profile
.package_use()
.iter()
.find_map(|(atom, flags)| {
if atom.clone().into_cp().to_string() == "app-editors/emacs" {
Some(flags)
} else {
None
}
})
.expect("failed to read package.use settings for app-editors/emacs");
assert_eq!(
emacs_package_use
.iter()
.map(UseFlag::to_string)
.collect::<Vec<_>>(),
vec!["default", "gui"]
);
assert_eq!(
profile
.use_force()
.iter()
.map(UseFlag::to_string)
.collect::<Vec<_>>(),
vec!["default", "gui"]
);
}