Skip to content

Commit 4ea0bfe

Browse files
committed
Examples
1 parent 8cc93ef commit 4ea0bfe

153 files changed

Lines changed: 2706 additions & 12 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CodeCoverageCompare/CodeCoverageCompare.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@
257257
isa = XCBuildConfiguration;
258258
buildSettings = {
259259
CODE_SIGN_STYLE = Automatic;
260-
DEVELOPMENT_TEAM = N4T6W27592;
260+
DEVELOPMENT_TEAM = CY96495443;
261261
PRODUCT_NAME = "$(TARGET_NAME)";
262262
SWIFT_VERSION = 5.0;
263263
};
@@ -267,7 +267,7 @@
267267
isa = XCBuildConfiguration;
268268
buildSettings = {
269269
CODE_SIGN_STYLE = Automatic;
270-
DEVELOPMENT_TEAM = N4T6W27592;
270+
DEVELOPMENT_TEAM = CY96495443;
271271
PRODUCT_NAME = "$(TARGET_NAME)";
272272
SWIFT_VERSION = 5.0;
273273
};

CodeCoverageCompare/CodeCoverageCompare/main.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,13 @@
99
import Foundation
1010
import CodeCoverageFramework
1111

12-
let coverage = "//Users/michael.charland/git/CodeCoverageCompare/example/coverage.json"
12+
let coverage = "//Users/michael/Documents/git/CodeCoverageCompare/example/coverage.json"
1313

1414
let url = URL(fileURLWithPath: coverage)
15-
do {
1615
let data = try Data(contentsOf: url)
1716
let jsonResult = try JSONSerialization.jsonObject(with: data, options: .mutableLeaves)
18-
if let jsonResult = jsonResult as? Dictionary<String, AnyObject>, let person = jsonResult["person"] as? [Any] {
19-
// do stuff
17+
if let jsonResult = jsonResult as? Dictionary<String, AnyObject>, let person = jsonResult["removedTargets"] as? [Any] {
18+
print(person)
2019
}
21-
} catch {
22-
// handle error
23-
}
2420

2521
//CodeCoverage.go(fileA: a, fileB: b)

CodeCoverageFramework/CodeCoverageFramework.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
4C61E9CF226B91B200F95EA9 /* CodeCoverageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C61E9CE226B91B200F95EA9 /* CodeCoverageTests.swift */; };
2020
4C61E9D1226BEDE400F95EA9 /* CoveredLineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C61E9D0226BEDE400F95EA9 /* CoveredLineTests.swift */; };
2121
4C61E9E82274870E00F95EA9 /* CoveredResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C61E9E72274870E00F95EA9 /* CoveredResult.swift */; };
22+
4CA6CC32237878C50010ACC9 /* Coverage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CA6CC31237878C50010ACC9 /* Coverage.swift */; };
2223
/* End PBXBuildFile section */
2324

2425
/* Begin PBXContainerItemProxy section */
@@ -48,6 +49,7 @@
4849
4C61E9CE226B91B200F95EA9 /* CodeCoverageTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodeCoverageTests.swift; sourceTree = "<group>"; };
4950
4C61E9D0226BEDE400F95EA9 /* CoveredLineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoveredLineTests.swift; sourceTree = "<group>"; };
5051
4C61E9E72274870E00F95EA9 /* CoveredResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoveredResult.swift; sourceTree = "<group>"; };
52+
4CA6CC31237878C50010ACC9 /* Coverage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Coverage.swift; sourceTree = "<group>"; };
5153
/* End PBXFileReference section */
5254

