From c9c68b2ff242f9e681a4e12a9a620524c7e3decc Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Tue, 12 Sep 2023 11:12:08 +0200 Subject: [PATCH] `group()`s work both on Android and iOS --- .../ios/Runner.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../ios/Classes/PatrolAppServiceClient.swift | 41 ++++++++++++++++++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/packages/patrol/example/ios/Runner.xcodeproj/project.pbxproj b/packages/patrol/example/ios/Runner.xcodeproj/project.pbxproj index 13a049c99..db11d1e62 100644 --- a/packages/patrol/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/patrol/example/ios/Runner.xcodeproj/project.pbxproj @@ -265,7 +265,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1430; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { diff --git a/packages/patrol/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/patrol/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 327fff847..05552f28c 100644 --- a/packages/patrol/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/patrol/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ RunDartTestResponse { @@ -58,3 +59,39 @@ import NIO ) } } + +extension Patrol_DartGroupEntry { + + func listTestsFlat(parentGroupName: String) -> [Patrol_DartGroupEntry] { + var tests = [Patrol_DartGroupEntry]() + + for test in self.entries { + if test.type == Patrol_DartGroupEntry.GroupEntryType.test { + if parentGroupName.isEmpty { + // This case is invalid, because every test will have at least + // 1 named group - its filename. + + continue // What else can we do? + } + + // TODO: There has to be some copy() function + tests.append( + .with { + $0.name = "\(parentGroupName) \(test.name)" + $0.fullName = test.fullName + $0.type = test.type + $0.entries = test.entries + }) + } else if test.type == Patrol_DartGroupEntry.GroupEntryType.group { + if parentGroupName.isEmpty { + tests.append(contentsOf: test.listTestsFlat(parentGroupName: test.name)) + } else { + tests.append( + contentsOf: test.listTestsFlat(parentGroupName: "\(parentGroupName) \(test.name)")) + } + } + } + + return tests + } +}