Skip to content

Commit 65f9497

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

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

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 false
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 {

0 commit comments

Comments
 (0)