test: hide local tests behind ff
This commit is contained in:
parent
8470bb3183
commit
2147fc7b98
4 changed files with 13 additions and 11 deletions
|
|
@ -24,6 +24,10 @@ linicon = "2.3.0"
|
||||||
gtk4 = "0.4.7"
|
gtk4 = "0.4.7"
|
||||||
criterion = "0.3.5"
|
criterion = "0.3.5"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
local_tests = []
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "simple_lookup"
|
name = "simple_lookup"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
|
||||||
14
src/lib.rs
14
src/lib.rs
|
|
@ -63,7 +63,7 @@ mod theme;
|
||||||
/// Return the list of installed themes on the system
|
/// Return the list of installed themes on the system
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```rust
|
/// ```rust,no_run
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
/// use freedesktop_icons::list_themes;
|
/// use freedesktop_icons::list_themes;
|
||||||
///
|
///
|
||||||
|
|
@ -92,7 +92,7 @@ pub fn list_themes() -> Vec<&'static str> {
|
||||||
/// Return the default GTK theme if set.
|
/// Return the default GTK theme if set.
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```rust
|
/// ```rust, no_run
|
||||||
/// use freedesktop_icons::default_theme_gtk;
|
/// use freedesktop_icons::default_theme_gtk;
|
||||||
///
|
///
|
||||||
/// let theme = 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
|
// If the icon was previously search but not found, we return
|
||||||
// `None` early, otherwise, attempt to perform a lookup
|
// `None` early, otherwise, attempt to perform a lookup
|
||||||
if self.cache {
|
if self.cache {
|
||||||
match self.cache_lookup(self.theme) {
|
if let CacheEntry::Found(icon) = self.cache_lookup(self.theme) {
|
||||||
CacheEntry::Found(icon) => {
|
return Some(icon);
|
||||||
return Some(icon);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -344,6 +341,7 @@ impl<'a> LookupBuilder<'a> {
|
||||||
// WARNING: these test are highly dependent on your installed icon-themes.
|
// 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.
|
// If you want to run them, make sure you have 'Papirus' and 'Arc' icon-themes installed.
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[cfg(feature = "local_tests")]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::{lookup, CacheEntry, CACHE};
|
use crate::{lookup, CacheEntry, CACHE};
|
||||||
use speculoos::prelude::*;
|
use speculoos::prelude::*;
|
||||||
|
|
@ -383,7 +381,7 @@ mod test {
|
||||||
.that(&icon)
|
.that(&icon)
|
||||||
.is_some()
|
.is_some()
|
||||||
.is_equal_to(PathBuf::from(
|
.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",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ mod paths;
|
||||||
|
|
||||||
type Result<T> = std::result::Result<T, ThemeError>;
|
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 struct Theme {
|
||||||
pub path: ThemePath,
|
pub path: ThemePath,
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_get_all_themes() {
|
fn should_get_all_themes() {
|
||||||
let themes = get_all_themes().unwrap();
|
let themes = get_all_themes();
|
||||||
assert_that!(themes.get("hicolor")).is_some();
|
assert_that!(themes.get("hicolor")).is_some();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_read_theme_index() -> Result<()> {
|
fn should_read_theme_index() -> Result<()> {
|
||||||
let themes = get_all_themes()?;
|
let themes = get_all_themes();
|
||||||
let themes: Vec<&Theme> = themes.values().flatten().collect();
|
let themes: Vec<&Theme> = themes.values().flatten().collect();
|
||||||
assert_that!(themes).is_not_empty();
|
assert_that!(themes).is_not_empty();
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue