diff --git a/Sources/SWBTestSupport/SkippedTestSupport.swift b/Sources/SWBTestSupport/SkippedTestSupport.swift index 10decc7a..b526492d 100644 --- a/Sources/SWBTestSupport/SkippedTestSupport.swift +++ b/Sources/SWBTestSupport/SkippedTestSupport.swift @@ -175,6 +175,10 @@ extension Trait where Self == Testing.ConditionTrait { return .skipIfEnvironmentVariableSet(key: "GITHUB_ACTIONS") } + package static func skipInXcodeCloud(_ comment: Comment? = nil) -> Self { + return .skipIfEnvironmentVariableSet(key: "CI_XCODE_CLOUD") + } + package static func requireClangFeatures(_ requiredFeatures: DiscoveredClangToolSpecInfo.FeatureFlag...) -> Self { enabled("Clang compiler does not support features: \(requiredFeatures)") { let features = try await ConditionTraitContext.shared.clangFeatures @@ -295,7 +299,10 @@ extension Trait where Self == Testing.ConditionTrait { /// Constructs a condition trait that causes a test to be disabled if not running against a version of Xcode within the given range. package static func requireXcodeBuildVersions(in range: @Sendable @autoclosure @escaping () throws -> R, sourceLocation: SourceLocation = #_sourceLocation) -> Self where R.Bound == ProductBuildVersion { enabled("Xcode version is not suitable", sourceLocation: sourceLocation, { - return try await range().contains(InstalledXcode.currentlySelected().productBuildVersion()) + guard let installedVersion = try? await InstalledXcode.currentlySelected().productBuildVersion() else { + return true + } + return try range().contains(installedVersion) }) } diff --git a/Tests/SWBBuildSystemTests/ClangCompilationCachingTests.swift b/Tests/SWBBuildSystemTests/ClangCompilationCachingTests.swift index b9066b22..cd1937f8 100644 --- a/Tests/SWBBuildSystemTests/ClangCompilationCachingTests.swift +++ b/Tests/SWBBuildSystemTests/ClangCompilationCachingTests.swift @@ -19,8 +19,7 @@ import SWBTestSupport import SWBUtil @Suite(.skipHostOS(.windows, "Windows platform has no CAS support yet"), - .requireDependencyScannerPlusCaching, - .flaky("A handful of Swift Build CAS tests fail when running the entire test suite"), .bug("rdar://146781403")) + .requireDependencyScannerPlusCaching, .skipInXcodeCloud("flaky tests"), .requireXcode26()) fileprivate struct ClangCompilationCachingTests: CoreBasedTests { let canUseCASPlugin: Bool let canUseCASPruning: Bool @@ -1580,7 +1579,7 @@ fileprivate struct ClangCompilationCachingTests: CoreBasedTests { func checkModuleCommandLine(task: Task, results: BuildOperationTester.BuildResults, name: String) { // The final command-line is only known to the dynamic task, but it's printed to output so we can check that. results.checkTaskOutput(task) { output in - XCTAssertMatch(output.stringValue, .contains(#"\#(name)\=/\^mod"#)) + XCTAssertMatch(output.stringValue, .or(.contains(#"\#(name)\=/\^mod"#), .contains(#"\#(name) /\^mod"#))) checkCommandLineCommon(output: output) } } @@ -1843,6 +1842,7 @@ fileprivate struct ClangCompilationCachingTests: CoreBasedTests { "CLANG_ENABLE_COMPILE_CACHE": enableCaching ? "YES" : "NO", "CLANG_ENABLE_MODULES": "NO", "COMPILATION_CACHE_CAS_PATH": casPath.str, + "DSTROOT": tmpDirPath.join("dstroot").str, ] if usePlugin { buildSettings["COMPILATION_CACHE_ENABLE_PLUGIN"] = "YES" @@ -1967,7 +1967,11 @@ fileprivate struct ClangCompilationCachingTests: CoreBasedTests { // Ignore output for plugin CAS since it may not yet support validation. try await checkBuild("validated successfully\n") // Create an error and trigger revalidation by messing with the validation data. - try tester.fs.move(casPath.join("builtin/v1.1/v8.data"), to: casPath.join("builtin/v1.1/v8.data.moved")) + let dataDir = casPath.join("builtin").join("v1.1") + let dataFile = try #require(tester.fs.listdir(dataDir).first { + $0.hasSuffix(".data") && $0.hasPrefix("v") + }) + try tester.fs.move(dataDir.join(dataFile), to: dataDir.join("moved")) try await tester.fs.writeFileContents(casPath.join("builtin/v1.validation")) { stream in stream <<< "0" } diff --git a/Tests/SWBBuildSystemTests/ClangModuleVerifierTests.swift b/Tests/SWBBuildSystemTests/ClangModuleVerifierTests.swift index a05d0662..632dbbf1 100644 --- a/Tests/SWBBuildSystemTests/ClangModuleVerifierTests.swift +++ b/Tests/SWBBuildSystemTests/ClangModuleVerifierTests.swift @@ -192,7 +192,7 @@ fileprivate struct ClangModuleVerifierTests: CoreBasedTests { } @Test(.requireSDKs(.macOS), .requireClangFeatures(.wSystemHeadersInModule), .requireDependencyScannerPlusCaching, - .flaky("A handful of Swift Build CAS tests fail when running the entire test suite"), .bug("rdar://146781403")) + .skipInXcodeCloud("flaky tests"), .requireXcode26()) func cachedBuild() async throws { try await withTemporaryDirectory { (tmpDirPath: Path) in let archs = ["arm64", "x86_64"] diff --git a/Tests/SWBBuildSystemTests/SwiftCompilationCachingTests.swift b/Tests/SWBBuildSystemTests/SwiftCompilationCachingTests.swift index 3836da8e..370d740b 100644 --- a/Tests/SWBBuildSystemTests/SwiftCompilationCachingTests.swift +++ b/Tests/SWBBuildSystemTests/SwiftCompilationCachingTests.swift @@ -20,7 +20,7 @@ import SWBTaskExecution import SWBProtocol @Suite(.requireSwiftFeatures(.compilationCaching), - .flaky("A handful of Swift Build CAS tests fail when running the entire test suite"), .bug("rdar://146781403")) + .skipInXcodeCloud("flaky tests"), .requireXcode26()) fileprivate struct SwiftCompilationCachingTests: CoreBasedTests { @Test(.requireSDKs(.iOS)) func swiftCachingSimple() async throws {