mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
test(macos): remove unused coverage artifacts (#122755)
This commit is contained in:
committed by
GitHub
parent
2ce420091e
commit
fb13d62e70
@@ -1,29 +0,0 @@
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
/// Hosts arbitrary SwiftUI content as an AppKit view so it can be embedded in a native `NSMenuItem.view`.
|
||||
///
|
||||
/// SwiftUI `MenuBarExtraStyle.menu` aggressively simplifies many view hierarchies into a title + image.
|
||||
/// Wrapping the content in an `NSViewRepresentable` forces AppKit-backed menu item rendering.
|
||||
struct MenuHostedItem: NSViewRepresentable {
|
||||
let width: CGFloat
|
||||
let rootView: AnyView
|
||||
|
||||
func makeNSView(context _: Context) -> NSHostingView<AnyView> {
|
||||
let hosting = NSHostingView(rootView: self.rootView)
|
||||
self.applySizing(to: hosting)
|
||||
return hosting
|
||||
}
|
||||
|
||||
func updateNSView(_ nsView: NSHostingView<AnyView>, context _: Context) {
|
||||
nsView.rootView = self.rootView
|
||||
self.applySizing(to: nsView)
|
||||
}
|
||||
|
||||
private func applySizing(to hosting: NSHostingView<AnyView>) {
|
||||
let width = max(1, self.width)
|
||||
hosting.frame.size.width = width
|
||||
let fitting = hosting.fittingSize
|
||||
hosting.frame = NSRect(origin: .zero, size: NSSize(width: width, height: fitting.height))
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import Darwin
|
||||
import Foundation
|
||||
import Testing
|
||||
|
||||
@Suite(.serialized)
|
||||
struct CoverageDumpTests {
|
||||
@Test func `periodically flush coverage`() async {
|
||||
guard ProcessInfo.processInfo.environment["LLVM_PROFILE_FILE"] != nil else { return }
|
||||
guard let writeProfile = resolveProfileWriteFile() else { return }
|
||||
let deadline = Date().addingTimeInterval(4)
|
||||
while Date() < deadline {
|
||||
_ = writeProfile()
|
||||
try? await Task.sleep(nanoseconds: 250_000_000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private typealias ProfileWriteFn = @convention(c) () -> Int32
|
||||
|
||||
private func resolveProfileWriteFile() -> ProfileWriteFn? {
|
||||
let symbol = dlsym(UnsafeMutableRawPointer(bitPattern: -2), "__llvm_profile_write_file")
|
||||
guard let symbol else { return nil }
|
||||
return unsafeBitCast(symbol, to: ProfileWriteFn.self)
|
||||
}
|
||||
@@ -33,14 +33,6 @@ struct LowCoverageViewSmokeTests {
|
||||
_ = hosting.fittingSize
|
||||
}
|
||||
|
||||
@Test func `menu hosted item hosts content`() {
|
||||
let view = MenuHostedItem(width: 240, rootView: AnyView(Text("Menu")))
|
||||
let hosting = NSHostingView(rootView: view)
|
||||
_ = hosting.fittingSize
|
||||
hosting.rootView = MenuHostedItem(width: 320, rootView: AnyView(Text("Updated")))
|
||||
_ = hosting.fittingSize
|
||||
}
|
||||
|
||||
@Test func `dock icon manager updates visibility`() {
|
||||
_ = NSApplication.shared
|
||||
UserDefaults.standard.set(false, forKey: showDockIconKey)
|
||||
|
||||
Reference in New Issue
Block a user