Add os.Logger categories, OSSignposter wrapper and shortHash helper; enforce exact Debug/Release/install signatures; lint tests; update M0 docs and progress.
55 lines
1.6 KiB
Swift
55 lines
1.6 KiB
Swift
import os
|
|
import Testing
|
|
@testable import SprachmittlerCore
|
|
|
|
/// T0.4: the logging helper must stay in sync with ARCHITECTURE §15.
|
|
@Suite("Logging contract")
|
|
struct LoggingContractTests {
|
|
@Test func categoriesMatchArchitecture() {
|
|
#expect(LogCategory.allCases.map(\.rawValue) == [
|
|
"capture",
|
|
"pasteboard",
|
|
"session",
|
|
"ollama",
|
|
"engine",
|
|
"validate",
|
|
"insert",
|
|
"panel",
|
|
"settings",
|
|
])
|
|
}
|
|
|
|
@Test func signpostNamesMatchArchitecture() {
|
|
#expect(SignpostName.allCases.map(\.rawValue) == [
|
|
"capture",
|
|
"panel",
|
|
"request",
|
|
"firstToken",
|
|
"translate",
|
|
"validate",
|
|
"copy",
|
|
"insert",
|
|
])
|
|
}
|
|
|
|
/// `OSSignposter.beginInterval` needs a `StaticString`; this catches a hand-written switch drift.
|
|
@Test func signpostLiteralsMatchRawValues() {
|
|
for name in SignpostName.allCases {
|
|
#expect(String(describing: name.literal) == name.rawValue)
|
|
}
|
|
}
|
|
|
|
@Test func loggersWorkForEveryCategory() {
|
|
let loggers = Loggers(subsystem: "test.sprachmittler")
|
|
for category in LogCategory.allCases {
|
|
loggers.logger(category).debug("logging contract test")
|
|
|
|
let signposts = loggers.signposts(category)
|
|
let interval = signposts.begin(.capture)
|
|
#expect(interval.name.rawValue == "capture")
|
|
signposts.end(interval)
|
|
signposts.event(.panel)
|
|
}
|
|
}
|
|
}
|