16
16
17
17
import ArgumentParser
18
18
import Foundation
19
+
19
20
private enum Constants { }
20
21
21
22
extension Constants {
@@ -35,6 +36,23 @@ extension Constants {
35
36
static let umbrellaPodFlags = Constants . flags + [ " --use-json " ]
36
37
}
37
38
39
+ public extension Date {
40
+ func dateTimeString( ) -> String {
41
+ let formatter = DateFormatter ( )
42
+ formatter. dateStyle = . short
43
+ formatter. timeStyle = . medium
44
+ return formatter. string ( from: self )
45
+ }
46
+
47
+ func formattedDurationSince( _ date: Date ) -> String {
48
+ let formatter = DateComponentsFormatter ( )
49
+ formatter. unitsStyle = . abbreviated
50
+ formatter. allowedUnits = [ . hour, . minute, . second]
51
+ let secondsSinceDate = date. timeIntervalSince ( self )
52
+ return formatter. string ( from: secondsSinceDate) ?? " \( round ( secondsSinceDate) ) sec "
53
+ }
54
+ }
55
+
38
56
// SpecFiles is a wraper of dict mapping from required pods to their path. This
39
57
// will also contain a sequence of installing podspecs.
40
58
class SpecFiles {
@@ -356,7 +374,19 @@ struct SpecRepoBuilder: ParsableCommand {
356
374
357
375
var exitCode : Int32 = 0
358
376
var failedPods : [ String ] = [ ]
377
+ let startDate = Date ( )
378
+ var minutes = 0
359
379
for pod in specFileDict. depInstallOrder {
380
+ var timer : DispatchSourceTimer = {
381
+ let t = DispatchSource . makeTimerSource ( )
382
+ t. schedule ( deadline: . now( ) , repeating: 60 )
383
+ t. setEventHandler ( handler: {
384
+ print ( " Tests have run \( minutes) min(s). " )
385
+ minutes += 1
386
+ } )
387
+ return t
388
+ } ( )
389
+ timer. resume ( )
360
390
var podExitCode : Int32 = 0
361
391
print ( " ---------- \( pod) ----------- " )
362
392
switch pod {
@@ -380,11 +410,13 @@ struct SpecRepoBuilder: ParsableCommand {
380
410
failedPods. append ( pod)
381
411
print ( " Failed pod - \( pod) " )
382
412
}
413
+ timer. cancel ( )
414
+ let finishDate = Date ( )
415
+ print ( " \( pod) is finished at: \( finishDate. dateTimeString ( ) ) . " +
416
+ " Duration: \( startDate. formattedDurationSince ( finishDate) ) " )
383
417
}
384
418
if exitCode != 0 {
385
419
Self . exit ( withError: SpecRepoBuilderError . failedToPush ( pods: failedPods) )
386
420
}
387
421
}
388
422
}
389
-
390
- SpecRepoBuilder . main ( )
0 commit comments