add mockrepo tests
This commit is contained in:
@@ -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',
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
1
tests/profile/mockrepo/profiles/base/make.defaults
Normal file
1
tests/profile/mockrepo/profiles/base/make.defaults
Normal file
@@ -0,0 +1 @@
|
|||||||
|
USE="base"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
app-editors/emacs gui
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
..
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
gui
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
USE="emacs"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
app-editors/emacs default
|
||||||
1
tests/profile/mockrepo/profiles/features/emacs/packages
Normal file
1
tests/profile/mockrepo/profiles/features/emacs/packages
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*app-editors/emacs
|
||||||
1
tests/profile/mockrepo/profiles/features/emacs/parent
Normal file
1
tests/profile/mockrepo/profiles/features/emacs/parent
Normal file
@@ -0,0 +1 @@
|
|||||||
|
../../base
|
||||||
1
tests/profile/mockrepo/profiles/features/emacs/use.force
Normal file
1
tests/profile/mockrepo/profiles/features/emacs/use.force
Normal file
@@ -0,0 +1 @@
|
|||||||
|
default
|
||||||
1
tests/profile/mockrepo/profiles/repo_name
Normal file
1
tests/profile/mockrepo/profiles/repo_name
Normal file
@@ -0,0 +1 @@
|
|||||||
|
mockrepo
|
||||||
58
tests/profile/read_mock_profile.rs
Normal file
58
tests/profile/read_mock_profile.rs
Normal 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"]
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user