Unlucky Launcher v0.2.0
CI / runtime smoke (macos arm64, probe) (push) Skipped
CI / fmt (rustfmt --check) (push) Canceled after 0s
CI / clippy (ubuntu-latest) (push) Canceled after 0s
CI / clippy (windows-latest) (push) Canceled after 0s
CI / test (ubuntu-latest) (push) Canceled after 0s
CI / test (windows-latest) (push) Canceled after 0s
CI / build release (ubuntu-latest) (push) Canceled after 0s
CI / build release (windows-latest) (push) Canceled after 0s
CI / runtime smoke (ubuntu x64, xvfb) (push) Canceled after 0s
Guards / core 零 UI 守门 (push) Canceled after 0s
Guards / presenter 零 UI 守门 (push) Canceled after 0s
Guards / design 零第三方依赖守门 (push) Canceled after 0s
Guards / unsafe 落点守门(集合必须恰好一个文件) (push) Canceled after 0s
Guards / 文件行数 ≤400 守门 (push) Canceled after 0s
Guards / 依赖许可与来源(cargo-deny) (push) Canceled after 0s
CI / runtime smoke (macos arm64, probe) (push) Skipped
CI / fmt (rustfmt --check) (push) Canceled after 0s
CI / clippy (ubuntu-latest) (push) Canceled after 0s
CI / clippy (windows-latest) (push) Canceled after 0s
CI / test (ubuntu-latest) (push) Canceled after 0s
CI / test (windows-latest) (push) Canceled after 0s
CI / build release (ubuntu-latest) (push) Canceled after 0s
CI / build release (windows-latest) (push) Canceled after 0s
CI / runtime smoke (ubuntu x64, xvfb) (push) Canceled after 0s
Guards / core 零 UI 守门 (push) Canceled after 0s
Guards / presenter 零 UI 守门 (push) Canceled after 0s
Guards / design 零第三方依赖守门 (push) Canceled after 0s
Guards / unsafe 落点守门(集合必须恰好一个文件) (push) Canceled after 0s
Guards / 文件行数 ≤400 守门 (push) Canceled after 0s
Guards / 依赖许可与来源(cargo-deny) (push) Canceled after 0s
首个 iced + Material 3 Expressive 版本的源码快照。 完整历史与日常提交在 dev 分支;main 只放阶段性快照。
This commit is contained in:
commit
8a8e5ca0c0
1079 files changed
+208035
No files matched your search
@@ -0,0 +1,73 @@
|
||||
//! sink 组合测试(复合 sink 是接 M15 采集器 / UI 日志页的接缝)。
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
fn line(stream: Stream, text: &str) -> LogLine {
|
||||
LogLine::new(stream, text)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn composite_sink_broadcasts_in_registration_order() {
|
||||
let order = Arc::new(Mutex::new(Vec::<String>::new()));
|
||||
let first = {
|
||||
let order = order.clone();
|
||||
FnSink::new(move |line: &LogLine| {
|
||||
order.lock().unwrap().push(format!("first:{}", line.text));
|
||||
})
|
||||
};
|
||||
let second = {
|
||||
let order = order.clone();
|
||||
FnSink::new(move |line: &LogLine| {
|
||||
order.lock().unwrap().push(format!("second:{}", line.text));
|
||||
})
|
||||
};
|
||||
let composite = CompositeSink::new()
|
||||
.with(first.shared())
|
||||
.with(second.shared());
|
||||
assert_eq!(composite.len(), 2);
|
||||
composite.on_line(&line(Stream::Stdout, "hello"));
|
||||
|
||||
let recorded = order.lock().unwrap().clone();
|
||||
assert_eq!(recorded, vec!["first:hello", "second:hello"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn composite_sink_passes_stream_and_text() {
|
||||
let seen = Arc::new(Mutex::new(Vec::<(Stream, String)>::new()));
|
||||
let recorder = {
|
||||
let seen = seen.clone();
|
||||
FnSink::new(move |line: &LogLine| {
|
||||
seen.lock().unwrap().push((line.stream, line.text.clone()));
|
||||
})
|
||||
};
|
||||
// 模拟 diagnose 侧:只记文本 + 流标记(不解析 jsonl、不 import launch 类型)。
|
||||
let mut composite = CompositeSink::new();
|
||||
composite.push(recorder.shared());
|
||||
composite.on_line(&line(Stream::Stdout, "out"));
|
||||
composite.on_line(&line(Stream::Stderr, "err"));
|
||||
|
||||
let seen = seen.lock().unwrap().clone();
|
||||
assert_eq!(seen.len(), 2);
|
||||
assert_eq!(seen[0], (Stream::Stdout, "out".to_string()));
|
||||
assert_eq!(seen[1], (Stream::Stderr, "err".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn counting_sink_counts_per_stream() {
|
||||
let counter = Arc::new(CountingSink::new());
|
||||
counter.on_line(&line(Stream::Stdout, "a"));
|
||||
counter.on_line(&line(Stream::Stdout, "b"));
|
||||
counter.on_line(&line(Stream::Stderr, "c"));
|
||||
assert_eq!(counter.stdout_lines(), 2);
|
||||
assert_eq!(counter.stderr_lines(), 1);
|
||||
assert_eq!(counter.total_lines(), 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_composite_is_harmless() {
|
||||
let composite = CompositeSink::new();
|
||||
assert!(composite.is_empty());
|
||||
composite.on_line(&line(Stream::Stdout, "ignored"));
|
||||
}
|
||||
Reference in new issue
Block a user