v0.1.3-pre.004

This commit is contained in:
2026-08-15 19:58:18 +02:00
parent 0629a48e97
commit 29660fd9f0
13 changed files with 1134 additions and 174 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-logging-lib/unit_tests/runtime.rs
// version: 5
// version: 6
#[test]
fn level_mapping_covers_all_ksp_levels() {
@@ -17,7 +17,7 @@ fn takeover_filter_silences_external_targets_and_applies_ksp_overrides() {
crate::LogFilterLevel::Info,
crate::SpanEvents::Off,
std::option::Option::Some(crate::ConsoleSettings::stdout()),
std::option::Option::None,
std::vec::Vec::new(),
)
.with_target_filter(crate::TargetFilter::new("ksp-logging-lib", crate::LogFilterLevel::Trace));
let filter = super::build_target_filter(&settings);
@@ -47,7 +47,7 @@ fn file_rotation_mapping_covers_supported_cadences() {
#[test]
fn disabled_runtime_has_no_layers_or_outputs() {
let settings = crate::LoggingSettings::new(crate::LogFilterLevel::Info, crate::SpanEvents::Off, std::option::Option::None, std::option::Option::None);
let settings = crate::LoggingSettings::new(crate::LogFilterLevel::Info, crate::SpanEvents::Off, std::option::Option::None, std::vec::Vec::new());
let result = super::prepare_runtime(&settings);
assert!(result.is_ok());
let prepared = match result {
@@ -65,7 +65,7 @@ fn console_runtime_composes_takeover_filter_before_formatter_and_owns_guard() {
crate::LogFilterLevel::Info,
crate::SpanEvents::Off,
std::option::Option::Some(crate::ConsoleSettings::stdout()),
std::option::Option::None,
std::vec::Vec::new(),
);
let result = super::prepare_runtime(&settings);
assert!(result.is_ok());
@@ -91,7 +91,7 @@ fn dropped_line_snapshots_add_saturating_by_sink() {
#[test]
fn takeover_filter_prefers_more_specific_ksp_prefixes_and_supports_off() {
let settings = crate::LoggingSettings::new(crate::LogFilterLevel::Info, crate::SpanEvents::Off, std::option::Option::None, std::option::Option::None)
let settings = crate::LoggingSettings::new(crate::LogFilterLevel::Info, crate::SpanEvents::Off, std::option::Option::None, std::vec::Vec::new())
.with_target_filter(crate::TargetFilter::new("ksp-store-", crate::LogFilterLevel::Debug))
.with_target_filter(crate::TargetFilter::new("ksp-store-lib", crate::LogFilterLevel::Trace))
.with_target_filter(crate::TargetFilter::new("ksp-wallet-lib", crate::LogFilterLevel::Off));
@@ -102,6 +102,43 @@ fn takeover_filter_prefers_more_specific_ksp_prefixes_and_supports_off() {
assert!(!filter.would_enable("ksp-wallet-lib", &tracing::Level::ERROR));
}
#[test]
fn pre_multi_sink_runtime_rejects_new_capabilities_instead_of_ignoring_them() {
let routed_console = crate::ConsoleSettings::new(
true,
crate::ConsoleOutput::Stdout,
true,
crate::LogFormat::Compact,
crate::OutputFilter::new(crate::LogFilterLevel::Debug, std::vec!["ksp-logging-lib".to_string()], std::vec!["logging".to_string()]),
);
let routed_settings =
crate::LoggingSettings::new(crate::LogFilterLevel::Info, crate::SpanEvents::Off, std::option::Option::Some(routed_console), std::vec::Vec::new());
assert!(routed_settings.validate().is_ok());
assert!(super::prepare_runtime(&routed_settings).is_err());
let first_file = crate::FileSettings::new(
"file.first",
true,
"logs",
"first.log",
crate::FileRotation::Never,
crate::LogFormat::Human,
crate::OutputFilter::unrestricted(),
);
let second_file = crate::FileSettings::new(
"file.second",
true,
"logs",
"second.log",
crate::FileRotation::Never,
crate::LogFormat::Human,
crate::OutputFilter::unrestricted(),
);
let multi_file_settings =
crate::LoggingSettings::new(crate::LogFilterLevel::Info, crate::SpanEvents::Off, std::option::Option::None, std::vec![first_file, second_file]);
assert!(multi_file_settings.validate().is_ok());
assert!(super::prepare_runtime(&multi_file_settings).is_err());
}
struct BlockingWriter {
first_write: bool,
started: std::sync::mpsc::SyncSender<()>,