Skip to content

Commit

Permalink
Merge pull request #3 from felginep/feature/improvements
Browse files Browse the repository at this point in the history
Feature/improvements
  • Loading branch information
davidahouse authored Oct 4, 2019
2 parents 8434203 + 809aec1 commit bcfaf47
Show file tree
Hide file tree
Showing 31 changed files with 98 additions and 61 deletions.
2 changes: 1 addition & 1 deletion Sources/XCResultKit/ActionDeviceRecord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public struct ActionDeviceRecord: XCResultObject {
logicalCPUCoresPerPackage = xcOptional(element: "logicalCPUCoresPerPackage", from: json)
platformRecord = try xcRequired(element: "platformRecord", from: json)
} catch {
print("Error initializing from json: \(error.localizedDescription)")
debug("Error parsing ActionDeviceRecord: \(error.localizedDescription)")
return nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XCResultKit/ActionPlatformRecord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public struct ActionPlatformRecord: XCResultObject {
identifier = try xcRequired(element: "identifier", from: json)
userDescription = try xcRequired(element: "userDescription", from: json)
} catch {
print("Error parsing ActionPlatformRecord: \(error.localizedDescription)")
debug("Error parsing ActionPlatformRecord: \(error.localizedDescription)")
return nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XCResultKit/ActionRecord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public struct ActionRecord: XCResultObject {
endedTime = try xcRequired(element: "endedTime", from: json)
runDestination = try xcRequired(element: "runDestination", from: json)
} catch {
print("Error parsing ActionRecord: \(error.localizedDescription)")
debug("Error parsing ActionRecord: \(error.localizedDescription)")
return nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XCResultKit/ActionResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public struct ActionResult: XCResultObject {
testsRef = xcOptional(element: "testsRef", from: json)
diagnosticsRef = xcOptional(element: "diagnosticsRef", from: json)
} catch {
print("Error parsing ActionResult: \(error.localizedDescription)")
debug("Error parsing ActionResult: \(error.localizedDescription)")
return nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XCResultKit/ActionRunDestinationRecord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public struct ActionRunDestinationRecord: XCResultObject {
localComputerRecord = try xcRequired(element: "localComputerRecord", from: json)
targetSDKRecord = try xcRequired(element: "targetSDKRecord", from: json)
} catch {
print("Error parsing ActionRunDestinationRecord: \(error.localizedDescription)")
debug("Error parsing ActionRunDestinationRecord: \(error.localizedDescription)")
return nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XCResultKit/ActionSDKRecord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public struct ActionSDKRecord: XCResultObject {
operatingSystemVersion = try xcRequired(element: "operatingSystemVersion", from: json)
isInternal = xcOptional(element: "isInternal", from: json)
} catch {
print("Error parsing ActionSDKRecord: \(error.localizedDescription)")
debug("Error parsing ActionSDKRecord: \(error.localizedDescription)")
return nil
}
}
Expand Down
8 changes: 5 additions & 3 deletions Sources/XCResultKit/ActionTestActivitySummary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ public struct ActionTestActivitySummary: XCResultObject {
uuid = try xcRequired(element: "uuid", from: json)
start = xcOptional(element: "start", from: json)
finish = xcOptional(element: "finish", from: json)
attachments = xcArray(element: "attachments", from: json).compactMap { ActionTestAttachment($0) }
subactivities = xcArray(element: "subactivities", from: json).compactMap { ActionTestActivitySummary($0) }
attachments = xcArray(element: "attachments", from: json)
.ofType(ActionTestAttachment.self)
subactivities = xcArray(element: "subactivities", from: json)
.ofType(ActionTestActivitySummary.self)
} catch {
print("Error parsing ActionTestActivitySummary: \(error.localizedDescription)")
debug("Error parsing ActionTestActivitySummary: \(error.localizedDescription)")
return nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XCResultKit/ActionTestAttachment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public struct ActionTestAttachment: XCResultObject {
payloadRef = xcOptional(element: "payloadRef", from: json)
payloadSize = try xcRequired(element: "payloadSize", from: json)
} catch {
print("Error parsing ActionTestAttachment: \(error.localizedDescription)")
debug("Error parsing ActionTestAttachment: \(error.localizedDescription)")
return nil
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/XCResultKit/ActionTestFailureSummary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public struct ActionTestFailureSummary: XCResultObject {
message = xcOptional(element: "message", from: json)
fileName = try xcRequired(element: "fileName", from: json)
lineNumber = try xcRequired(element: "lineNumber", from: json)
isPerformanceFailure = try xcRequired(element: "isPerformanceFailure", from: json)
isPerformanceFailure = xcOptional(element: "isPerformanceFailure", from: json) ?? false
} catch {
print("Error parsing ActionTestFailureSummary: \(error.localizedDescription)")
debug("Error parsing ActionTestFailureSummary: \(error.localizedDescription)")
return nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XCResultKit/ActionTestMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public struct ActionTestMetadata: XCResultObject {
failureSummariesCount = xcOptional(element: "failureSummariesCount", from: json)
activitySummariesCount = xcOptional(element: "activitySummariesCount", from: json)
} catch {
print("Error parsing ActionTestMetadata: \(error.localizedDescription)")
debug("Error parsing ActionTestMetadata: \(error.localizedDescription)")
return nil
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/XCResultKit/ActionTestPerformanceMetricSummary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public struct ActionTestPerformanceMetricSummary: XCResultObject {
do {
displayName = try xcRequired(element: "displayName", from: json)
unitOfMeasurement = try xcRequired(element: "unitOfMeasurement", from: json)
measurements = xcArray(element: "measurements", from: json).compactMap { Double($0) }
measurements = xcArray(element: "measurements", from: json).ofType(Double.self)
identifier = xcOptional(element: "identifier", from: json)
baselineName = xcOptional(element: "baselineName", from: json)
baselineAverage = xcOptional(element: "baselineAverage", from: json)
Expand All @@ -45,7 +45,7 @@ public struct ActionTestPerformanceMetricSummary: XCResultObject {
maxRegression = xcOptional(element: "maxRegression", from: json)
maxStandardDeviation = xcOptional(element: "maxStandardDeviation", from: json)
} catch {
print("Error parsing ActionTestPerformanceMetricSummary: \(error.localizedDescription)")
debug("Error parsing ActionTestPerformanceMetricSummary: \(error.localizedDescription)")
return nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XCResultKit/ActionTestPlanRunSummaries.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public struct ActionTestPlanRunSummaries: XCResultObject {
public let summaries: [ActionTestPlanRunSummary]

public init?(_ json: [String : AnyObject]) {
summaries = xcArray(element: "summaries", from: json).compactMap { ActionTestPlanRunSummary($0) }
summaries = xcArray(element: "summaries", from: json).ofType(ActionTestPlanRunSummary.self)
}
}
4 changes: 2 additions & 2 deletions Sources/XCResultKit/ActionTestPlanRunSummary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public struct ActionTestPlanRunSummary: XCResultObject {
public init?(_ json: [String : AnyObject]) {
do {
name = try xcRequired(element: "name", from: json)
testableSummaries = xcArray(element: "testableSummaries", from: json).compactMap { ActionTestableSummary($0) }
testableSummaries = xcArray(element: "testableSummaries", from: json).ofType(ActionTestableSummary.self)
} catch {
print("Error parsing ActionTestMetadata: \(error.localizedDescription)")
debug("Error parsing ActionTestPlanRunSummary: \(error.localizedDescription)")
return nil
}
}
Expand Down
11 changes: 7 additions & 4 deletions Sources/XCResultKit/ActionTestSummary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ public struct ActionTestSummary: XCResultObject {
identifier = try xcRequired(element: "identifier", from: json)
testStatus = try xcRequired(element: "testStatus", from: json)
duration = try xcRequired(element: "duration", from: json)
performanceMetrics = xcArray(element: "performanceMetrics", from: json).compactMap { ActionTestPerformanceMetricSummary($0) }
failureSummaries = xcArray(element: "failureSummaries", from: json).compactMap { ActionTestFailureSummary($0) }
activitySummaries = xcArray(element: "activitySummaries", from: json).compactMap { ActionTestActivitySummary($0) }
performanceMetrics = xcArray(element: "performanceMetrics", from: json)
.ofType(ActionTestPerformanceMetricSummary.self)
failureSummaries = xcArray(element: "failureSummaries", from: json)
.ofType(ActionTestFailureSummary.self)
activitySummaries = xcArray(element: "activitySummaries", from: json)
.ofType(ActionTestActivitySummary.self)
} catch {
print("Error parsing ActionTestSummary: \(error.localizedDescription)")
debug("Error parsing ActionTestSummary: \(error.localizedDescription)")
return nil
}
}
Expand Down
8 changes: 5 additions & 3 deletions Sources/XCResultKit/ActionTestSummaryGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ public struct ActionTestSummaryGroup: XCResultObject {
name = try xcRequired(element: "name", from: json)
identifier = try xcRequired(element: "identifier", from: json)
duration = try xcRequired(element: "duration", from: json)
subtestGroups = xcArray(element: "subtests", from: json).compactMap { ActionTestSummaryGroup($0) }
subtests = xcArray(element: "subtests", from: json).compactMap { ActionTestMetadata($0) }
subtestGroups = xcArray(element: "subtests", from: json)
.ofType(ActionTestSummaryGroup.self)
subtests = xcArray(element: "subtests", from: json)
.ofType(ActionTestMetadata.self)
} catch {
print("Error parsing ActionTestSummaryGroup: \(error.localizedDescription)")
debug("Error parsing ActionTestSummaryGroup: \(error.localizedDescription)")
return nil
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/XCResultKit/ActionTestableSummary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public struct ActionTestableSummary: XCResultObject {
projectRelativePath = xcOptional(element: "projectRelativePath", from: json)
targetName = xcOptional(element: "targetName", from: json)
testKind = xcOptional(element: "testKind", from: json)
tests = xcArray(element: "tests", from: json).compactMap { ActionTestSummaryGroup($0) }
tests = xcArray(element: "tests", from: json).ofType(ActionTestSummaryGroup.self)
diagnosticsDirectoryName = xcOptional(element: "diagnosticsDirectoryName", from: json)
failureSummaries = xcArray(element: "failureSummaries", from: json).compactMap { ActionTestFailureSummary($0) }
failureSummaries = xcArray(element: "failureSummaries", from: json).ofType(ActionTestFailureSummary.self)
testLanguage = xcOptional(element: "testLanguage", from: json)
testRegion = xcOptional(element: "testRegion", from: json)
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/XCResultKit/ActionsInvocationRecord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public struct ActionsInvocationRecord: XCResultObject {
issues = try xcRequired(element: "issues", from: json)
metadataRef = xcOptional(element: "metadataRef", from: json)
archive = xcOptional(element: "archive", from: json)
actions = xcArray(element: "actions", from: json).compactMap { ActionRecord($0) }
actions = xcArray(element: "actions", from: json).ofType(ActionRecord.self)
} catch {
print("Error parsing ActionsInvocationRecord: \(error.localizedDescription)")
debug("Error parsing ActionsInvocationRecord: \(error.localizedDescription)")
return nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XCResultKit/DocumentLocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public struct DocumentLocation: XCResultObject {
url = try xcRequired(element: "url", from: json)
concreteTypeName = try xcRequired(element: "concreteTypeName", from: json)
} catch {
print("Error parsing DocumentLocation: \(error.localizedDescription)")
debug("Error parsing DocumentLocation: \(error.localizedDescription)")
return nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XCResultKit/IssueSummary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public struct IssueSummary: XCResultObject {
producingTarget = xcOptional(element: "producingTarget", from: json)
documentLocationInCreatingWorkspace = xcOptional(element: "documentLocationInCreatingWorkspace", from: json)
} catch {
print("Error parsing IssueSummary: \(error.localizedDescription)")
debug("Error parsing IssueSummary: \(error.localizedDescription)")
return nil
}
}
Expand Down
15 changes: 15 additions & 0 deletions Sources/XCResultKit/Logger.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Logger.swift
// Rainbow
//
// Created by Pierre Felgines on 04/10/2019.
//

import Foundation

/// Log message only in debug environment
func debug(_ message: String) {
#if DEBUG
print(message)
#endif
}
2 changes: 1 addition & 1 deletion Sources/XCResultKit/Reference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public struct Reference: XCResultObject {
id = try xcRequired(element: "id", from: json)
targetType = xcOptional(element: "targetType", from: json)
} catch {
print("Error parsing Reference: \(error.localizedDescription)")
debug("Error parsing Reference: \(error.localizedDescription)")
return nil
}
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/XCResultKit/ResultIssueSummaries.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public struct ResultIssueSummaries: XCResultObject {
public let warningSummaries: [IssueSummary]

public init?(_ json: [String: AnyObject]) {
analyzerWarningSummaries = xcArray(element: "analyzerWarningSummaries", from: json).compactMap { IssueSummary($0) }
errorSummaries = xcArray(element: "errorSummaries", from: json).compactMap { IssueSummary($0) }
testFailureSummaries = xcArray(element: "testFailureSummaries", from: json).compactMap { TestFailureIssueSummary($0) }
warningSummaries = xcArray(element: "warningSummaries", from: json).compactMap { IssueSummary($0) }
analyzerWarningSummaries = xcArray(element: "analyzerWarningSummaries", from: json).ofType(IssueSummary.self)
errorSummaries = xcArray(element: "errorSummaries", from: json).ofType(IssueSummary.self)
testFailureSummaries = xcArray(element: "testFailureSummaries", from: json).ofType(TestFailureIssueSummary.self)
warningSummaries = xcArray(element: "warningSummaries", from: json).ofType(IssueSummary.self)
}
}
2 changes: 1 addition & 1 deletion Sources/XCResultKit/TestFailureIssueSummary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public struct TestFailureIssueSummary: XCResultObject {
producingTarget = xcOptional(element: "producingTarget", from: json)
documentLocationInCreatingWorkspace = xcOptional(element: "documentLocationInCreatingWorkspace", from: json)
} catch {
print("Error parsing ResultMetrics: \(error.localizedDescription)")
debug("Error parsing TestFailureIssueSummary: \(error.localizedDescription)")
return nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XCResultKit/TypeDefinition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public struct TypeDefinition: XCResultObject {
do {
name = try xcRequired(element: "name", from: json)
} catch {
print("Error parsing TypeDefinition: \(error.localizedDescription)")
debug("Error parsing TypeDefinition: \(error.localizedDescription)")
return nil
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/XCResultKit/XCResultBool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ extension Bool: XCResultObject {
public init?(_ json: [String: AnyObject]) {
// Ensure we have the correct type here
guard let type = json["_type"] as? [String: AnyObject], let name = type["_name"] as? String, name == "Bool" else {
print("Incorrect type, expecting Bool")
debug("Incorrect type, expecting Bool")
return nil
}

guard let actualValue = json["_value"] as? NSString else {
print("Unable to get bool value")
debug("Unable to get bool value")
return nil
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/XCResultKit/XCResultDate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ extension Date: XCResultObject {
public init?(_ json: [String: AnyObject]) {
// Ensure we have the correct type here
guard let type = json["_type"] as? [String: AnyObject], let name = type["_name"] as? String, name == "Date" else {
print("Incorrect type, expecting Date")
debug("Incorrect type, expecting Date")
return nil
}

guard let actualValue = json["_value"] as? NSString else {
print("Unable to get date value")
debug("Unable to get date value")
return nil
}

guard let date = Date.isoFormatter.date(from:actualValue as String) else {
print("error parsing date: \(actualValue as String)")
debug("error parsing date: \(actualValue as String)")
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/XCResultKit/XCResultDouble.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ extension Double: XCResultObject {
public init?(_ json: [String: AnyObject]) {
// Ensure we have the correct type here
guard let type = json["_type"] as? [String: AnyObject], let name = type["_name"] as? String, name == "Double" else {
print("Incorrect type, expecting Int")
debug("Incorrect type, expecting Double")
return nil
}

guard let actualValue = json["_value"] as? NSString else {
print("Unable to get double value")
debug("Unable to get double value")
return nil
}

Expand Down
Loading

0 comments on commit bcfaf47

Please sign in to comment.