termusiclib/
lib.rs

1#![forbid(unsafe_code)]
2#![recursion_limit = "2048"]
3#![warn(clippy::all, clippy::correctness)]
4#![warn(rust_2018_idioms)]
5#![warn(clippy::pedantic)]
6// TODO: work to remove the following lints
7#![allow(clippy::missing_errors_doc)]
8
9pub mod common;
10pub mod config;
11pub mod invidious;
12pub mod new_database;
13pub mod player;
14pub mod playlist;
15pub mod podcast;
16pub mod songtag;
17pub mod taskpool;
18pub mod track;
19pub mod ueberzug;
20pub mod utils;
21pub mod xywh;
22
23pub const VERSION: &str = env!("CARGO_PKG_VERSION");
24
25use include_dir::{Dir, include_dir};
26pub static THEME_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/themes");
27
28#[macro_use]
29extern crate log;
30
31#[cfg(test)]
32mod tests {
33    use std::{ffi::OsStr, path::PathBuf};
34
35    use crate::config::v2::tui::theme::ThemeColors;
36
37    /// Test that all themes in /lib/themes/ can be loaded
38    #[test]
39    fn should_parse_all_themes() {
40        let cargo_manifest_dir = env!("CARGO_MANIFEST_DIR");
41        let path = PathBuf::from(format!("{cargo_manifest_dir}/themes/"));
42        for entry in path.read_dir().unwrap() {
43            let entry = entry.unwrap();
44            let entry_path = entry.path();
45
46            if entry_path.extension() != Some(OsStr::new("yml")) {
47                continue;
48            }
49
50            println!(
51                "Theme: {}",
52                entry_path.file_name().unwrap().to_string_lossy()
53            );
54
55            let actual_theme = ThemeColors::from_yaml_file(&entry_path).unwrap();
56
57            assert!(actual_theme.file_name.is_some_and(|v| !v.is_empty()));
58        }
59    }
60}