Skip to content

Commit d872d20

Browse files
committed
=regex workaround for crashes on String.starts(with:) caused by rdar://98691039
1 parent 2d72e32 commit d872d20

File tree

6 files changed

+21
-24
lines changed

6 files changed

+21
-24
lines changed

Sources/DistributedActorsTestKit/Cluster/ClusteredActorSystemsXCTestCase.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,18 @@ open class ClusteredActorSystemsXCTestCase: XCTestCase {
9696
self.actorStatsBefore = try InspectKit.actorStats()
9797
}
9898

99-
self.stuckTestDumpLogsTask = Task.detached {
100-
try await Task.sleep(until: .now + self.dumpLogsAfter, clock: .continuous)
101-
guard !Task.isCancelled else {
102-
return
103-
}
104-
105-
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
106-
print("!!!!!!!!!! TEST SEEMS STUCK - DUMPING LOGS !!!!!!!!!!")
107-
print("!!!!!!!!!! PID: \(ProcessInfo.processInfo.processIdentifier) !!!!!!!!!!")
108-
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
109-
self.printAllCapturedLogs()
110-
}
99+
// self.stuckTestDumpLogsTask = Task.detached {
100+
// try await Task.sleep(until: .now + self.dumpLogsAfter, clock: .continuous)
101+
// guard !Task.isCancelled else {
102+
// return
103+
// }
104+
//
105+
// print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
106+
// print("!!!!!!!!!! TEST SEEMS STUCK - DUMPING LOGS !!!!!!!!!!")
107+
// print("!!!!!!!!!! PID: \(ProcessInfo.processInfo.processIdentifier) !!!!!!!!!!")
108+
// print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
109+
// self.printAllCapturedLogs()
110+
// }
111111
try await super.setUp()
112112
}
113113

Sources/DistributedActorsTestKit/InspectKit.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import Foundation
16-
#if swift(>=5.8.0)
1716
// FIXME(regex): rdar://98705227 can't use regex on 5.7 on Linux because of a bug that crashes String.starts(with:) at runtime then
1817
import RegexBuilder
19-
#endif
2018
import XCTest
2119

2220
internal struct InspectKit {
@@ -146,7 +144,6 @@ internal struct InspectKit {
146144

147145
/// Actor names to their counts
148146
static func actorStats() throws -> ActorStats {
149-
#if swift(>=5.8.0)
150147
// FIXME(regex): rdar://98705227 can't use regex on 5.7 on Linux because of a bug that crashes String.starts(with:) at runtime then
151148
let (out, err, _) = Self.runCommand(cmd: "\(self.baseDir)/scripts/dump_actors.sh")
152149

@@ -175,9 +172,6 @@ internal struct InspectKit {
175172
}
176173

177174
return ActorStats(stats: stats)
178-
#else
179-
return .init()
180-
#endif
181175
}
182176
}
183177

Sources/DistributedActorsTestKit/LogCapture.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ struct LogCaptureLogHandler: LogHandler {
204204
public func log(level: Logger.Level, message: Logger.Message, metadata: Logger.Metadata?, file: String, function: String, line: UInt) {
205205
let actorPath = self.metadata["actor/path"].map { "\($0)" } ?? ""
206206

207-
guard self.capture.settings.filterActorPaths.contains(where: { path in actorPath.starts(with: path) }) else {
207+
guard self.capture.settings.filterActorPaths.contains(where: { path in
208+
if (path == "") { // TODO(swift): rdar://98691039 String.starts(with:) has a bug when given an empty string, so we have to avoid it
209+
return true
210+
}
211+
212+
return actorPath.starts(with: path)
213+
}) else {
208214
return // ignore this actor's logs, it was filtered out
209215
}
210216
guard !self.capture.settings.excludeActorPaths.contains(actorPath) else {

Sources/MultiNodeTestKitRunner/boot+MultiNodeTestKitRunner+Exec.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,4 @@ extension MultiNodeTestKitRunnerBoot {
135135
}
136136
return .init(uniqueKeysWithValues: nodeList)
137137
}
138-
139138
}

Sources/MultiNodeTestKitRunner/boot+MultiNodeTestKitRunner+Test.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import ArgumentParser
1616
import DistributedActors
1717
import struct Foundation.Date
1818
import class Foundation.FileHandle
19-
import class Foundation.Process
19+
@preconcurrency import class Foundation.Process
2020
import class Foundation.ProcessInfo
2121
import struct Foundation.URL
2222
import MultiNodeTestKit
@@ -237,7 +237,6 @@ extension MultiNodeTestKitRunnerBoot {
237237
process.terminate()
238238
}
239239
}
240-
241240
}
242241

243242
struct NodeInterpretedRunResult {

Tests/DistributedActorsTests/ClusterSystem+ActorTransportTests.swift renamed to Tests/DistributedActorsTests/BasicClusterSystemLifecycleTests.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
import DistributedActorsTestKit
1717
import XCTest
1818

19-
// FIXME: rename
20-
final class ActorSystemTransportTests: SingleClusterSystemXCTestCase, @unchecked Sendable {
19+
final class BasicClusterSystemLifecycleTests: SingleClusterSystemXCTestCase, @unchecked Sendable {
2120
func test_system_shouldAssignIdentityAndReadyActor() async throws {
2221
try runAsyncAndBlock {
2322
let first = await setUpNode("first")

0 commit comments

Comments
 (0)