test: hide local tests behind ff

This commit is contained in:
Paul Delafosse 2025-01-23 11:09:45 +01:00
parent 8470bb3183
commit 2147fc7b98
No known key found for this signature in database
GPG key ID: BE7DF2A0DC126E7C
4 changed files with 13 additions and 11 deletions

View file

@ -24,6 +24,10 @@ linicon = "2.3.0"
gtk4 = "0.4.7"
criterion = "0.3.5"
[features]
default = []
local_tests = []
[[bench]]
name = "simple_lookup"
harness = false

View file

@ -63,7 +63,7 @@ mod theme;
/// Return the list of installed themes on the system
///
/// ## Example
/// ```rust
/// ```rust,no_run
/// # fn main() {
/// use freedesktop_icons::list_themes;
///
@ -92,7 +92,7 @@ pub fn list_themes() -> Vec<&'static str> {
/// Return the default GTK theme if set.
///
/// ## Example
/// ```rust
/// ```rust, no_run
/// use freedesktop_icons::default_theme_gtk;
///
/// let theme = default_theme_gtk();
@ -259,11 +259,8 @@ impl<'a> LookupBuilder<'a> {
// If the icon was previously search but not found, we return
// `None` early, otherwise, attempt to perform a lookup
if self.cache {
match self.cache_lookup(self.theme) {
CacheEntry::Found(icon) => {
return Some(icon);
}
_ => {}
if let CacheEntry::Found(icon) = self.cache_lookup(self.theme) {
return Some(icon);
};
}
@ -344,6 +341,7 @@ impl<'a> LookupBuilder<'a> {
// WARNING: these test are highly dependent on your installed icon-themes.
// If you want to run them, make sure you have 'Papirus' and 'Arc' icon-themes installed.
#[cfg(test)]
#[cfg(feature = "local_tests")]
mod test {
use crate::{lookup, CacheEntry, CACHE};
use speculoos::prelude::*;
@ -383,7 +381,7 @@ mod test {
.that(&icon)
.is_some()
.is_equal_to(PathBuf::from(
"/usr/share/icons/Adwaita/scalable/devices/video-single-display-symbolic.svg",
"/usr/share/icons/Adwaita/symbolic/devices/video-single-display-symbolic.svg",
));
}

View file

@ -14,7 +14,7 @@ mod paths;
type Result<T> = std::result::Result<T, ThemeError>;
pub static THEMES: Lazy<BTreeMap<String, Vec<Theme>>> = Lazy::new(|| get_all_themes());
pub static THEMES: Lazy<BTreeMap<String, Vec<Theme>>> = Lazy::new(get_all_themes);
pub struct Theme {
pub path: ThemePath,

View file

@ -55,7 +55,7 @@ mod test {
#[test]
fn should_get_all_themes() {
let themes = get_all_themes().unwrap();
let themes = get_all_themes();
assert_that!(themes.get("hicolor")).is_some();
}
@ -67,7 +67,7 @@ mod test {
#[test]
fn should_read_theme_index() -> Result<()> {
let themes = get_all_themes()?;
let themes = get_all_themes();
let themes: Vec<&Theme> = themes.values().flatten().collect();
assert_that!(themes).is_not_empty();
Ok(())