Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

101
vendor/log/tests/integration.rs vendored Normal file
View File

@@ -0,0 +1,101 @@
#![allow(dead_code, unused_imports)]
use log::{debug, error, info, trace, warn, Level, LevelFilter, Log, Metadata, Record};
use std::sync::{Arc, Mutex};
struct State {
last_log_level: Mutex<Option<Level>>,
last_log_location: Mutex<Option<u32>>,
}
struct Logger(Arc<State>);
impl Log for Logger {
fn enabled(&self, _: &Metadata) -> bool {
true
}
fn log(&self, record: &Record) {
*self.0.last_log_level.lock().unwrap() = Some(record.level());
*self.0.last_log_location.lock().unwrap() = record.line();
}
fn flush(&self) {}
}
#[test]
fn test_integration() {
// 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 = "release_max_level_off",
feature = "release_max_level_error",
feature = "release_max_level_warn",
feature = "release_max_level_info",
feature = "release_max_level_debug",
feature = "release_max_level_trace",
)))]
{
let me = Arc::new(State {
last_log_level: Mutex::new(None),
last_log_location: Mutex::new(None),
});
let a = me.clone();
let logger = Logger(me);
test_filter(&logger, &a, LevelFilter::Off);
test_filter(&logger, &a, LevelFilter::Error);
test_filter(&logger, &a, LevelFilter::Warn);
test_filter(&logger, &a, LevelFilter::Info);
test_filter(&logger, &a, LevelFilter::Debug);
test_filter(&logger, &a, LevelFilter::Trace);
test_line_numbers(&logger, &a);
}
}
fn test_filter(logger: &dyn Log, a: &State, filter: LevelFilter) {
// tests to ensure logs with a level beneath 'max_level' are filtered out
log::set_max_level(filter);
error!(logger: logger, "");
last(a, t(Level::Error, filter));
warn!(logger: logger, "");
last(a, t(Level::Warn, filter));
info!(logger: logger, "");
last(a, t(Level::Info, filter));
debug!(logger: logger, "");
last(a, t(Level::Debug, filter));
trace!(logger: logger, "");
last(a, t(Level::Trace, filter));
fn t(lvl: Level, filter: LevelFilter) -> Option<Level> {
if lvl <= filter {
Some(lvl)
} else {
None
}
}
fn last(state: &State, expected: Option<Level>) {
let lvl = state.last_log_level.lock().unwrap().take();
assert_eq!(lvl, expected);
}
}
fn test_line_numbers(logger: &dyn Log, state: &State) {
log::set_max_level(LevelFilter::Trace);
info!(logger: logger, ""); // ensure check_line function follows log macro
check_log_location(state);
#[track_caller]
fn check_log_location(state: &State) {
let location = std::panic::Location::caller().line(); // get function calling location
let line_number = state.last_log_location.lock().unwrap().take().unwrap(); // get location of most recent log
assert_eq!(line_number, location - 1);
}
}

429
vendor/log/tests/macros.rs vendored Normal file
View File