5355
/* Begin PBXFrameworksBuildPhase section */
@@ -98,6 +100,7 @@
98100
4C61E9C3226B87CD00F95EA9 /* CoveredProject.swift */,
99101
4C61E9E72274870E00F95EA9 /* CoveredResult.swift */,
100102
4C61E9C5226B87EC00F95EA9 /* Parser.swift */,
103+
4CA6CC31237878C50010ACC9 /* Coverage.swift */,
101104
);
102105
path = CodeCoverageFramework;
103106
sourceTree = "<group>";
@@ -229,6 +232,7 @@
229232
4C61E9C0226B876800F95EA9 /* CoveredLine.swift in Sources */,
230233
4C61E9C4226B87CD00F95EA9 /* CoveredProject.swift in Sources */,
231234
4C61E9C8226B881C00F95EA9 /* CodeCoverage.swift in Sources */,
235+
4CA6CC32237878C50010ACC9 /* Coverage.swift in Sources */,
232236
4C61E9C2226B87BA00F95EA9 /* CoveredClass.swift in Sources */,
233237
4C61E9E82274870E00F95EA9 /* CoveredResult.swift in Sources */,
234238
);
Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
// This file was generated from JSON Schema using quicktype, do not modify it directly.
2+
// To parse the JSON, add this file to your project and do:
3+
//
4+
// let project = try? newJSONDecoder().decode(Project.self, from: jsonData)
5+
6+
import Foundation
7+
8+
// MARK: - Project
9+
struct Project: Codable {
10+
let removedTargets: [JSONAny]
11+
let lineCoverageDelta: LineCoverageDelta
12+
let addedTargets: [JSONAny]
13+
let targetDeltas: [TargetDelta]
14+
}
15+
16+
// MARK: - LineCoverageDelta
17+
struct LineCoverageDelta: Codable {
18+
let executableLinesDelta: Int
19+
let lineCoverageDelta: Double
20+
let coveredLinesDelta: Int
21+
}
22+
23+
// MARK: - TargetDelta
24+
struct TargetDelta: Codable {
25+
let addedFiles: [JSONAny]
26+
let lineCoverageDelta: LineCoverageDelta
27+
let name: String
28+
let removedFiles: [JSONAny]
29+
let fileDeltas: [FileDelta]
30+
}
31+
32+
// MARK: - FileDelta
33+
struct FileDelta: Codable {
34+
let removedFunctions: [RemovedFunction]
35+
let lineCoverageDelta: LineCoverageDelta
36+
let documentLocation: String
37+
let addedFunctions: [AddedFunction]
38+
let functionDeltas: [JSONAny]
39+
}
40+
41+
// MARK: - AddedFunction
42+
struct AddedFunction: Codable {
43+
let coveredLines: Int
44+
let lineCoverage: Double
45+
let lineNumber, executionCount: Int
46+
let name: String
47+
let executableLines: Int
48+
}
49+
50+
// MARK: - RemovedFunction
51+
struct RemovedFunction: Codable {
52+
let name: String
53+
}
54+
55+
// MARK: - Encode/decode helpers
56+
57+
class JSONNull: Codable, Hashable {
58+
59+
public static func == (lhs: JSONNull, rhs: JSONNull) -> Bool {
60+
return true
61+
}
62+
63+
public var hashValue: Int {
64+
return 0
65+
}
66+
67+
public func hash(into hasher: inout Hasher) {
68+
// No-op
69+
}
70+
71+
public init() {}
72+
73+
public required init(from decoder: Decoder) throws {
74+
let container = try decoder.singleValueContainer()
75+
if !container.decodeNil() {
76+
throw DecodingError.typeMismatch(JSONNull.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Wrong type for JSONNull"))
77+
}
78+
}
79+
80+
public func encode(to encoder: Encoder) throws {
81+
var container = encoder.singleValueContainer()
82+
try container.encodeNil()
83+
}
84+
}
85+
86+
class JSONCodingKey: CodingKey {
87+
let key: String
88+
89+
required init?(intValue: Int) {
90+
return nil
91+
}
92+
93+
required init?(stringValue: String) {
94+
key = stringValue
95+
}
96+
97+
var intValue: Int? {
98+
return nil
99+
}
100+
101+
var stringValue: String {
102+
return key
103+
}
104+
}
105+
106+
class JSONAny: Codable {
107+
108+
let value: Any
109+
110+
static func decodingError(forCodingPath codingPath: [CodingKey]) -> DecodingError {
111+
let context = DecodingError.Context(codingPath: codingPath, debugDescription: "Cannot decode JSONAny")
112+
return DecodingError.typeMismatch(JSONAny.self, context)
113+
}
114+
115+
static func encodingError(forValue value: Any, codingPath: [CodingKey]) -> EncodingError {
116+
let context = EncodingError.Context(codingPath: codingPath, debugDescription: "Cannot encode JSONAny")
117+
return EncodingError.invalidValue(value, context)
118+
}
119+
120+
static func decode(from container: SingleValueDecodingContainer) throws -> Any {
121+
if let value = try? container.decode(Bool.self) {
122+
return value
123+
}
124+
if let value = try? container.decode(Int64.self) {
125+
return value
126+
}
127+
if let value = try? container.decode(Double.self) {
128+
return value
129+
}
130+
if let value = try? container.decode(String.self) {
131+
return value
132+
}
133+
if container.decodeNil() {
134+
return JSONNull()
135+
}
136+
throw decodingError(forCodingPath: container.codingPath)
137+
}
138+
139+
static func decode(from container: inout UnkeyedDecodingContainer) throws -> Any {
140+
if let value = try? container.decode(Bool.self) {
141+
return value
142+
}
143+
if let value = try? container.decode(Int64.self) {
144+
return value
145+
}
146+
if let value = try? container.decode(Double.self) {
147+
return value
148+
}
149+
if let value = try? container.decode(String.self) {
150+
return value
151+
}
152+
if let value = try? container.decodeNil() {
153+
if value {
154+
return JSONNull()
155+
}
156+
}
157+
if var container = try? container.nestedUnkeyedContainer() {
158+
return try decodeArray(from: &container)
159+
}
160+
if var container = try? container.nestedContainer(keyedBy: JSONCodingKey.self) {
161+
return try decodeDictionary(from: &container)
162+
}
163+
throw decodingError(forCodingPath: container.codingPath)
164+
}
165+
166+
static func decode(from container: inout KeyedDecodingContainer<JSONCodingKey>, forKey key: JSONCodingKey) throws -> Any {
167+
if let value = try? container.decode(Bool.self, forKey: key) {
168+
return value
169+
}
170+
if let value = try? container.decode(Int64.self, forKey: key) {
171+
return value
172+
}
173+
if let value = try? container.decode(Double.self, forKey: key) {
174+
return value
175+
}
176+
if let value = try? container.decode(String.self, forKey: key) {
177+
return value
178+
}
179+
if let value = try? container.decodeNil(forKey: key) {
180+
if value {
181+
return JSONNull()
182+
}
183+
}
184+
if var container = try? container.nestedUnkeyedContainer(forKey: key) {
185+
return try decodeArray(from: &container)
186+
}
187+
if var container = try? container.nestedContainer(keyedBy: JSONCodingKey.self, forKey: key) {
188+
return try decodeDictionary(from: &container)
189+
}
190+
throw decodingError(forCodingPath: container.codingPath)
191+
}
192+
193+
static func decodeArray(from container: inout UnkeyedDecodingContainer) throws -> [Any] {
194+
var arr: [Any] = []
195+
while !container.isAtEnd {
196+
let value = try decode(from: &container)
197+
arr.append(value)
198+
}
199+
return arr
200+
}
201+
202+
static func decodeDictionary(from container: inout KeyedDecodingContainer<JSONCodingKey>) throws -> [String: Any] {
203+
var dict = [String: Any]()
204+
for key in container.allKeys {
205+
let value = try decode(from: &container, forKey: key)
206+
dict[key.stringValue] = value
207+
}
208+
return dict
209+
}
210+
211+
static func encode(to container: inout UnkeyedEncodingContainer, array: [Any]) throws {
212+
for value in array {
213+
if let value = value as? Bool {
214+
try container.encode(value)
215+
} else if let value = value as? Int64 {
216+
try container.encode(value)
217+
} else if let value = value as? Double {
218+
try container.encode(value)
219+
} else if let value = value as? String {
220+
try container.encode(value)
221+
} else if value is JSONNull {
222+
try container.encodeNil()
223+
} else if let value = value as? [Any] {
224+
var container = container.nestedUnkeyedContainer()
225+
try encode(to: &container, array: value)
226+
} else if let value = value as? [String: Any] {
227+
var container = container.nestedContainer(keyedBy: JSONCodingKey.self)
228+
try encode(to: &container, dictionary: value)
229+
} else {
230+
throw encodingError(forValue: value, codingPath: container.codingPath)
231+
}
232+
}
233+
}
234+
235+
static func encode(to container: inout KeyedEncodingContainer<JSONCodingKey>, dictionary: [String: Any]) throws {
236+
for (key, value) in dictionary {
237+
let key = JSONCodingKey(stringValue: key)!
238+
if let value = value as? Bool {
239+
try container.encode(value, forKey: key)
240+
} else if let value = value as? Int64 {
241+
try container.encode(value, forKey: key)
242+
} else if let value = value as? Double {
243+
try container.encode(value, forKey: key)
244+
} else if let value = value as? String {
245+
try container.encode(value, forKey: key)
246+
} else if value is JSONNull {
247+
try container.encodeNil(forKey: key)
248+
} else if let value = value as? [Any] {
249+
var container = container.nestedUnkeyedContainer(forKey: key)
250+
try encode(to: &container, array: value)
251+
} else if let value = value as? [String: Any] {
252+
var container = container.nestedContainer(keyedBy: JSONCodingKey.self, forKey: key)
253+
try encode(to: &container, dictionary: value)
254+
} else {
255+
throw encodingError(forValue: value, codingPath: container.codingPath)
256+
}
257+
}
258+
}
259+
260+
static func encode(to container: inout SingleValueEncodingContainer, value: Any) throws {
261+
if let value = value as? Bool {
262+
try container.encode(value)
263+
} else if let value = value as? Int64 {
264+
try container.encode(value)
265+
} else if let value = value as? Double {
266+
try container.encode(value)
267+
} else if let value = value as? String {
268+
try container.encode(value)
269+
} else if value is JSONNull {
270+
try container.encodeNil()
271+
} else {
272+
throw encodingError(forValue: value, codingPath: container.codingPath)
273+
}
274+
}
275+
276+
public required init(from decoder: Decoder) throws {
277+
if var arrayContainer = try? decoder.unkeyedContainer() {
278+
self.value = try JSONAny.decodeArray(from: &arrayContainer)
279+
} else if var container = try? decoder.container(keyedBy: JSONCodingKey.self) {
280+
self.value = try JSONAny.decodeDictionary(from: &container)
281+
} else {
282+
let container = try decoder.singleValueContainer()
283+
self.value = try JSONAny.decode(from: container)
284+
}
285+
}
286+
287+
public func encode(to encoder: Encoder) throws {
288+
if let arr = self.value as? [Any] {
289+
var container = encoder.unkeyedContainer()
290+
try JSONAny.encode(to: &container, array: arr)
291+
} else if let dict = self.value as? [String: Any] {
292+
var container = encoder.container(keyedBy: JSONCodingKey.self)
293+
try JSONAny.encode(to: &container, dictionary: dict)
294+
} else {
295+
var container = encoder.singleValueContainer()
296+
try JSONAny.encode(to: &container, value: self.value)
297+
}
298+
}
299+
}

CodeCoverageFramework/CodeCoverageFramework/CoveredLine.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// Copyright © 2019 charland. All rights reserved.
77
//
88

9-
import CSV
109
import Foundation
1110

1211
struct CoveredLine: Equatable {

Logs/Build/LogStoreManifest.plist

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>logFormatVersion</key>
6+
<integer>10</integer>
7+
<key>logs</key>
8+
<dict/>
9+
</dict>
10+
</plist>

0 commit comments

Comments
 (0)