Supported subdirectories in integration tests data

commit_hash:a8efe4fbf4f156ff212dca5cb3316d4d9770e004
This commit is contained in:
burstein
2025-06-16 13:33:58 +03:00
parent 5c6992bc35
commit 777aef5959
19 changed files with 44 additions and 38 deletions
+15 -14
View File
@@ -14146,6 +14146,7 @@
"client/ios/DivKitTests/Utils/Assert.swift":"divkit/public/client/ios/DivKitTests/Utils/Assert.swift",
"client/ios/DivKitTests/Utils/BlockModelingUtils.swift":"divkit/public/client/ios/DivKitTests/Utils/BlockModelingUtils.swift",
"client/ios/DivKitTests/Utils/DivBuilders.swift":"divkit/public/client/ios/DivKitTests/Utils/DivBuilders.swift",
"client/ios/DivKitTests/Utils/FilesProvider.swift":"divkit/public/client/ios/DivKitTests/Utils/FilesProvider.swift",
"client/ios/DivKitTests/Variables/DivTriggersStorageTests.swift":"divkit/public/client/ios/DivKitTests/Variables/DivTriggersStorageTests.swift",
"client/ios/DivKitTests/Variables/DivVariableStorageTests.swift":"divkit/public/client/ios/DivKitTests/Variables/DivVariableStorageTests.swift",
"client/ios/DivKitTests/Variables/DivVariableStorageWithOuterStorageTests.swift":"divkit/public/client/ios/DivKitTests/Variables/DivVariableStorageWithOuterStorageTests.swift",
@@ -20667,22 +20668,22 @@
"test_data/expression_test_data/variables_names.json":"divkit/public/test_data/expression_test_data/variables_names.json",
"test_data/expression_test_data/variables_values.json":"divkit/public/test_data/expression_test_data/variables_values.json",
"test_data/expression_test_data/whitespace.json":"divkit/public/test_data/expression_test_data/whitespace.json",
"test_data/integration_test_data/decl_expressions_cycle.json":"divkit/public/test_data/integration_test_data/decl_expressions_cycle.json",
"test_data/integration_test_data/decl_expressions_item_builder.json":"divkit/public/test_data/integration_test_data/decl_expressions_item_builder.json",
"test_data/integration_test_data/decl_expressions_item_builder_override.json":"divkit/public/test_data/integration_test_data/decl_expressions_item_builder_override.json",
"test_data/integration_test_data/decl_expressions_nesting.json":"divkit/public/test_data/integration_test_data/decl_expressions_nesting.json",
"test_data/integration_test_data/decl_expressions_simple.json":"divkit/public/test_data/integration_test_data/decl_expressions_simple.json",
"test_data/integration_test_data/decl_expressions_transitive.json":"divkit/public/test_data/integration_test_data/decl_expressions_transitive.json",
"test_data/integration_test_data/decl_expressions/decl_expressions_cycle.json":"divkit/public/test_data/integration_test_data/decl_expressions/decl_expressions_cycle.json",
"test_data/integration_test_data/decl_expressions/decl_expressions_item_builder.json":"divkit/public/test_data/integration_test_data/decl_expressions/decl_expressions_item_builder.json",
"test_data/integration_test_data/decl_expressions/decl_expressions_item_builder_override.json":"divkit/public/test_data/integration_test_data/decl_expressions/decl_expressions_item_builder_override.json",
"test_data/integration_test_data/decl_expressions/decl_expressions_nesting.json":"divkit/public/test_data/integration_test_data/decl_expressions/decl_expressions_nesting.json",
"test_data/integration_test_data/decl_expressions/decl_expressions_simple.json":"divkit/public/test_data/integration_test_data/decl_expressions/decl_expressions_simple.json",
"test_data/integration_test_data/decl_expressions/decl_expressions_transitive.json":"divkit/public/test_data/integration_test_data/decl_expressions/decl_expressions_transitive.json",
"test_data/integration_test_data/expression_with_several_local_functions.json":"divkit/public/test_data/integration_test_data/expression_with_several_local_functions.json",
"test_data/integration_test_data/item_builder_variable_triggers.json":"divkit/public/test_data/integration_test_data/item_builder_variable_triggers.json",
"test_data/integration_test_data/local_functions_array.json":"divkit/public/test_data/integration_test_data/local_functions_array.json",
"test_data/integration_test_data/local_functions_color.json":"divkit/public/test_data/integration_test_data/local_functions_color.json",
"test_data/integration_test_data/local_functions_datetime.json":"divkit/public/test_data/integration_test_data/local_functions_datetime.json",
"test_data/integration_test_data/local_functions_dict.json":"divkit/public/test_data/integration_test_data/local_functions_dict.json",
"test_data/integration_test_data/local_functions_int.json":"divkit/public/test_data/integration_test_data/local_functions_int.json",
"test_data/integration_test_data/local_functions_number.json":"divkit/public/test_data/integration_test_data/local_functions_number.json",
"test_data/integration_test_data/local_functions_string.json":"divkit/public/test_data/integration_test_data/local_functions_string.json",
"test_data/integration_test_data/local_functions_url.json":"divkit/public/test_data/integration_test_data/local_functions_url.json",
"test_data/integration_test_data/local_functions/local_functions_array.json":"divkit/public/test_data/integration_test_data/local_functions/local_functions_array.json",
"test_data/integration_test_data/local_functions/local_functions_color.json":"divkit/public/test_data/integration_test_data/local_functions/local_functions_color.json",
"test_data/integration_test_data/local_functions/local_functions_datetime.json":"divkit/public/test_data/integration_test_data/local_functions/local_functions_datetime.json",
"test_data/integration_test_data/local_functions/local_functions_dict.json":"divkit/public/test_data/integration_test_data/local_functions/local_functions_dict.json",
"test_data/integration_test_data/local_functions/local_functions_int.json":"divkit/public/test_data/integration_test_data/local_functions/local_functions_int.json",
"test_data/integration_test_data/local_functions/local_functions_number.json":"divkit/public/test_data/integration_test_data/local_functions/local_functions_number.json",
"test_data/integration_test_data/local_functions/local_functions_string.json":"divkit/public/test_data/integration_test_data/local_functions/local_functions_string.json",
"test_data/integration_test_data/local_functions/local_functions_url.json":"divkit/public/test_data/integration_test_data/local_functions/local_functions_url.json",
"test_data/integration_test_data/set_dict_variable.json":"divkit/public/test_data/integration_test_data/set_dict_variable.json",
"test_data/integration_test_data/typed_action_priority.json":"divkit/public/test_data/integration_test_data/typed_action_priority.json",
"test_data/interactive_snapshot_test_data/div-action/array-variable-mutation.json":"divkit/public/test_data/interactive_snapshot_test_data/div-action/array-variable-mutation.json",
@@ -287,6 +287,7 @@
9D08688F2DCE3C0900C5B2CC /* IntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D08688E2DCE3C0400C5B2CC /* IntegrationTests.swift */; };
9D0868BB2DD10F7E00C5B2CC /* integration_test_data in Resources */ = {isa = PBXBuildFile; fileRef = 9D0868BA2DD10F7E00C5B2CC /* integration_test_data */; };
9D09984F2CA30D010098098C /* AccessoryViewProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D09984E2CA30D010098098C /* AccessoryViewProvider.swift */; };
9D5AE8362DFC680500D58B81 /* FilesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D5AE8352DFC680300D58B81 /* FilesProvider.swift */; };
9D5BFB092CA1DA20005F8EB1 /* CustomFunctionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D5BFB082CA1DA20005F8EB1 /* CustomFunctionTests.swift */; };
9DD0C78A2D74ABB4009EA1AF /* SubmitActionHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD0C7892D74AB7E009EA1AF /* SubmitActionHandlerTests.swift */; };
9DEA2C752DDCC63400A074B5 /* RobotoFlex-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 9DEA2C742DDCC63400A074B5 /* RobotoFlex-Regular.ttf */; };
@@ -658,6 +659,7 @@
9D08688E2DCE3C0400C5B2CC /* IntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntegrationTests.swift; sourceTree = "<group>"; };
9D0868BA2DD10F7E00C5B2CC /* integration_test_data */ = {isa = PBXFileReference; lastKnownFileType = folder; name = integration_test_data; path = ../../../test_data/integration_test_data; sourceTree = "<group>"; };
9D09984E2CA30D010098098C /* AccessoryViewProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessoryViewProvider.swift; sourceTree = "<group>"; };
9D5AE8352DFC680300D58B81 /* FilesProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilesProvider.swift; sourceTree = "<group>"; };
9D5BFB082CA1DA20005F8EB1 /* CustomFunctionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomFunctionTests.swift; sourceTree = "<group>"; };
9DD0C7892D74AB7E009EA1AF /* SubmitActionHandlerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubmitActionHandlerTests.swift; sourceTree = "<group>"; };
9DEA2C742DDCC63400A074B5 /* RobotoFlex-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "RobotoFlex-Regular.ttf"; sourceTree = "<group>"; };
@@ -1418,6 +1420,7 @@
8CF8BBE62B3265E000569777 /* Utils */ = {
isa = PBXGroup;
children = (
9D5AE8352DFC680300D58B81 /* FilesProvider.swift */,
8CF8BBE42B322E3100569777 /* Assert.swift */,
8CF8BBE72B32660500569777 /* BlockModelingUtils.swift */,
8CF8BBE92B32682700569777 /* DivBuilders.swift */,
@@ -2074,6 +2077,7 @@
8C0DC7122865CA1100286F6B /* DivKitTests.swift in Sources */,
8C1233AB2C32F08600F534DC /* DivFontProviderTests.swift in Sources */,
8C7B1BF62865C01C0036EF4C /* DivTextExtensionsTests.swift in Sources */,
9D5AE8362DFC680500D58B81 /* FilesProvider.swift in Sources */,
8C23F41A29DDB3810069F3F7 /* EntityWithArrayTemplate.swift in Sources */,
8C84C2232D0870F400A574AC /* ScrollActionHandlerTests.swift in Sources */,
8C23F41929DDB3810069F3F7 /* EntityWithArrayOfNestedItemsTemplate.swift in Sources */,
@@ -25,23 +25,11 @@ private func runTest(_ data: TestData) {
)
}
private func getFiles(_ path: String) -> [URL] {
let bundle = Bundle(for: DivDataParsingTests.self)
var files: [URL] = []
try! FileManager.default
.contentsOfDirectory(atPath: bundle.path(forResource: path, ofType: nil)!)
.forEach {
if $0.hasSuffix(".json") {
files.append(bundle.url(forResource: $0, withExtension: nil, subdirectory: path)!)
} else {
files.append(contentsOf: getFiles("\(path)/\($0)"))
}
}
return files
}
private func makeTestCases() -> [(String, TestData)] {
try! getFiles("parsing_test_data").map { url in
try! getFiles(
"parsing_test_data",
forBundle: Bundle(for: DivDataParsingTests.self)
).map { url in
let testName = url.pathComponents
.trimmingPrefix { $0 != "parsing_test_data" }
.dropFirst()
@@ -23,14 +23,15 @@ final class IntegrationTests: XCTestCase {
}
private func makeTestCases() -> [(String, IntegrationTestData)] {
Bundle(for: DivKitTests.self)
.urls(forResourcesWithExtension: "json", subdirectory: "integration_test_data")!
.map { url in
let fileName = url.lastPathComponent
let testData = try! JSONDecoder()
.decode(IntegrationTestData.self, from: Data(contentsOf: url))
return ("\(fileName): \(testData.description)", testData)
}
getFiles(
"integration_test_data",
forBundle: Bundle(for: IntegrationTests.self)
).map { url in
let fileName = url.lastPathComponent
let testData = try! JSONDecoder()
.decode(IntegrationTestData.self, from: Data(contentsOf: url))
return ("\(fileName): \(testData.description)", testData)
}
}
private func createDivView(_ divData: DivData, components: DivKitComponents) async {
@@ -0,0 +1,12 @@
import Foundation
func getFiles(_ path: String, forBundle bundle: Bundle) -> [URL] {
guard let enumerator = FileManager.default.enumerator(
atPath: bundle.path(forResource: path, ofType: nil)!
) else { return [] }
return enumerator.compactMap {
guard let fileName = $0 as? String, fileName.hasSuffix(".json") else { return nil }
return bundle.url(forResource: fileName, withExtension: nil, subdirectory: path)!
}
}