@@ -0,0 +1,429 @@
use log::{log, log_enabled, Log, Metadata, Record};
macro_rules! all_log_macros {
($($arg:tt)*) => ({
::log::trace!($($arg)*);
::log::debug!($($arg)*);
::log::info!($($arg)*);
::log::warn!($($arg)*);
::log::error!($($arg)*);
});
}
// Not `Copy`
struct Logger;
impl Log for Logger {
fn enabled(&self, _: &Metadata) -> bool {
false
}
fn log(&self, _: &Record) {}
fn flush(&self) {}
}
#[test]
fn no_args() {
let logger = Logger;
for lvl in log::Level::iter() {
log!(lvl, "hello");
log!(lvl, "hello",);
log!(target: "my_target", lvl, "hello");
log!(target: "my_target", lvl, "hello",);
log!(logger: logger, lvl, "hello");
log!(logger: logger, lvl, "hello",);
log!(logger: logger, target: "my_target", lvl, "hello");
log!(logger: logger, target: "my_target", lvl, "hello",);
}
all_log_macros!("hello");
all_log_macros!("hello",);
all_log_macros!(target: "my_target", "hello");
all_log_macros!(target: "my_target", "hello",);
all_log_macros!(logger: logger, "hello");
all_log_macros!(logger: logger, "hello",);
all_log_macros!(logger: logger, target: "my_target", "hello");
all_log_macros!(logger: logger, target: "my_target", "hello",);
}
#[test]
fn anonymous_args() {
for lvl in log::Level::iter() {
log!(lvl, "hello {}", "world");
log!(lvl, "hello {}", "world",);
log!(target: "my_target", lvl, "hello {}", "world");
log!(target: "my_target", lvl, "hello {}", "world",);
log!(lvl, "hello {}", "world");
log!(lvl, "hello {}", "world",);
}
all_log_macros!("hello {}", "world");
all_log_macros!("hello {}", "world",);
all_log_macros!(target: "my_target", "hello {}", "world");
all_log_macros!(target: "my_target", "hello {}", "world",);
let logger = Logger;
all_log_macros!(logger: logger, "hello {}", "world");
all_log_macros!(logger: logger, "hello {}", "world",);
all_log_macros!(logger: logger, target: "my_target", "hello {}", "world");
all_log_macros!(logger: logger, target: "my_target", "hello {}", "world",);
}
#[test]
fn named_args() {
for lvl in log::Level::iter() {
log!(lvl, "hello {world}", world = "world");
log!(lvl, "hello {world}", world = "world",);
log!(target: "my_target", lvl, "hello {world}", world = "world");
log!(target: "my_target", lvl, "hello {world}", world = "world",);
log!(lvl, "hello {world}", world = "world");
log!(lvl, "hello {world}", world = "world",);
}
all_log_macros!("hello {world}", world = "world");
all_log_macros!("hello {world}", world = "world",);
all_log_macros!(target: "my_target", "hello {world}", world = "world");
all_log_macros!(target: "my_target", "hello {world}", world = "world",);
let logger = Logger;
all_log_macros!(logger: logger, "hello {world}", world = "world");
all_log_macros!(logger: logger, "hello {world}", world = "world",);
all_log_macros!(logger: logger, target: "my_target", "hello {world}", world = "world");
all_log_macros!(logger: logger, target: "my_target", "hello {world}", world = "world",);
}
#[test]
fn inlined_args() {
let world = "world";
for lvl in log::Level::iter() {
log!(lvl, "hello {world}");
log!(lvl, "hello {world}",);
log!(target: "my_target", lvl, "hello {world}");
log!(target: "my_target", lvl, "hello {world}",);
log!(lvl, "hello {world}");
log!(lvl, "hello {world}",);
}
all_log_macros!("hello {world}");
all_log_macros!("hello {world}",);
all_log_macros!(target: "my_target", "hello {world}");
all_log_macros!(target: "my_target", "hello {world}",);
let logger = Logger;
all_log_macros!(logger: logger, "hello {world}");
all_log_macros!(logger: logger, "hello {world}",);
all_log_macros!(logger: logger, target: "my_target", "hello {world}");
all_log_macros!(logger: logger, target: "my_target", "hello {world}",);
}
#[test]
fn enabled() {
let logger = Logger;
for lvl in log::Level::iter() {
let _enabled = log_enabled!(lvl);
let _enabled = log_enabled!(target: "my_target", lvl);
let _enabled = log_enabled!(logger: logger, target: "my_target", lvl);
let _enabled = log_enabled!(logger: logger, lvl);
}
}
#[test]
fn expr() {
let logger = Logger;
for lvl in log::Level::iter() {
log!(lvl, "hello");
log!(logger: logger, lvl, "hello");
}
}
#[test]
#[cfg(feature = "kv")]
fn kv_no_args() {
let logger = Logger;
for lvl in log::Level::iter() {
log!(target: "my_target", lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello");
log!(lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello");
log!(logger: logger, target: "my_target", lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello");
log!(logger: logger, lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello");
}
all_log_macros!(target: "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello");
all_log_macros!(target = "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello");
all_log_macros!(cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello");
all_log_macros!(logger: logger, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello");
all_log_macros!(logger: logger, target: "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello");
}
#[test]
#[cfg(feature = "kv")]
fn kv_expr_args() {
let logger = Logger;
for lvl in log::Level::iter() {
log!(target: "my_target", lvl, cat_math = { let mut x = 0; x += 1; x + 1 }; "hello");
log!(lvl, target = "my_target", cat_math = { let mut x = 0; x += 1; x + 1 }; "hello");
log!(lvl, cat_math = { let mut x = 0; x += 1; x + 1 }; "hello");
log!(logger: logger, target: "my_target", lvl, cat_math = { let mut x = 0; x += 1; x + 1 }; "hello");
log!(logger: logger, lvl, target = "my_target", cat_math = { let mut x = 0; x += 1; x + 1 }; "hello");
log!(logger: logger, lvl, cat_math = { let mut x = 0; x += 1; x + 1 }; "hello");
}
all_log_macros!(target: "my_target", cat_math = { let mut x = 0; x += 1; x + 1 }; "hello");
all_log_macros!(target = "my_target", cat_math = { let mut x = 0; x += 1; x + 1 }; "hello");
all_log_macros!(cat_math = { let mut x = 0; x += 1; x + 1 }; "hello");
all_log_macros!(logger: logger, target: "my_target", cat_math = { let mut x = 0; x += 1; x + 1 }; "hello");
all_log_macros!(logger: logger, target = "my_target", cat_math = { let mut x = 0; x += 1; x + 1 }; "hello");
all_log_macros!(logger: logger, cat_math = { let mut x = 0; x += 1; x + 1 }; "hello");
}
#[test]
#[cfg(feature = "kv")]
fn kv_anonymous_args() {
let logger = Logger;
for lvl in log::Level::iter() {
log!(target: "my_target", lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {}", "world");
log!(lvl, target = "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {}", "world");
log!(lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {}", "world");
log!(logger: logger, target: "my_target", lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {}", "world");
log!(logger: logger, lvl, target = "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {}", "world");
log!(logger: logger, lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {}", "world");
}
all_log_macros!(target: "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {}", "world");
all_log_macros!(target = "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {}", "world");
all_log_macros!(cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {}", "world");
all_log_macros!(logger: logger, target: "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {}", "world");
all_log_macros!(logger: logger, target = "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {}", "world");
all_log_macros!(logger: logger, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {}", "world");
}
#[test]
#[cfg(feature = "kv")]
fn kv_named_args() {
let logger = Logger;
for lvl in log::Level::iter() {
log!(target: "my_target", lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}", world = "world");
log!(lvl, target = "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}", world = "world");
log!(lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}", world = "world");
log!(logger: logger, target: "my_target", lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}", world = "world");
log!(logger: logger, lvl, target = "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}", world = "world");
log!(logger: logger, lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}", world = "world");
}
all_log_macros!(target: "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}", world = "world");
all_log_macros!(target = "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}", world = "world");
all_log_macros!(cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}", world = "world");
all_log_macros!(logger: logger, target: "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}", world = "world");
all_log_macros!(logger: logger, target = "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}", world = "world");
all_log_macros!(logger: logger, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}", world = "world");
}
#[test]
#[cfg(feature = "kv")]
fn kv_ident() {
let cat_1 = "chashu";
let cat_2 = "nori";
all_log_macros!(cat_1, cat_2:%, cat_count = 2; "hello {world}", world = "world");
}
#[test]
#[cfg(feature = "kv")]
fn kv_expr_context() {
match "chashu" {
cat_1 => {
log::info!(target: "target", cat_1 = cat_1, cat_2 = "nori"; "hello {}", "cats");
}
};
}
#[test]
fn implicit_named_args() {
let world = "world";
for lvl in log::Level::iter() {
log!(lvl, "hello {world}");
log!(lvl, "hello {world}",);
log!(target: "my_target", lvl, "hello {world}");
log!(target: "my_target", lvl, "hello {world}",);
log!(lvl, "hello {world}");
log!(lvl, "hello {world}",);
}
all_log_macros!("hello {world}");
all_log_macros!("hello {world}",);
all_log_macros!(target: "my_target", "hello {world}");
all_log_macros!(target: "my_target", "hello {world}",);
#[cfg(feature = "kv")]
all_log_macros!(target = "my_target"; "hello {world}");
#[cfg(feature = "kv")]
all_log_macros!(target = "my_target"; "hello {world}",);
}
#[test]
#[cfg(feature = "kv")]
fn kv_implicit_named_args() {
let world = "world";
for lvl in log::Level::iter() {
log!(target: "my_target", lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}");
log!(lvl, cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}");
}
all_log_macros!(target: "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}");
all_log_macros!(target = "my_target", cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}");
all_log_macros!(cat_1 = "chashu", cat_2 = "nori", cat_count = 2; "hello {world}");
}
#[test]
#[cfg(feature = "kv")]
fn kv_string_keys() {
for lvl in log::Level::iter() {
log!(target: "my_target", lvl, "also dogs" = "Fílos", "key/that-can't/be/an/ident" = "hi"; "hello {world}", world = "world");
}
all_log_macros!(target: "my_target", "also dogs" = "Fílos", "key/that-can't/be/an/ident" = "hi"; "hello {world}", world = "world");
}
#[test]
#[cfg(feature = "kv")]
fn kv_common_value_types() {
all_log_macros!(
u8 = 42u8,
u16 = 42u16,
u32 = 42u32,
u64 = 42u64,
u128 = 42u128,
i8 = -42i8,
i16 = -42i16,
i32 = -42i32,
i64 = -42i64,
i128 = -42i128,
f32 = 4.2f32,
f64 = -4.2f64,
bool = true,
str = "string";
"hello world"
);
}
#[test]
#[cfg(feature = "kv")]
fn kv_debug() {
all_log_macros!(
a:? = 42,
b:debug = 42;
"hello world"
);
}
#[test]
#[cfg(feature = "kv")]
fn kv_display() {
all_log_macros!(
a:% = 42,
b:display = 42;
"hello world"
);
}
#[test]
#[cfg(feature = "kv_std")]
fn kv_error() {
all_log_macros!(
a:err = std::io::Error::new(std::io::ErrorKind::Other, "an error");
"hello world"
);
}
#[test]
#[cfg(feature = "kv_sval")]
fn kv_sval() {
all_log_macros!(
a:sval = 42;
"hello world"
);
}
#[test]
#[cfg(feature = "kv_serde")]
fn kv_serde() {
all_log_macros!(
a:serde = 42;
"hello world"
);
}
#[test]
fn logger_short_lived() {
all_log_macros!(logger: Logger, "hello");
all_log_macros!(logger: &Logger, "hello");
}
#[test]
fn logger_expr() {
all_log_macros!(logger: {
let logger = Logger;
logger
}, "hello");
}
/// Some and None (from Option) are used in the macros.
#[derive(Debug)]
enum Type {
Some,
None,
}
#[test]
fn regression_issue_494() {
use self::Type::*;
all_log_macros!("some message: {:?}, {:?}", None, Some);
}