Skip to content

Commit

Permalink
added line_numbers test to cargo.toml and lib.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
DIvkov575 committed Mar 19, 2024
1 parent cffcd66 commit d94009e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Expand Up @@ -24,6 +24,11 @@ name = "filters"
path = "tests/filters.rs"
harness = false

[[test]]
name = "line_numbers"
path = "tests/line_numbers.rs"
harness = true

[[test]]
name = "macros"
path = "tests/macros.rs"
Expand Down
8 changes: 3 additions & 5 deletions tests/line_numbers.rs
Expand Up @@ -2,11 +2,11 @@

#![allow(dead_code, unused_imports)]

use log::{info, LevelFilter, Log, Metadata, Record};
use std::sync::{Arc, Mutex};

#[cfg(feature = "std")]
use log::set_boxed_logger;
use log::{info, LevelFilter, Log, Metadata, Record};

#[cfg(not(feature = "std"))]
fn set_boxed_logger(logger: Box<dyn Log>) -> Result<(), log::SetLoggerError> {
Expand All @@ -32,9 +32,7 @@ impl Log for Logger {
}

#[test]
fn line_number() {
// These tests don't really make sense when static
// max level filtering is applied
fn line_numbers() {
#[cfg(not(any(
feature = "max_level_off",
feature = "max_level_error",
Expand All @@ -58,7 +56,7 @@ fn line_number() {
log::set_max_level(LevelFilter::Trace);

info!("");
check_line(&state, 60);
check_line(&state, 58);
}
fn check_line(state: &State, expected: u32) {
let line_number = state.last_log.lock().unwrap().take().unwrap();
Expand Down
1 change: 0 additions & 1 deletion tests/src/lib.rs
Expand Up @@ -13,7 +13,6 @@ mod filters;
#[path = "../macros.rs"]
mod macros;


#[cfg(test)]
#[path = "../line_numbers.rs"]
mod line_numbers;

0 comments on commit d94009e

Please sign in to comment.