5
5
"time"
6
6
7
7
"github.com/google/uuid"
8
- log "github.com/sirupsen/logrus"
9
8
"howett.net/plist"
10
9
)
11
10
@@ -26,13 +25,18 @@ func SetupDecoders() {
26
25
"DTTapHeartbeatMessage" : NewDTTapHeartbeatMessage ,
27
26
"XCTCapabilities" : NewXCTCapabilities ,
28
27
"NSUUID" : NewNSUUIDFromBytes ,
29
- "XCActivityRecord" : DecodeXCActivityRecord ,
28
+ "XCActivityRecord" : NewXCActivityRecord ,
29
+ "XCTAttachment" : NewXCTAttachment ,
30
30
"DTKTraceTapMessage" : NewDTKTraceTapMessage ,
31
31
"NSValue" : NewNSValue ,
32
+ "NSArray" : NewNSArray ,
32
33
"XCTTestIdentifier" : NewXCTTestIdentifier ,
33
34
"DTTapStatusMessage" : NewDTTapStatusMessage ,
34
35
"DTTapMessage" : NewDTTapMessage ,
35
36
"DTCPUClusterInfo" : NewDTCPUClusterInfo ,
37
+ "XCTIssue" : NewXCTIssue ,
38
+ "XCTSourceCodeContext" : NewXCTSourceCodeContext ,
39
+ "XCTSourceCodeLocation" : NewXCTSourceCodeLocation ,
36
40
}
37
41
}
38
42
}
@@ -80,7 +84,7 @@ func NewXCTestConfiguration(
80
84
contents ["reportActivities" ] = true
81
85
contents ["reportResultsToIDE" ] = true
82
86
contents ["sessionIdentifier" ] = NewNSUUID (sessionIdentifier )
83
- contents ["systemAttachmentLifetime" ] = 2
87
+ contents ["systemAttachmentLifetime" ] = 0
84
88
// contents["targetApplicationArguments"] = []interface{}{} //TODO: triggers a bug
85
89
contents ["targetApplicationBundleID" ] = targetApplicationBundleID
86
90
// contents["targetApplicationEnvironment"] = //TODO: triggers a bug map[string]interface{}{}
@@ -96,7 +100,20 @@ func NewXCTestConfiguration(
96
100
contents ["testsToSkip" ] = plist .UID (0 )
97
101
contents ["testTimeoutsEnabled" ] = false
98
102
contents ["treatMissingBaselinesAsFailures" ] = false
99
- contents ["userAttachmentLifetime" ] = 1
103
+ contents ["userAttachmentLifetime" ] = 0
104
+ contents ["preferredScreenCaptureFormat" ] = 2
105
+ contents ["IDECapabilities" ] = XCTCapabilities {CapabilitiesDictionary : map [string ]interface {}{
106
+ "expected failure test capability" : true ,
107
+ "test case run configurations" : true ,
108
+ "test timeout capability" : true ,
109
+ "test iterations" : true ,
110
+ "request diagnostics for specific devices" : true ,
111
+ "delayed attachment transfer" : true ,
112
+ "skipped test capability" : true ,
113
+ "daemon container sandbox extension" : true ,
114
+ "ubiquitous test identifiers" : true ,
115
+ "XCTIssue capability" : true ,
116
+ }}
100
117
return XCTestConfiguration {contents }
101
118
}
102
119
@@ -147,20 +164,28 @@ type XCActivityRecord struct {
147
164
"attachments":<interface {}(howett.net/plist.UID)>)
148
165
149
166
*/
150
- Finish interface {}
151
- Start interface {}
167
+ Finish NSDate
168
+ Start NSDate
152
169
Title string
153
170
UUID NSUUID
154
171
ActivityType string
155
- Attachments interface {}
172
+ Attachments [] XCTAttachment
156
173
}
157
174
158
- func DecodeXCActivityRecord (object map [string ]interface {}, objects []interface {}) interface {} {
175
+ func NewXCActivityRecord (object map [string ]interface {}, objects []interface {}) interface {} {
159
176
finish_ref := object ["finish" ].(plist.UID )
160
- finish := objects [finish_ref ]
177
+ finish := NSDate {}
178
+ if _ , ok := objects [finish_ref ].(map [string ]interface {}); ok {
179
+ finish_raw := objects [finish_ref ].(map [string ]interface {})
180
+ finish = NewNSDate (finish_raw , objects ).(NSDate )
181
+ }
161
182
162
183
start_ref := object ["start" ].(plist.UID )
163
- start := objects [start_ref ]
184
+ start := NSDate {}
185
+ if _ , ok := objects [start_ref ].(map [string ]interface {}); ok {
186
+ start_raw := objects [start_ref ].(map [string ]interface {})
187
+ start = NewNSDate (start_raw , objects ).(NSDate )
188
+ }
164
189
165
190
uuid_ref := object ["uuid" ].(plist.UID )
166
191
uuid_raw := objects [uuid_ref ].(map [string ]interface {})
@@ -170,16 +195,54 @@ func DecodeXCActivityRecord(object map[string]interface{}, objects []interface{}
170
195
title := objects [title_ref ].(string )
171
196
172
197
attachments_ref := object ["attachments" ].(plist.UID )
173
- attachments := objects [attachments_ref ]
198
+ attachments_raw := objects [attachments_ref ].(map [string ]interface {})
199
+
200
+ attachments := make ([]XCTAttachment , 0 )
201
+ for _ , obj := range NewNSArray (attachments_raw , objects ).(NSArray ).Values {
202
+ attachments = append (attachments , obj .(XCTAttachment ))
203
+ }
174
204
175
205
activityType_ref := object ["activityType" ].(plist.UID )
176
206
activityType := objects [activityType_ref ].(string )
177
207
178
- log .Info (objects [9 ])
179
-
180
208
return XCActivityRecord {Finish : finish , Start : start , UUID : uuid , Title : title , Attachments : attachments , ActivityType : activityType }
181
209
}
182
210
211
+ const (
212
+ LifetimeKeepAlways = uint64 (0 )
213
+ LifetimeDeleteOnSuccess = uint64 (1 )
214
+ )
215
+
216
+ type XCTAttachment struct {
217
+ lifetime uint64
218
+ UniformTypeIdentifier string
219
+ fileNameOverride string
220
+ Payload []uint8
221
+ Timestamp float64
222
+ Name string
223
+ userInfo map [string ]interface {}
224
+ }
225
+
226
+ func NewXCTAttachment (object map [string ]interface {}, objects []interface {}) interface {} {
227
+ lifetime := object ["lifetime" ].(uint64 )
228
+ uniformTypeIdentifier := objects [object ["uniformTypeIdentifier" ].(plist.UID )].(string )
229
+ fileNameOverride := objects [object ["fileNameOverride" ].(plist.UID )].(string )
230
+ payload := objects [object ["payload" ].(plist.UID )].([]uint8 )
231
+ timestamp := objects [object ["timestamp" ].(plist.UID )].(float64 )
232
+ name := objects [object ["name" ].(plist.UID )].(string )
233
+ userInfo , _ := extractDictionary (objects [object ["userInfo" ].(plist.UID )].(map [string ]interface {}), objects )
234
+
235
+ return XCTAttachment {
236
+ lifetime : lifetime ,
237
+ UniformTypeIdentifier : uniformTypeIdentifier ,
238
+ fileNameOverride : fileNameOverride ,
239
+ Payload : payload ,
240
+ Timestamp : timestamp ,
241
+ Name : name ,
242
+ userInfo : userInfo ,
243
+ }
244
+ }
245
+
183
246
func NewNSUUIDFromBytes (object map [string ]interface {}, objects []interface {}) interface {} {
184
247
val := object ["NS.uuidbytes" ].([]byte )
185
248
return NSUUID {uuidbytes : val }
@@ -193,6 +256,21 @@ func NewNSUUID(id uuid.UUID) NSUUID {
193
256
return NSUUID {bytes }
194
257
}
195
258
259
+ func archiveNSUUID (uid interface {}, objects []interface {}) ([]interface {}, plist.UID ) {
260
+ nsuuid := uid .(NSUUID )
261
+ object := map [string ]interface {}{}
262
+
263
+ object ["NS.uuidbytes" ] = nsuuid .uuidbytes
264
+ uuidReference := len (objects )
265
+ objects = append (objects , object )
266
+
267
+ classref := uuidReference + 1
268
+ object [class ] = plist .UID (classref )
269
+ objects = append (objects , buildClassDict ("NSUUID" , "NSObject" ))
270
+
271
+ return objects , plist .UID (uuidReference )
272
+ }
273
+
196
274
func archiveXCTCapabilities (capsIface interface {}, objects []interface {}) ([]interface {}, plist.UID ) {
197
275
caps := capsIface .(XCTCapabilities )
198
276
object := map [string ]interface {}{}
@@ -209,23 +287,8 @@ func archiveXCTCapabilities(capsIface interface{}, objects []interface{}) ([]int
209
287
return objects , plist .UID (capsReference )
210
288
}
211
289
212
- func archiveNSUUID (uid interface {}, objects []interface {}) ([]interface {}, plist.UID ) {
213
- nsuuid := uid .(NSUUID )
214
- object := map [string ]interface {}{}
215
-
216
- object ["NS.uuidbytes" ] = nsuuid .uuidbytes
217
- uuidReference := len (objects )
218
- objects = append (objects , object )
219
-
220
- classref := uuidReference + 1
221
- object [class ] = plist .UID (classref )
222
- objects = append (objects , buildClassDict ("NSUUID" , "NSObject" ))
223
-
224
- return objects , plist .UID (uuidReference )
225
- }
226
-
227
290
type NSURL struct {
228
- path string
291
+ Path string
229
292
}
230
293
231
294
func NewNSURL (path string ) NSURL {
@@ -247,7 +310,7 @@ func archiveNSURL(nsurlInterface interface{}, objects []interface{}) ([]interfac
247
310
248
311
pathRef := classref + 1
249
312
object ["NS.relative" ] = plist .UID (pathRef )
250
- objects = append (objects , fmt .Sprintf ("file://%s" , nsurl .path ))
313
+ objects = append (objects , fmt .Sprintf ("file://%s" , nsurl .Path ))
251
314
252
315
return objects , plist .UID (urlReference )
253
316
}
@@ -284,6 +347,19 @@ func NewNSValue(object map[string]interface{}, objects []interface{}) interface{
284
347
return NSValue {NSRectval : rectval , NSSpecial : special }
285
348
}
286
349
350
+ type NSArray struct {
351
+ Values []interface {}
352
+ }
353
+
354
+ func NewNSArray (object map [string ]interface {}, objects []interface {}) interface {} {
355
+ objectRefs := object ["NS.objects" ].([]interface {})
356
+
357
+ uidList := toUidList (objectRefs )
358
+ extractObjects , _ := extractObjects (uidList , objects )
359
+
360
+ return NSArray {Values : extractObjects }
361
+ }
362
+
287
363
type XCTTestIdentifier struct {
288
364
O uint64
289
365
C []string
@@ -344,6 +420,10 @@ func NewNSError(object map[string]interface{}, objects []interface{}) interface{
344
420
return NSError {ErrorCode : errorCode , Domain : domain , UserInfo : userinfo }
345
421
}
346
422
423
+ func (err NSError ) Error () string {
424
+ return fmt .Sprintf ("Error code: %d, Domain: %s, User info: %v" , err .ErrorCode , err .Domain , err .UserInfo )
425
+ }
426
+
347
427
// Apples Reference Date is Jan 1st 2001 00:00
348
428
const nsReferenceDate = 978307200000
349
429
@@ -450,3 +530,49 @@ func archiveNSMutableDictionary(object interface{}, objects []interface{}) ([]in
450
530
mut := object .(NSMutableDictionary )
451
531
return serializeMap (mut .internalDict , objects , buildClassDict ("NSMutableDictionary" , "NSDictionary" , "NSObject" ))
452
532
}
533
+
534
+ type XCTIssue struct {
535
+ RuntimeIssueSeverity uint64
536
+ DetailedDescription string
537
+ CompactDescription string
538
+ SourceCodeContext XCTSourceCodeContext
539
+ }
540
+
541
+ func NewXCTIssue (object map [string ]interface {}, objects []interface {}) interface {} {
542
+ runtimeIssueSeverity := object ["runtimeIssueSeverity" ].(uint64 )
543
+ detailedDescriptionRef := object ["detailed-description" ].(plist.UID )
544
+ sourceCodeContextRef := object ["source-code-context" ].(plist.UID )
545
+ compactDescriptionRef := object ["compact-description" ].(plist.UID )
546
+
547
+ detailedDescription := objects [detailedDescriptionRef ].(string )
548
+ compactDescription := objects [compactDescriptionRef ].(string )
549
+ sourceCodeContext := NewXCTSourceCodeContext (objects [sourceCodeContextRef ].(map [string ]interface {}), objects ).(XCTSourceCodeContext )
550
+
551
+ return XCTIssue {RuntimeIssueSeverity : runtimeIssueSeverity , DetailedDescription : detailedDescription , CompactDescription : compactDescription , SourceCodeContext : sourceCodeContext }
552
+ }
553
+
554
+ type XCTSourceCodeContext struct {
555
+ Location XCTSourceCodeLocation
556
+ }
557
+
558
+ func NewXCTSourceCodeContext (object map [string ]interface {}, objects []interface {}) interface {} {
559
+ locationRef := object ["location" ].(plist.UID )
560
+ location := NewXCTSourceCodeLocation (objects [locationRef ].(map [string ]interface {}), objects ).(XCTSourceCodeLocation )
561
+
562
+ return XCTSourceCodeContext {Location : location }
563
+ }
564
+
565
+ type XCTSourceCodeLocation struct {
566
+ FileUrl NSURL
567
+ LineNumber uint64
568
+ }
569
+
570
+ func NewXCTSourceCodeLocation (object map [string ]interface {}, objects []interface {}) interface {} {
571
+ fileUrlRef := object ["file-url" ].(plist.UID )
572
+ relativeRef := objects [fileUrlRef ].(map [string ]interface {})["NS.relative" ].(plist.UID )
573
+ relativePath := objects [int (relativeRef )].(string )
574
+ fileUrl := NewNSURL (relativePath )
575
+ lineNumber := object ["line-number" ].(uint64 )
576
+
577
+ return XCTSourceCodeLocation {FileUrl : fileUrl , LineNumber : lineNumber }
578
+ }
0 commit comments