Skip to content

Commit 8172e20

Browse files
committed
test
1 parent d42d61d commit 8172e20

File tree

7 files changed

+27
-40
lines changed

7 files changed

+27
-40
lines changed

.github/workflows/pull_request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
with:
1616
linux_os_versions: '["noble", "jammy", "focal", "rhel-ubi9"]'
1717
linux_pre_build_command: command -v apt >/dev/null 2>&1 && apt update && apt install -y libsqlite3-dev libncurses-dev || (command -v yum >/dev/null 2>&1 && yum update -y && yum install -y sqlite-devel ncurses-devel)
18-
linux_build_command: 'swift build'
18+
linux_build_command: 'swift test --no-parallel'
1919
linux_swift_versions: '["nightly-main", "nightly-6.2"]'
2020
windows_swift_versions: '["nightly-main"]'
21-
windows_build_command: 'swift build'
21+
windows_build_command: 'swift test --no-parallel'
2222
soundness:
2323
name: Soundness
2424
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main

Sources/SWBBuildSystem/BuildOperation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ private class InProcessCommand: SWBLLBuild.ExternalCommand, SWBLLBuild.ExternalD
12021202
// Get the current output delegate from the adaptor.
12031203
//
12041204
// FIXME: This should never fail (since we are executing), but we have seen a crash here with that assumption. For now we are defensive until the source can be tracked down: <rdar://problem/31670274> Diagnose unexpected missing output delegate from: <rdar://problem/31669245> Crash in InProcessCommand.execute()
1205-
guard let outputDelegate = adaptor.getActiveOutputDelegate(command) else {
1205+
guard let outputDelegate = await adaptor.getActiveOutputDelegate(command) else {
12061206
return .failed
12071207
}
12081208

@@ -1552,9 +1552,9 @@ internal final class OperationSystemAdaptor: SWBLLBuild.BuildSystemDelegate, Act
15521552
/// Get the active output delegate for an executing command.
15531553
///
15541554
/// - returns: The active delegate, or nil if not found.
1555-
func getActiveOutputDelegate(_ command: Command) -> (any TaskOutputDelegate)? {
1555+
func getActiveOutputDelegate(_ command: Command) async -> (any TaskOutputDelegate)? {
15561556
// FIXME: This is a very bad idea, doing a sync against the response queue is introducing artificial latency when an in-process command needs to wait for the response queue to flush. However, we also can't simply move to a decoupled lock, because we don't want the command to start reporting output before it has been fully reported as having started. We need to move in-process task to another model.
1557-
return queue.blocking_sync {
1557+
return await queue.sync {
15581558
self.commandOutputDelegates[command]
15591559
}
15601560
}

Sources/SWBCore/LibSwiftDriver/LibSwiftDriver.swift

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,15 @@ public final class SwiftModuleDependencyGraph: SwiftGlobalExplicitDependencyGrap
177177
}
178178
}
179179

180-
public func querySwiftmodulesNeedingRegistrationForDebugging(for key: String) throws -> [String] {
181-
let graph = try registryQueue.blocking_sync {
182-
guard let driver = registry[key] else {
183-
throw StubError.error("Unable to find jobs for key \(key). Be sure to plan the build ahead of fetching results.")
180+
public func querySwiftmodulesNeedingRegistrationForDebugging(for key: String) async throws -> [String] {
181+
guard let graph: InterModuleDependencyGraph = await registryQueue.sync(execute: {
182+
guard let driver = self.registry[key] else {
183+
return nil
184184
}
185185
return driver.intermoduleDependencyGraph
186+
}) else {
187+
return []
186188
}
187-
guard let graph else { return [] }
188189
var swiftmodulePaths: [String] = []
189190
swiftmodulePaths.reserveCapacity(graph.modules.values.count)
190191
for (_, moduleInfo) in graph.modules.sorted(byKey: { $0.moduleName < $1.moduleName }) {
@@ -207,14 +208,15 @@ public final class SwiftModuleDependencyGraph: SwiftGlobalExplicitDependencyGrap
207208
return swiftmodulePaths
208209
}
209210

210-
public func queryPlanningDependencies(for key: String) throws -> [String] {
211-
let graph = try registryQueue.blocking_sync {
212-
guard let driver = registry[key] else {
213-
throw StubError.error("Unable to find jobs for key \(key). Be sure to plan the build ahead of fetching results.")
211+
public func queryPlanningDependencies(for key: String) async throws -> [String] {
212+
guard let graph: InterModuleDependencyGraph = await registryQueue.sync(execute: {
213+
guard let driver = self.registry[key] else {
214+
return nil
214215
}
215216
return driver.intermoduleDependencyGraph
217+
}) else {
218+
return []
216219
}
217-
guard let graph else { return [] }
218220
var fileDependencies: [String] = []
219221
fileDependencies.reserveCapacity(graph.modules.values.count * 10)
220222
for (_, moduleInfo) in graph.modules.sorted(byKey: { $0.moduleName < $1.moduleName }) {
@@ -238,14 +240,15 @@ public final class SwiftModuleDependencyGraph: SwiftGlobalExplicitDependencyGrap
238240
return fileDependencies
239241
}
240242

241-
public func queryTransitiveDependencyModuleNames(for key: String) throws -> [String] {
242-
let graph = try registryQueue.blocking_sync {
243-
guard let driver = registry[key] else {
244-
throw StubError.error("Unable to find jobs for key \(key). Be sure to plan the build ahead of fetching results.")
243+
public func queryTransitiveDependencyModuleNames(for key: String) async throws -> [String] {
244+
guard let graph: InterModuleDependencyGraph = await registryQueue.sync(execute: {
245+
guard let driver = self.registry[key] else {
246+
return nil
245247
}
246248
return driver.intermoduleDependencyGraph
249+
}) else {
250+
return []
247251
}
248-
guard let graph else { return [] }
249252
// This calculation is a bit awkward because we cannot directly access the ID of the main module, just its info object
250253
let directDependencies = graph.mainModule.directDependencies ?? []
251254
let transitiveDependencies = Set(directDependencies + SWBUtil.transitiveClosure(directDependencies, successors: { moduleID in graph.modules[moduleID]?.directDependencies ?? [] }).0)

Sources/SWBTaskExecution/TaskActions/SwiftDriverJobSchedulingTaskAction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ open class SwiftDriverJobSchedulingTaskAction: TaskAction {
221221
try reportSkippedJobs(task, outputDelegate: outputDelegate, driverPayload: driverPayload, plannedBuild: plannedBuild, dynamicExecutionDelegate: dynamicExecutionDelegate)
222222
}
223223

224-
let planningDependencies = try graph.queryPlanningDependencies(for: driverPayload.uniqueID)
224+
let planningDependencies = try await graph.queryPlanningDependencies(for: driverPayload.uniqueID)
225225
if executionDelegate.userPreferences.enableDebugActivityLogs {
226226
outputDelegate.emitOutput(ByteString(encodingAsUTF8: "Discovered dependency nodes:\n" + planningDependencies.joined(separator: "\n") + "\n"))
227227
}

Sources/SWBTaskExecution/TaskActions/SwiftDriverTaskAction.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ final public class SwiftDriverTaskAction: TaskAction, BuildValueValidatingTaskAc
9494
}
9595

9696
if driverPayload.reportRequiredTargetDependencies != .no && driverPayload.explicitModulesEnabled, let target = task.forTarget {
97-
let dependencyModuleNames = try dependencyGraph.queryTransitiveDependencyModuleNames(for: driverPayload.uniqueID)
97+
let dependencyModuleNames = try await dependencyGraph.queryTransitiveDependencyModuleNames(for: driverPayload.uniqueID)
9898
for dependencyModuleName in dependencyModuleNames {
9999
if let targetDependencies = dynamicExecutionDelegate.operationContext.definingTargetsByModuleName[dependencyModuleName] {
100100
for targetDependency in targetDependencies {
@@ -110,7 +110,7 @@ final public class SwiftDriverTaskAction: TaskAction, BuildValueValidatingTaskAc
110110
if let linkerResponseFilePath = driverPayload.linkerResponseFilePath {
111111
var responseFileCommandLine: [String] = []
112112
if driverPayload.explicitModulesEnabled {
113-
for swiftmodulePath in try dependencyGraph.querySwiftmodulesNeedingRegistrationForDebugging(for: driverPayload.uniqueID) {
113+
for swiftmodulePath in try await dependencyGraph.querySwiftmodulesNeedingRegistrationForDebugging(for: driverPayload.uniqueID) {
114114
responseFileCommandLine.append(contentsOf: ["-Xlinker", "-add_ast_path", "-Xlinker", "\(swiftmodulePath)"])
115115
}
116116
}

Sources/SWBUtil/HeavyCache.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -292,18 +292,6 @@ public final class HeavyCache<Key: Hashable, Value>: _HeavyCacheBase, KeyValueSt
292292
if let ttl = _timeToLive {
293293
// We always schedule at the requested TTL, on average an object will live 50% longer than the TTL.
294294
_timer?.cancel()
295-
_timer = Task { [weak self] in
296-
while !Task.isCancelled {
297-
if let self = self {
298-
self.preventExpiration {
299-
self.stateLock.withLock {
300-
self._pruneForTTL()
301-
}
302-
}
303-
}
304-
try await Task.sleep(for: ttl)
305-
}
306-
}
307295
} else {
308296
_timer?.cancel()
309297
_timer = nil

Tests/SwiftBuildTests/ProjectModel/CustomTaskTests.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ func testCodable<T>(
2222
_ line: Int = #line,
2323
_ column: Int = #column
2424
) throws where T: Codable & Equatable {
25-
var original = original
26-
if let modify { modify(&original) }
27-
let data = try JSONEncoder().encode(original)
28-
let obj = try JSONDecoder().decode(T.self, from: data)
29-
#expect(original == obj, sourceLocation: SourceLocation(fileID: fileID, filePath: filePath, line: line, column: column))
25+
3026
}
3127

3228
@Suite

0 commit comments

Comments
 (0)