Skip to content

Commit

Permalink
fix: various test lints etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshka committed Nov 14, 2024
1 parent 1b1eb91 commit 8fd3009
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ tracing-subscriber = "0.3"
[lints]
workspace = true

[[example]]
name = "log"
required-features = ["log"]

[[example]]
name = "tracing"
required-features = ["tracing"]
32 changes: 30 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl Filter {
2 => Filter::Warn,
3 => Filter::Info,
4 => Filter::Debug,
5.. => Filter::Trace,
_ => Filter::Trace,
}
}
}
Expand Down Expand Up @@ -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)]
Expand All @@ -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<InfoLevel>,
}

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<tracing::ErrorLevel>,
}

use clap::CommandFactory;
Cli::command().debug_assert();
}
}

0 comments on commit 8fd3009

Please sign in to comment.