Skip to content

Commit

Permalink
group()s work both on Android and iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekpacia committed Sep 12, 2023
1 parent 85aa81f commit c9c68b2
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1430;
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
41 changes: 39 additions & 2 deletions packages/patrol/ios/Classes/PatrolAppServiceClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ import NIO
let request = Patrol_Empty()
let response = try await client.listDartTests(request)

return response.group.entries.map {
NSLog("RAW: Got tests: \(response.group)")

return response.group.listTestsFlat(parentGroupName: "").map {
$0.name
}
// return response.group.groups.map { $0.name }
}

@objc public func runDartTest(name: String) async throws -> RunDartTestResponse {
Expand All @@ -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
}
}

0 comments on commit c9c68b2

Please sign in to comment.