Skip to content

Commit

Permalink
Add method to get logs
Browse files Browse the repository at this point in the history
  • Loading branch information
felginep committed Oct 7, 2019
1 parent b83571a commit 6386d58
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Sources/XCResultKit/XCResultFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ public class XCResultFile {
return nil
}
}

public func getLogs(id: String) -> ActivityLogSection? {
guard let getOutput = shell(command: ["-l", "-c", "xcrun xcresulttool get --path \(url.path) --id \(id) --format json"]) else {
return nil
}

do {
guard let data = getOutput.data(using: .utf8) else {
debug("Unable to turn string into data, must not be a utf8 string")
return nil
}
guard let rootJSON = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: AnyObject] else {
debug("Expecting top level dictionary but didn't find one")
return nil
}

return ActivityLogSection(rootJSON)
} catch {
debug("Error deserializing JSON: \(error)")
return nil
}
}

public func getActionTestSummary(id: String) -> ActionTestSummary? {

Expand Down

0 comments on commit 6386d58

Please sign in to comment.