1
0
Fork 0
gobject-generator/Tests/IntegrationTests/CompileGateTests.swift

43 lines
1.8 KiB
Swift

// CompileGateTests.swift
// Wraps scripts/compile-gate.sh as a test so CI can run the compile gate via
// `swift test`. Gated behind SWIFT_GTK_GEN_COMPILE_GATE=1 so the default
// `swift test` run stays fast and does not require system GIR files.
import Foundation
import Testing
/// Integration test that runs the compile gate: generate a tier's monorepo
/// and require the generated package to build with zero errors.
///
/// Enable with `SWIFT_GTK_GEN_COMPILE_GATE=1 swift test`; select a tier with
/// `SWIFT_GTK_GEN_GATE_TIER` (defaults to `"1"`, accepts `"all"`).
@Suite struct CompileGateTests {
/// Whether the gate is enabled for this test run.
private nonisolated static var gateEnabled: Bool {
ProcessInfo.processInfo.environment["SWIFT_GTK_GEN_COMPILE_GATE"] == "1"
}
/// The tier argument passed to the gate script.
private nonisolated static var tier: String {
ProcessInfo.processInfo.environment["SWIFT_GTK_GEN_GATE_TIER"] ?? "1"
}
@Test(.enabled(if: gateEnabled, "set SWIFT_GTK_GEN_COMPILE_GATE=1 to run the compile gate"))
func generatedPackageCompiles() throws {
// #filePath = .../Tests/IntegrationTests/CompileGateTests.swift
let packageRoot = URL(fileURLWithPath: #filePath)
.deletingLastPathComponent() // IntegrationTests
.deletingLastPathComponent() // Tests
.deletingLastPathComponent() // package root
let script = packageRoot.appendingPathComponent("scripts/compile-gate.sh")
let process = Process()
process.executableURL = script
process.arguments = [Self.tier]
process.currentDirectoryURL = packageRoot
try process.run()
process.waitUntilExit()
#expect(process.terminationStatus == 0, "compile gate failed for tier \(Self.tier)")
}
}