From 8fd3009128ce2ff535557358916f0a374db523bc Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Thu, 14 Nov 2024 00:05:29 -0800 Subject: [PATCH] fix: various test lints etc. --- Cargo.toml | 4 ++++ src/lib.rs | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 23b3b14..63f9787 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -132,6 +132,10 @@ tracing-subscriber = "0.3" [lints] workspace = true +[[example]] +name = "log" +required-features = ["log"] + [[example]] name = "tracing" required-features = ["tracing"] diff --git a/src/lib.rs b/src/lib.rs index c615862..83dfc19 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -215,7 +215,7 @@ impl Filter { 2 => Filter::Warn, 3 => Filter::Info, 4 => Filter::Debug, - 5.. => Filter::Trace, + _ => Filter::Trace, } } } @@ -275,10 +275,12 @@ pub trait LogLevel { #[cfg(test)] mod test { + #[allow(unused_imports)] use super::*; #[test] - fn verify_app() { + #[cfg(feature = "log")] + fn default_verbosity() { #[derive(Debug, clap::Parser)] struct Cli { #[command(flatten)] @@ -288,4 +290,30 @@ mod test { use clap::CommandFactory; Cli::command().debug_assert(); } + + #[test] + #[cfg(feature = "log")] + fn verbosity_with_log() { + #[derive(Debug, clap::Parser)] + struct Cli { + #[command(flatten)] + verbose: Verbosity, + } + + use clap::CommandFactory; + Cli::command().debug_assert(); + } + + #[test] + #[cfg(feature = "tracing")] + fn verbosity_with_tracing() { + #[derive(Debug, clap::Parser)] + struct Cli { + #[command(flatten)] + verbose: Verbosity, + } + + use clap::CommandFactory; + Cli::command().debug_assert(); + } }