38
38
from blinkpy .web_tests .port .android import (
39
39
PRODUCTS , PRODUCTS_TO_STEPNAMES )
40
40
41
- CSV_HEADING = ('Test name, Test Result, Baseline Result, '
41
+ CSV_HEADING = ('Test name, %s Result, %s Result, '
42
42
'Result Comparison, Test Flaky Results, '
43
43
'Baseline Flaky Results, Unreliable Comparison\n ' )
44
44
YES = 'Yes'
45
45
NO = 'No'
46
46
_log = logging .getLogger (os .path .basename (__file__ ))
47
+
48
+ # Extend this script to compare the results between wptrunner/Chrome
49
+ # and rwt/content_shell on Linux
50
+ PRODUCTS = PRODUCTS + ['chrome_linux' , 'content_shell' ]
51
+ PRODUCTS_TO_STEPNAMES .update ({
52
+ 'chrome_linux' : 'wpt_tests_suite' ,
53
+ 'content_shell' : 'blink_web_tests' })
54
+ PRODUCTS_TO_BUILDER_NAME = {
55
+ 'android_weblayer' : 'android-weblayer-pie-x86-wpt-fyi-rel' ,
56
+ 'android_webview' : 'android-webview-pie-x86-wpt-fyi-rel' ,
57
+ 'chrome_android' : 'android-web-platform-pie-x86-fyi-rel' ,
58
+ 'chrome_linux' : 'linux-wpt-fyi-rel' ,
59
+ 'content_shell' : "Linux Tests" }
60
+
47
61
STEP_NAME_VARIANTS = {
48
62
'chrome_public_wpt' : ['chrome_public_wpt on Ubuntu-16.04 or Ubuntu-18.04' ],
49
- 'weblayer_shell_wpt' : ['weblayer_shell_wpt on Ubuntu-16.04 or Ubuntu-18.04' ]
63
+ 'weblayer_shell_wpt' : ['weblayer_shell_wpt on Ubuntu-16.04 or Ubuntu-18.04' ],
64
+ 'system_webview_wpt' : ['system_webview_wpt on Ubuntu-16.04 or Ubuntu-18.04' ],
65
+ 'wpt_tests_suite' : ['wpt_tests_suite on Ubuntu-18.04' ],
66
+ 'blink_web_tests' : ['blink_web_tests on Ubuntu-18.04' ]
50
67
}
51
68
52
69
def map_tests_to_results (output_mp , input_mp , path = '' ):
@@ -60,30 +77,38 @@ def map_tests_to_results(output_mp, input_mp, path=''):
60
77
class WPTResultsDiffer (object ):
61
78
62
79
def __init__ (self , args , host , actual_results_map ,
63
- baseline_results_map , csv_output ):
80
+ baseline_results_map , csv_output , ignore_missing = False ):
64
81
self ._args = args
65
82
self ._host = host
66
83
self ._actual_results_map = actual_results_map
67
84
self ._baseline_results_map = baseline_results_map
68
85
self ._csv_output = csv_output
69
- self ._test_flaky_results = self ._get_flaky_test_results (
70
- args .product_to_compare )
71
- self ._baseline_flaky_results = self ._get_flaky_test_results (
72
- args .baseline_product )
86
+ self ._ignore_missing = ignore_missing
87
+ self ._test_flaky_results = None
88
+ self ._baseline_flaky_results = None
89
+
90
+ try :
91
+ self ._test_flaky_results = self ._get_flaky_test_results (
92
+ args .product_to_compare )
93
+ except :
94
+ _log .info ('Failed to get flaky results for %s' % args .product_to_compare )
95
+
96
+ try :
97
+ self ._baseline_flaky_results = self ._get_flaky_test_results (
98
+ args .baseline_product )
99
+ except :
100
+ _log .info ('Failed to get flaky results for %s' % args .baseline_product )
101
+
102
+ self ._handle_flaky = self ._test_flaky_results is not None \
103
+ and self ._baseline_flaky_results is not None
73
104
74
105
def _get_flaky_test_results (self , product ):
75
106
return self ._get_bot_expectations (product ).flakes_by_path (
76
107
False , ignore_bot_expected_results = True ,
77
108
consider_only_flaky_runs = False )
78
109
79
110
def _get_bot_expectations (self , product ):
80
- specifiers = [product ]
81
- builders = self ._host .builders .filter_builders (
82
- include_specifiers = specifiers )
83
- assert len (builders ) == 1 , (
84
- 'Multiple builders match the specifiers %s' % specifiers )
85
-
86
- builder_name = builders [0 ]
111
+ builder_name = PRODUCTS_TO_BUILDER_NAME [product ]
87
112
bot_expectations_factory = BotTestExpectationsFactory (
88
113
self ._host .builders , PRODUCTS_TO_STEPNAMES [product ])
89
114
@@ -96,7 +121,8 @@ def flaky_results(self, test_name, flaky_dict):
96
121
def create_csv (self ):
97
122
super_set = (set (self ._actual_results_map .keys ()) |
98
123
set (self ._baseline_results_map .keys ()))
99
- file_output = CSV_HEADING
124
+ file_output = CSV_HEADING % (self ._args .product_to_compare ,
125
+ self ._args .baseline_product )
100
126
101
127
for test in sorted (super_set ):
102
128
if ',' in test :
@@ -112,11 +138,13 @@ def create_csv(self):
112
138
if line [- 1 ] == line [- 2 ]:
113
139
line .append ('SAME RESULTS' )
114
140
elif 'MISSING' in (line [- 1 ], line [- 2 ]):
141
+ if self ._ignore_missing :
142
+ continue
115
143
line .append ('MISSING RESULTS' )
116
144
else :
117
145
line .append ('DIFFERENT RESULTS' )
118
146
119
- if line [- 1 ] != 'MISSING RESULTS' :
147
+ if self . _handle_flaky and line [- 1 ] != 'MISSING RESULTS' :
120
148
test_flaky_results = self .flaky_results (
121
149
test , self ._test_flaky_results )
122
150
@@ -169,19 +197,15 @@ def _get_product_test_results(host, product, results_path=None):
169
197
else :
170
198
_log .info (('Retrieving test results for '
171
199
'product %s using the bb command' ), product )
172
- specifiers = [product ]
173
- builders = host .builders .filter_builders (
174
- include_specifiers = specifiers )
175
- assert len (builders ) == 1
176
-
177
- builder_name = builders [0 ]
200
+ builder_name = PRODUCTS_TO_BUILDER_NAME [product ]
201
+ # TODO: Note the builder name and number in the CSV file
178
202
latest_build = host .bb_agent .get_latest_finished_build (
179
203
builder_name )
180
204
_log .debug ('The latest build for %s is %d' ,
181
205
builder_name , latest_build .build_number )
182
206
183
207
build_results = _get_build_test_results (host , product , latest_build )
184
- json_results_obj = tempfile .TemporaryFile ()
208
+ json_results_obj = tempfile .NamedTemporaryFile ()
185
209
json_results_obj .write (json .dumps (build_results ))
186
210
json_results_obj .seek (0 )
187
211
@@ -197,16 +221,19 @@ def main(args):
197
221
help = 'Path to baseline test results JSON file' )
198
222
parser .add_argument ('--baseline-product' , required = True , action = 'store' ,
199
223
choices = PRODUCTS ,
200
- help = 'Name of the baseline WPT product' )
224
+ help = 'Name of the baseline product' )
201
225
parser .add_argument ('--test-results-to-compare' , required = False ,
202
226
help = 'Path to actual test results JSON file' )
203
227
parser .add_argument ('--product-to-compare' , required = True , action = 'store' ,
204
228
choices = PRODUCTS ,
205
- help = 'Name of the WPT product being compared' )
229
+ help = 'Name of the product being compared' )
206
230
parser .add_argument ('--csv-output' , required = True ,
207
231
help = 'Path to CSV output file' )
208
232
parser .add_argument ('--verbose' , '-v' , action = 'count' , default = 1 ,
209
233
help = 'Verbosity level' )
234
+ parser .add_argument ('--ignore-missing' , action = 'store_true' ,
235
+ required = False , default = False ,
236
+ help = 'Ignore tests that are not run for one of the product' )
210
237
args = parser .parse_args ()
211
238
212
239
if args .verbose >= 3 :
@@ -240,14 +267,26 @@ def main(args):
240
267
# names to their results map
241
268
tests_to_actual_results = {}
242
269
tests_to_baseline_results = {}
270
+ if args .product_to_compare == 'chrome_linux' :
271
+ path = '/external/wpt'
272
+ else :
273
+ path = ''
243
274
map_tests_to_results (tests_to_actual_results ,
244
- actual_results_json ['tests' ])
275
+ actual_results_json ['tests' ],
276
+ path = path )
277
+
278
+ if args .baseline_product == 'chrome_linux' :
279
+ path = '/external/wpt'
280
+ else :
281
+ path = ''
245
282
map_tests_to_results (tests_to_baseline_results ,
246
- baseline_results_json ['tests' ])
283
+ baseline_results_json ['tests' ],
284
+ path = path )
247
285
248
286
# Create a CSV file which compares tests results to baseline results
249
287
WPTResultsDiffer (args , host , tests_to_actual_results ,
250
- tests_to_baseline_results , csv_output ).create_csv ()
288
+ tests_to_baseline_results , csv_output ,
289
+ args .ignore_missing ).create_csv ()
251
290
252
291
return 0
253
292
0 commit comments