Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Sources/SWBTestSupport/SkippedTestSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<R: RangeExpression>(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)
})
}

Expand Down
12 changes: 8 additions & 4 deletions Tests/SWBBuildSystemTests/ClangCompilationCachingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/SWBBuildSystemTests/ClangModuleVerifierTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down