Skip to content

Commit ee95b8b

Browse files
authored
Merge pull request #30601 from lorentey/fortify-benchmarks
[benchmark] Package.swift: Don’t trap on stray files under single-source/
2 parents b63aeb0 + c1bf5c9 commit ee95b8b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

benchmark/Package.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ func getSingleSourceLibraries(subDirectory: String) -> [String] {
2222
let fileURLs = try! f.contentsOfDirectory(at: dirURL,
2323
includingPropertiesForKeys: nil)
2424
return fileURLs.compactMap { (path: URL) -> String? in
25-
let c = path.lastPathComponent.split(separator: ".")
26-
// Too many components. Must be a gyb file.
27-
if c.count > 2 {
28-
return nil
29-
}
30-
if c[1] != "swift" {
25+
guard let lastDot = path.lastPathComponent.lastIndex(of: ".") else {
3126
return nil
3227
}
28+
let ext = String(path.lastPathComponent.suffix(from: lastDot))
29+
guard ext == ".swift" else { return nil }
30+
31+
let name = String(path.lastPathComponent.prefix(upTo: lastDot))
3332

34-
let name = String(c[0])
33+
// Test names must have a single component.
34+
if name.contains(".") { return nil }
3535

36-
// We do not support this test.
3736
if unsupportedTests.contains(name) {
37+
// We do not support this test.
3838
return nil
3939
}
4040

0 commit comments

Comments
 (0)