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 utils;
20pub mod xywh;
21
22pub const VERSION: &str = env!("CARGO_PKG_VERSION");
23
24use include_dir::{Dir, include_dir};
25pub static THEME_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/themes");
26
27#[macro_use]
28extern crate log;
29
30#[cfg(test)]
31mod tests {
32    use std::{ffi::OsStr, path::PathBuf};
33
34    use crate::config::v2::tui::theme::ThemeColors;
35
36    /// Test that all themes in /lib/themes/ can be loaded
37    #[test]
38    fn should_parse_all_themes() {
39        let cargo_manifest_dir = env!("CARGO_MANIFEST_DIR");
40        let path = PathBuf::from(format!("{cargo_manifest_dir}/themes/"));
41        for entry in path.read_dir().unwrap() {
42            let entry = entry.unwrap();
43            let entry_path = entry.path();
44
45            if entry_path.extension() != Some(OsStr::new("yml")) {
46                continue;
47            }
48
49            println!(
50                "Theme: {}",
51                entry_path.file_name().unwrap().to_string_lossy()
52            );
53
54            let actual_theme = ThemeColors::from_yaml_file(&entry_path).unwrap();
55
56            assert!(actual_theme.file_name.is_some_and(|v| !v.is_empty()));
57        }
58    }
59}