// ToolchainProbeTests.swift // Lyrebird // // Copyright (c) 2026 Joshua Parmenter / realizedsound // SPDX-License-Identifier: MIT #if os(macOS) import Testing @testable import LyrebirdLiveCompile @Suite("ToolchainProbe") struct ToolchainProbeTests { private func probe(swiftc: String?, sdk: String?, devDir: String?) -> ToolchainProbe { ToolchainProbe( swiftcResolver: { swiftc }, sdkResolver: { sdk }, developerDirResolver: { devDir } ) } @Test("swiftc + SDK both present → available") func availableWhenBothResolve() { #expect(probe(swiftc: "/usr/bin/swiftc", sdk: "/SDK", devDir: "/Dev").status() == .available) } @Test("no swiftc and no developer dir → missingDeveloperTools") func missingDeveloperTools() { #expect(probe(swiftc: nil, sdk: nil, devDir: nil).status() == .missingDeveloperTools) } @Test("no swiftc but developer dir present → missingSwiftc") func missingSwiftc() { #expect(probe(swiftc: nil, sdk: nil, devDir: "/Dev").status() == .missingSwiftc) // SDK value is irrelevant when swiftc is unresolved. #expect(probe(swiftc: nil, sdk: "/SDK", devDir: "/Dev").status() == .missingSwiftc) } @Test("swiftc present but SDK missing → missingSDK") func missingSDK() { #expect(probe(swiftc: "/usr/bin/swiftc", sdk: nil, devDir: "/Dev").status() == .missingSDK) } @Test("default probe on a build machine finds developer tools") func defaultProbeFindsDeveloperTools() { // Any machine that can build/test this package has a developer directory, so // the real (non-injected) resolvers must never report missingDeveloperTools — // this smoke-tests that the default xcode-select / xcrun probes actually run. // (Not asserting strict `.available`: a full-SDK requirement would couple the // suite to the host's exact toolchain completeness.) #expect(ToolchainProbe().status() != .missingDeveloperTools) } } #endif