Skip to content

Commit 2e1cb56

Browse files
[TEST-ONLY][swift][Caching] Fix some swift caching tests
Fix two problems from now enabled swift caching tests: * Some destinations/requirements are not consistent across the test so the test can fail with certain test configuration. * Make the test more reliable for different SDK configurations by abstracting out the number of module dependencies. rdar://158600194
1 parent 7adc227 commit 2e1cb56

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Tests/SWBBuildSystemTests/SwiftCompilationCachingTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,29 +111,29 @@ fileprivate struct SwiftCompilationCachingTests: CoreBasedTests {
111111
numCompile += tasks.count
112112
}
113113

114-
results.checkNote("0 hits / 4 cacheable tasks (0%)")
114+
results.checkNote("0 hits / \(numCompile) cacheable tasks (0%)")
115115

116116
results.checkNoTask()
117117
}
118118
#expect(try readMetrics("one").contains("\"swiftCacheHits\":0,\"swiftCacheMisses\":\(numCompile)"))
119119

120120
// touch a file, clean build folder, and rebuild.
121121
try await tester.fs.updateTimestamp(testWorkspace.sourceRoot.join("aProject/App.swift"))
122-
try await tester.checkBuild(runDestination: .macOS, buildCommand: .cleanBuildFolder(style: .regular), body: { _ in })
122+
try await tester.checkBuild(runDestination: .anyiOSDevice, buildCommand: .cleanBuildFolder(style: .regular), body: { _ in })
123123

124124
tester.userInfo = rawUserInfo.withAdditionalEnvironment(environment: metricsEnv("two"))
125125
try await tester.checkBuild(runDestination: .anyiOSDevice, persistent: true) { results in
126126
results.checkTask(.matchRule(["SwiftCompile", "normal", "arm64", "Compiling App.swift", "\(tmpDirPath.str)/Test/aProject/App.swift"])) { task in
127127
results.checkKeyQueryCacheHit(task)
128128
}
129129

130-
results.checkNote("4 hits / 4 cacheable tasks (100%)")
130+
results.checkNote("\(numCompile) hits / \(numCompile) cacheable tasks (100%)")
131131
}
132132
#expect(try readMetrics("two").contains("\"swiftCacheHits\":\(numCompile),\"swiftCacheMisses\":0"))
133133
}
134134
}
135135

136-
@Test(.requireSDKs(.iOS))
136+
@Test(.requireSDKs(.macOS))
137137
func swiftCachingSwiftPM() async throws {
138138
try await withTemporaryDirectory { tmpDirPath async throws -> Void in
139139
let commonBuildSettings = try await [

0 commit comments

Comments
 (0)