Refactor LoggingTests utilising Rust's new ability to redirect log files at runtime. (#4353)

This commit is contained in:
Doug
2025-07-25 08:54:36 +01:00
committed by GitHub
parent abc731e299
commit 095d927498
3 changed files with 67 additions and 48 deletions
@@ -8,6 +8,10 @@
import SwiftUI
class UnitTestsAppCoordinator: AppCoordinatorProtocol {
private let targetConfiguration: Target.ConfigurationResult
static let targetRageshakeURL = RemotePreference<RageshakeConfiguration>(.url("bugs.example.com/submit"))
static let targetAppHooks = AppHooks()
let windowManager: SecureWindowManagerProtocol
init(appDelegate: AppDelegate) {
@@ -23,6 +27,17 @@ class UnitTestsAppCoordinator: AppCoordinatorProtocol {
analyticsClient.isRunning = false
ServiceLocator.shared.register(analytics: AnalyticsService(client: analyticsClient,
appSettings: ServiceLocator.shared.settings))
// As the tests take advantage of Rust's ability to redirect the log files, there is
// often some debris left from the previous run, so we wipe the entire directory.
// This is an NOT an advised way to delete logs in production, `Tracing.deleteLogFiles`
// exists for that purpose.
try? FileManager.default.removeItem(at: .appGroupLogsDirectory)
targetConfiguration = Target.tests.configure(logLevel: .info,
traceLogPacks: [],
sentryURL: nil,
rageshakeURL: Self.targetRageshakeURL,
appHooks: Self.targetAppHooks)
}
func start() { }