Files
babaevmm 956c055cd8 update swiftformat, add organize rule
commit_hash:0f7ba811b37db6d2a9fc05efe5f94502feda4856
2025-08-04 16:24:48 +03:00

44 lines
1.3 KiB
Swift

import Foundation
enum TestData {
static let regressionPath = "regression_test_data"
static let samplesPath = "samples"
static let patchesPath = "regression_test_data/patches"
static var regressionTests: [RegressionTestModel] = {
let indexFileUrl = Bundle.main
.url(forResource: "index", withExtension: "json", subdirectory: regressionPath)!
let indexFileData = try! Data(contentsOf: indexFileUrl)
return try! JSONDecoder()
.decode(RegressionTestsModel.self, from: indexFileData)
.tests
.filter { $0.platforms.contains(.ios) }
.sorted { $0.title < $1.title }
}()
private static var cachedRegressionTests: [RegressionTestModel]?
static var samples: [URL] {
getAllFiles(path: samplesPath)
.map { url, _ in url }
}
private static func getAllFiles(path: String) -> [(URL, String)] {
getItems(path: path, extension: "")
.flatMap { _, folderName in
getAllFiles(path: "\(path)/\(folderName)")
}
+ getItems(path: path, extension: ".json")
}
private static func getItems(
path: String,
extension ext: String
) -> [(URL, String)] {
Bundle.main
.urls(forResourcesWithExtension: ext, subdirectory: path)!
.map { url in (url, String(url.lastPathComponent.split(separator: ".").first!)) }
.sorted { $0.1 < $1.1 }
}
}