Skip to content

Commit

Permalink
added testing harness + aimless changing of line_numbers.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
DIvkov575 committed Mar 19, 2024
1 parent 8f79efe commit ed1149b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -27,7 +27,7 @@ harness = false
[[test]]
name = "line_numbers"
path = "tests/line_numbers.rs"
harness = false
harness = true

[[test]]
name = "macros"
Expand Down
9 changes: 4 additions & 5 deletions tests/line_numbers.rs
Expand Up @@ -20,9 +20,7 @@ struct State {
struct Logger(Arc<State>);

impl Log for Logger {
fn enabled(&self, _: &Metadata) -> bool {
true
}
fn enabled(&self, _: &Metadata) -> bool { true }

fn log(&self, record: &Record) {
*self.0.last_log.lock().unwrap() = record.line();
Expand All @@ -31,7 +29,7 @@ impl Log for Logger {
fn flush(&self) {}
}

#[cfg_attr(lib_build, test)]
#[test]
fn main() {
#[cfg(not(any(
feature = "max_level_off",
Expand All @@ -53,10 +51,11 @@ fn main() {
});
let state = default_state.clone();
set_boxed_logger(Box::new(Logger(default_state))).unwrap();

log::set_max_level(LevelFilter::Trace);

info!("");
check_line(&state, 58);
check_line(&state, 57);
}
fn check_line(state: &State, expected: u32) {
let line_number = state.last_log.lock().unwrap().take().unwrap();
Expand Down

0 comments on commit ed1149b

Please sign in to comment.