Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
rustup update ${{ matrix.rust }} --no-self-update
rustup default ${{ matrix.rust }}
- run: cargo test --verbose
- run: cargo test --verbose --no-default-features
- run: cargo test --verbose --all-features
- run: cargo test --verbose --features serde
- run: cargo test --verbose --features std
- run: cargo test --verbose --features kv_unstable
Expand Down
42 changes: 31 additions & 11 deletions tests/filters.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(dead_code, unused_imports)]

#[cfg(not(lib_build))]
#[macro_use]
extern crate log;
Expand Down Expand Up @@ -32,18 +34,36 @@ impl Log for Logger {

#[cfg_attr(lib_build, test)]
fn main() {
let me = Arc::new(State {
last_log: Mutex::new(None),
});
let a = me.clone();
set_boxed_logger(Box::new(Logger(me))).unwrap();
// These tests don't really make sense when static
// max level filtering is applied
#[cfg(not(any(
feature = "max_level_off",
feature = "max_level_error",
feature = "max_level_warn",
feature = "max_level_info",
feature = "max_level_debug",
feature = "max_level_trace",
feature = "max_level_off",
feature = "max_level_error",
feature = "max_level_warn",
feature = "max_level_info",
feature = "max_level_debug",
feature = "max_level_trace",
)))]
{
let me = Arc::new(State {
last_log: Mutex::new(None),
});
let a = me.clone();
set_boxed_logger(Box::new(Logger(me))).unwrap();

test(&a, LevelFilter::Off);
test(&a, LevelFilter::Error);
test(&a, LevelFilter::Warn);
test(&a, LevelFilter::Info);
test(&a, LevelFilter::Debug);
test(&a, LevelFilter::Trace);
test(&a, LevelFilter::Off);
test(&a, LevelFilter::Error);
test(&a, LevelFilter::Warn);
test(&a, LevelFilter::Info);
test(&a, LevelFilter::Debug);
test(&a, LevelFilter::Trace);
}
}

fn test(a: &State, filter: LevelFilter) {
Expand Down