Four targets (MWBCore, MWBNet, MWBMac, mwb) with a layering test that keeps MWBCore free of AppKit/CoreGraphics/Network; tools/gates.sh as the definition of done; tools/bundle.sh producing a signed dist/mwb.app; tools/lane.sh for lane worktrees; smoke binary with --version and --check-permissions. docs/loop.md records the Dev -> QA -> lead loop with the literal dispatch prompts, the wave schedule and escalations. Co-Authored-By: Claude Fable 5.1 <[email protected]>
47 lines
2.1 KiB
Swift
47 lines
2.1 KiB
Swift
import Foundation
|
|
import XCTest
|
|
|
|
/// Enforces README D2 / docs/topo.md §1: `MWBCore` is pure logic and may
|
|
/// import only Foundation and CommonCrypto (plus CryptoKit for hashing).
|
|
/// A platform or network import in the core target fails this test.
|
|
final class LayeringTests: XCTestCase {
|
|
private static let forbidden = [
|
|
"AppKit", "Cocoa", "CoreGraphics", "Carbon", "SwiftUI", "Network", "IOKit", "ApplicationServices",
|
|
]
|
|
|
|
func testCoreImportsOnlyFoundationAndCrypto() throws {
|
|
let core = coreSourcesDirectory()
|
|
let files = try swiftFiles(under: core)
|
|
XCTAssertFalse(files.isEmpty, "no Swift sources found under \(core.path)")
|
|
for file in files {
|
|
let text = try String(contentsOf: file, encoding: .utf8)
|
|
for (number, line) in text.split(separator: "\n", omittingEmptySubsequences: false).enumerated() {
|
|
let trimmed = line.trimmingCharacters(in: .whitespaces)
|
|
guard trimmed.hasPrefix("import ") else { continue }
|
|
let module =
|
|
trimmed.dropFirst("import ".count).split(separator: " ").first.map(String.init) ?? ""
|
|
XCTAssertFalse(
|
|
Self.forbidden.contains(module),
|
|
"\(file.lastPathComponent):\(number + 1) imports \(module); MWBCore is Foundation-only (README D2)"
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
private func coreSourcesDirectory() -> URL {
|
|
// Tests/MWBCoreTests/LayeringTests.swift → repo root → Sources/MWBCore
|
|
URL(fileURLWithPath: #filePath)
|
|
.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
|
|
.appendingPathComponent("Sources/MWBCore", isDirectory: true)
|
|
}
|
|
|
|
private func swiftFiles(under directory: URL) throws -> [URL] {
|
|
let keys: [URLResourceKey] = [.isRegularFileKey]
|
|
guard let walker = FileManager.default.enumerator(at: directory, includingPropertiesForKeys: keys)
|
|
else {
|
|
return []
|
|
}
|
|
return walker.compactMap { $0 as? URL }.filter { $0.pathExtension == "swift" }
|
|
}
|
|
}
|