@@ -203,8 +203,7 @@ def clean_swift_package(path, swiftc, sandbox_profile,
203
203
204
204
def build_swift_package (path , swiftc , configuration , sandbox_profile ,
205
205
stdout = sys .stdout , stderr = sys .stderr ,
206
- incremental = False ,
207
- stats_path = None ):
206
+ incremental = False ):
208
207
"""Build a Swift package manager project."""
209
208
swift = swiftc [:- 1 ]
210
209
if not incremental :
@@ -214,9 +213,6 @@ def build_swift_package(path, swiftc, configuration, sandbox_profile,
214
213
env ['SWIFT_EXEC' ] = swiftc
215
214
command = [swift , 'build' , '-C' , path , '--verbose' ,
216
215
'--configuration' , configuration ]
217
- if stats_path is not None :
218
- command += ['-Xswiftc' , '-stats-output-dir' ,
219
- '-Xswiftc' , stats_path ]
220
216
if (swift_branch not in ['swift-3.0-branch' ,
221
217
'swift-3.1-branch' ]):
222
218
command .insert (2 , '--disable-sandbox' )
@@ -228,18 +224,14 @@ def build_swift_package(path, swiftc, configuration, sandbox_profile,
228
224
229
225
def test_swift_package (path , swiftc , sandbox_profile ,
230
226
stdout = sys .stdout , stderr = sys .stderr ,
231
- incremental = False ,
232
- stats_path = None ):
227
+ incremental = False ):
233
228
"""Test a Swift package manager project."""
234
229
swift = swiftc [:- 1 ]
235
230
if not incremental :
236
231
clean_swift_package (path , swiftc , sandbox_profile )
237
232
env = os .environ
238
233
env ['SWIFT_EXEC' ] = swiftc
239
234
command = [swift , 'test' , '-C' , path , '--verbose' ]
240
- if stats_path is not None :
241
- command += ['-Xswiftc' , '-stats-output-dir' ,
242
- '-Xswiftc' , stats_path ]
243
235
return common .check_execute (command , timeout = 3600 ,
244
236
sandbox_profile = sandbox_profile ,
245
237
stdout = stdout , stderr = stderr ,
@@ -274,31 +266,22 @@ def dispatch(root_path, repo, action, swiftc, swift_version,
274
266
sandbox_profile_xcodebuild , sandbox_profile_package ,
275
267
added_swift_flags , should_strip_resource_phases = False ,
276
268
stdout = sys .stdout , stderr = sys .stderr ,
277
- incremental = False ,
278
- stats_path = None ):
269
+ incremental = False ):
279
270
"""Call functions corresponding to actions."""
280
271
281
- if stats_path is not None :
282
- if os .path .exists (stats_path ):
283
- shutil .rmtree (stats_path )
284
- common .check_execute (['mkdir' , '-p' , stats_path ],
285
- stdout = stdout , stderr = stderr )
286
-
287
272
if action ['action' ] == 'BuildSwiftPackage' :
288
273
return build_swift_package (os .path .join (root_path , repo ['path' ]),
289
274
swiftc ,
290
275
action ['configuration' ],
291
276
sandbox_profile_package ,
292
277
stdout = stdout , stderr = stderr ,
293
- incremental = incremental ,
294
- stats_path = stats_path )
278
+ incremental = incremental )
295
279
elif action ['action' ] == 'TestSwiftPackage' :
296
280
return test_swift_package (os .path .join (root_path , repo ['path' ]),
297
281
swiftc ,
298
282
sandbox_profile_package ,
299
283
stdout = stdout , stderr = stderr ,
300
- incremental = incremental ,
301
- stats_path = stats_path )
284
+ incremental = incremental )
302
285
elif re .match (r'^(Build|Test)Xcode(Workspace|Project)(Scheme|Target)$' ,
303
286
action ['action' ]):
304
287
match = re .match (
@@ -315,8 +298,6 @@ def dispatch(root_path, repo, action, swiftc, swift_version,
315
298
if swift_version :
316
299
other_swift_flags += ['-swift-version' , swift_version ]
317
300
build_settings ['SWIFT_VERSION' ] = swift_version
318
- if stats_path is not None :
319
- other_swift_flags += ['-stats-output-dir' , stats_path ]
320
301
if added_swift_flags :
321
302
other_swift_flags .append (added_swift_flags )
322
303
if other_swift_flags :
@@ -438,12 +419,6 @@ def add_arguments(parser):
438
419
parser .add_argument ("--test-incremental" ,
439
420
help = 'test incremental-mode over multiple commits' ,
440
421
action = 'store_true' )
441
- parser .add_argument ("--check-stats" ,
442
- help = 'collect stats and compare to expectations' ,
443
- action = 'store_true' )
444
- parser .add_argument ("--show-stats" ,
445
- metavar = 'PATTERN' ,
446
- help = 'report stats matching PATTERN' )
447
422
parser .add_argument ("--add-swift-flags" ,
448
423
metavar = "FLAGS" ,
449
424
help = 'add flags to each Swift invocation' ,
@@ -1008,59 +983,13 @@ def have_same_trees(full, incr, d):
1008
983
ok = have_same_trees (full , incr , sub ) and ok
1009
984
return ok
1010
985
1011
- class StatsSummary :
1012
-
1013
- def __init__ (self ):
1014
- self .commits = {}
1015
-
1016
- def add_stats_from_json (self , seq , sha , j ):
1017
- key = (seq , sha )
1018
- if key not in self .commits :
1019
- self .commits [key ] = {}
1020
- for (k , v ) in j .items ():
1021
- if k .startswith ("time." ):
1022
- continue
1023
- e = self .commits [key ].get (k , 0 )
1024
- self .commits [key ][k ] = int (v ) + e
1025
-
1026
- def check_against_expected (self , seq , sha , expected ):
1027
- key = (seq , sha )
1028
- if key in self .commits :
1029
- for (k , ev ) in expected .items ():
1030
- if k in self .commits [key ]:
1031
- gv = self .commits [key ][k ]
1032
- if ev < gv :
1033
- message = ("Expected %s of %s, got %s" %
1034
- (k , str (ev ), str (gv )) )
1035
- raise EarlyExit (ActionResult (Result .FAIL , message ))
1036
-
1037
- def add_stats_from_file (self , seq , sha , f ):
1038
- with open (f ) as fp :
1039
- self .add_stats_from_json (seq , sha , json .load (fp ))
1040
-
1041
- def add_stats_from_dir (self , seq , sha , path ):
1042
- for root , dirs , files in os .walk (path ):
1043
- for f in files :
1044
- if not f .endswith (".json" ):
1045
- continue
1046
- self .add_stats_from_file (seq , sha , os .path .join (root , f ))
1047
-
1048
- def dump (self , pattern ):
1049
- return json .dumps ([ {"commit" : sha ,
1050
- "stats" : { k : v for (k , v ) in self .commits [(seq , sha )].items ()
1051
- if re .match (pattern , k ) } }
1052
- for (seq , sha ) in sorted (self .commits .keys ()) ],
1053
- sort_keys = False ,
1054
- indent = 2 )
1055
986
1056
987
class IncrementalActionBuilder (ActionBuilder ):
1057
988
1058
989
def __init__ (self , swiftc , swift_version , swift_branch ,
1059
990
sandbox_profile_xcodebuild ,
1060
991
sandbox_profile_package ,
1061
992
added_swift_flags ,
1062
- check_stats ,
1063
- show_stats ,
1064
993
project , action ):
1065
994
super (IncrementalActionBuilder ,
1066
995
self ).__init__ (swiftc , swift_version , swift_branch ,
@@ -1070,15 +999,8 @@ def __init__(self, swiftc, swift_version, swift_branch,
1070
999
skip_clean = True ,
1071
1000
project = project ,
1072
1001
action = action )
1073
- self .check_stats = check_stats
1074
- self .show_stats = show_stats
1075
- self .stats_path = None
1076
- self .stats_summ = None
1077
1002
self .proj_path = os .path .join (self .root_path , self .project ['path' ])
1078
1003
self .incr_path = self .proj_path + "-incr"
1079
- if self .check_stats or (self .show_stats is not None ):
1080
- self .stats_path = os .path .join (self .proj_path , "swift-stats" )
1081
- self .stats_summ = StatsSummary ()
1082
1004
1083
1005
def curr_build_state_path (self ):
1084
1006
if self .action ['action' ] == 'BuildSwiftPackage' :
@@ -1111,10 +1033,6 @@ def saved_build_state_path(self, seq, flav, sha):
1111
1033
return os .path .join (self .incr_path , ("build-state-%03d-%s-%.7s" %
1112
1034
(seq , flav , sha )))
1113
1035
1114
- def saved_build_stats_path (self , seq , flav , sha ):
1115
- return os .path .join (self .incr_path , ("build-stats-%03d-%s-%.7s" %
1116
- (seq , flav , sha )))
1117
-
1118
1036
def restore_saved_build_state (self , seq , flav , sha , stdout = sys .stdout ):
1119
1037
src = self .saved_build_state_path (seq , flav , sha )
1120
1038
dst = self .curr_build_state_path ()
@@ -1125,7 +1043,7 @@ def restore_saved_build_state(self, seq, flav, sha, stdout=sys.stdout):
1125
1043
shutil .rmtree (dst )
1126
1044
shutil .copytree (src , dst , symlinks = True )
1127
1045
1128
- def save_build_state (self , seq , flav , sha , stats , stdout = sys .stdout ):
1046
+ def save_build_state (self , seq , flav , sha , stdout = sys .stdout ):
1129
1047
src = self .curr_build_state_path ()
1130
1048
dst = self .saved_build_state_path (seq , flav , sha )
1131
1049
proj = self .project ['path' ]
@@ -1134,17 +1052,6 @@ def save_build_state(self, seq, flav, sha, stats, stdout=sys.stdout):
1134
1052
if os .path .exists (dst ):
1135
1053
shutil .rmtree (dst )
1136
1054
shutil .copytree (src , dst , symlinks = True )
1137
- if self .stats_summ is not None :
1138
- self .stats_summ .add_stats_from_dir (seq , sha , self .stats_path )
1139
- src = self .stats_path
1140
- dst = self .saved_build_stats_path (seq , flav , sha )
1141
- common .debug_print ("Saving %s stats #%d of %s to %s" %
1142
- (flav , seq , proj , dst ), stderr = stdout )
1143
- if os .path .exists (dst ):
1144
- shutil .rmtree (dst )
1145
- shutil .copytree (src , dst , symlinks = True )
1146
- if stats is not None and self .check_stats :
1147
- self .stats_summ .check_against_expected (seq , sha , stats )
1148
1055
1149
1056
def check_full_vs_incr (self , seq , sha , stdout = sys .stdout ):
1150
1057
full = self .saved_build_state_path (seq , 'full' , sha )
@@ -1182,9 +1089,6 @@ def build(self, stdout=sys.stdout):
1182
1089
stdout = stdout )
1183
1090
except EarlyExit as error :
1184
1091
action_result = error .value
1185
- if self .show_stats is not None :
1186
- common .debug_print ("Stats summary:" , stderr = stdout )
1187
- common .debug_print (self .stats_summ .dump (self .show_stats ), stderr = stdout )
1188
1092
return action_result
1189
1093
1190
1094
def dispatch (self , identifier , incremental , stdout = sys .stdout , stderr = sys .stderr ):
@@ -1197,8 +1101,7 @@ def dispatch(self, identifier, incremental, stdout=sys.stdout, stderr=sys.stderr
1197
1101
self .added_swift_flags ,
1198
1102
should_strip_resource_phases = False ,
1199
1103
stdout = stdout , stderr = stderr ,
1200
- incremental = incremental ,
1201
- stats_path = self .stats_path )
1104
+ incremental = incremental )
1202
1105
except common .ExecuteCommandFailure as error :
1203
1106
return self .failed (identifier , error )
1204
1107
else :
@@ -1222,12 +1125,7 @@ def build_incremental(self, identifier, commits, stdout=sys.stdout):
1222
1125
prev = None
1223
1126
seq = 0
1224
1127
action_result = ActionResult (Result .PASS , "" )
1225
- for commit in commits :
1226
- sha = commit
1227
- stats = None
1228
- if type (commit ) is dict :
1229
- sha = commit ['commit' ]
1230
- stats = commit .get ('stats' , None )
1128
+ for sha in commits :
1231
1129
proj = self .project ['path' ]
1232
1130
ident = "%s-%03d-%.7s" % (identifier , seq , sha )
1233
1131
if prev is None :
@@ -1244,7 +1142,7 @@ def build_incremental(self, identifier, commits, stdout=sys.stdout):
1244
1142
common .git_submodule_update (self .proj_path , stdout = stdout , stderr = stdout )
1245
1143
action_result = self .dispatch_or_raise (ident , incremental = True ,
1246
1144
stdout = stdout , stderr = stdout )
1247
- self .save_build_state (seq , 'incr' , sha , stats , stdout = stdout )
1145
+ self .save_build_state (seq , 'incr' , sha , stdout = stdout )
1248
1146
prev = sha
1249
1147
seq += 1
1250
1148
return action_result
0 commit comments