forked from otcshare/chromium-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_expectations_unittest.py
1501 lines (1339 loc) · 62 KB
/
update_expectations_unittest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright 2016 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging
from collections import OrderedDict
from blinkpy.common.host_mock import MockHost
from blinkpy.common.system.filesystem_mock import MockFileSystem
from blinkpy.common.system.log_testing import LoggingTestCase
from blinkpy.web_tests.update_expectations import ExpectationsRemover
from blinkpy.web_tests.builder_list import BuilderList
from blinkpy.web_tests.port.factory import PortFactory
from blinkpy.web_tests.port.test import MOCK_WEB_TESTS
from blinkpy.web_tests.update_expectations import main
from blinkpy.tool.commands.flaky_tests import FlakyTests
class FakeBotTestExpectations(object):
def __init__(self, results_by_path):
self._results = {}
# Make the results distinct like the real BotTestExpectations.
for path, results in results_by_path.items():
self._results[path] = list(set(results))
def all_results_by_path(self):
return self._results
class FakeBotTestExpectationsFactory(object):
def __init__(self):
"""The distinct results seen in at least one run of the test.
For example, if the bot results for mytest.html are:
PASS PASS FAIL PASS TIMEOUT
then |all_results_by_builder| would be:
{
'WebKit Linux Trusty' : {
'mytest.html': ['FAIL', 'PASS', 'TIMEOUT']
}
}
"""
self.all_results_by_builder = {}
def expectations_for_builder(self, builder):
if builder not in self.all_results_by_builder:
return None
return FakeBotTestExpectations(self.all_results_by_builder[builder])
class FakePortFactory(PortFactory):
def __init__(self, host, all_build_types=None, all_systems=None):
super(FakePortFactory, self).__init__(host)
self._all_build_types = all_build_types or ()
self._all_systems = all_systems or ()
self._configuration_specifier_macros = {
'mac': ['mac10.10'],
'win': ['win7'],
'linux': ['trusty']
}
def get(self, port_name=None, options=None, **kwargs):
"""Returns an object implementing the Port interface.
This fake object will always return the 'test' port.
"""
port = super(FakePortFactory, self).get('test', None)
port.all_build_types = self._all_build_types
port.all_systems = self._all_systems
port.configuration_specifier_macros_dict = self._configuration_specifier_macros
return port
class MockWebBrowser(object):
def __init__(self):
self.opened_url = None
def open(self, url):
self.opened_url = url
def _strip_multiline_string_spaces(raw_string):
return '\n'.join([s.strip() for s in raw_string.splitlines()])
class UpdateTestExpectationsTest(LoggingTestCase):
FLAKE_TYPE = 'flake'
FAIL_TYPE = 'fail'
def setUp(self):
super(UpdateTestExpectationsTest, self).setUp()
self._mock_web_browser = MockWebBrowser()
self._host = MockHost()
self._port = self._host.port_factory.get('test', None)
self._expectation_factory = FakeBotTestExpectationsFactory()
filesystem = self._host.filesystem
self._write_tests_into_filesystem(filesystem)
def tearDown(self):
super(UpdateTestExpectationsTest, self).tearDown()
def _write_tests_into_filesystem(self, filesystem):
test_list = [
'test/a.html', 'test/b.html', 'test/c.html', 'test/d.html',
'test/e.html', 'test/f.html', 'test/g.html'
]
for test in test_list:
path = filesystem.join(MOCK_WEB_TESTS, test)
filesystem.write_binary_file(path, '')
def _create_expectations_remover(self,
type_flag='all',
remove_missing=False,
include_cq_results=False):
return ExpectationsRemover(
self._host, self._port, self._expectation_factory,
self._mock_web_browser, type_flag, remove_missing,
include_cq_results)
def _parse_expectations(self, expectations):
path = self._port.path_to_generic_test_expectations_file()
self._host.filesystem.write_text_file(path, expectations)
def _define_builders(self, builders_dict):
"""Defines the available builders for the test.
Args:
builders_dict: A dictionary containing builder names to their
attributes, see BuilderList.__init__ for the format.
"""
self._host.builders = BuilderList(builders_dict)
def test_flake_mode_doesnt_remove_non_flakes(self):
"""Tests that lines that aren't flaky are not touched.
Lines are flaky if they contain a PASS as well as at least one other
failing result.
"""
test_expectations_before = _strip_multiline_string_spaces("""
# results: [ Pass Timeout Failure ]
# Even though the results show all passing, none of the
# expectations are flaky so we shouldn't remove any.
test/a.html [ Pass ]
test/b.html [ Timeout ]
test/c.html [ Failure Timeout ]""")
self._expectations_remover = (self._create_expectations_remover(
self.FLAKE_TYPE))
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('trusty', 'x86_64'), )
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {
'test/a.html': ['PASS', 'PASS'],
'test/b.html': ['PASS', 'PASS'],
'test/c.html': ['PASS', 'PASS'],
'test/d.html': ['PASS', 'PASS'],
'test/e.html': ['PASS', 'PASS'],
'test/f.html': ['PASS', 'PASS'],
}
}
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(updated_expectations, test_expectations_before)
def test_fail_mode_doesnt_remove_non_fails(self):
"""Tests that lines that aren't failing are not touched.
Lines are failing if they contain only 'Failure', 'Timeout', or
'Crash' results.
"""
test_expectations_before = _strip_multiline_string_spaces("""
# results: [ Pass Failure Timeout ]
# Even though the results show all passing, none of the
# expectations are failing so we shouldn't remove any.
test/a.html [ Pass ]
test/b.html [ Failure Pass ]
test/c.html [ Failure Pass Timeout ]""")
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('trusty', 'x86_64'), )
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {
'test/a.html': ['PASS', 'PASS'],
'test/b.html': ['PASS', 'PASS'],
'test/c.html': ['PASS', 'PASS'],
'test/d.html': ['PASS', 'PASS'],
'test/e.html': ['PASS', 'PASS'],
'test/f.html': ['PASS', 'PASS'],
}
}
self._expectations_remover = (self._create_expectations_remover(
self.FAIL_TYPE))
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(updated_expectations, test_expectations_before)
def test_dont_remove_directory_flake(self):
"""Tests that flake lines with directories are untouched."""
test_expectations_before = _strip_multiline_string_spaces("""
# results: [ Failure Pass ]
# This expectation is for a whole directory.
test/* [ Failure Pass ]""")
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('trusty', 'x86_64'), )
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {
'test/a.html': ['PASS', 'PASS'],
'test/b.html': ['PASS', 'PASS'],
'test/c.html': ['PASS', 'PASS'],
'test/d.html': ['PASS', 'PASS'],
'test/e.html': ['PASS', 'PASS'],
'test/f.html': ['PASS', 'PASS'],
}
}
self._expectations_remover = (self._create_expectations_remover(
self.FLAKE_TYPE))
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(updated_expectations, test_expectations_before)
def test_dont_remove_directory_fail(self):
"""Tests that fail lines with directories are untouched."""
test_expectations_before = _strip_multiline_string_spaces("""
# results: [ Failure ]
# This expectation is for a whole directory.
test/* [ Failure ]""")
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('trusty', 'x86_64'), )
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {
'test/a.html': ['PASS', 'PASS'],
'test/b.html': ['PASS', 'PASS'],
'test/c.html': ['PASS', 'PASS'],
'test/d.html': ['PASS', 'PASS'],
'test/e.html': ['PASS', 'PASS'],
'test/f.html': ['PASS', 'PASS'],
}
}
self._expectations_remover = (self._create_expectations_remover(
self.FAIL_TYPE))
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(updated_expectations, test_expectations_before)
def test_dont_remove_skip(self):
"""Tests that lines with Skip are untouched.
If a line is marked as Skip, it will eventually contain no results,
which is indistinguishable from "All Passing" so don't remove since we
don't know what the results actually are.
"""
test_expectations_before = _strip_multiline_string_spaces("""
# results: [ Skip ]
# Skip expectations should never be removed.
test/a.html [ Skip ]
test/b.html [ Skip ]
test/c.html [ Skip ]""")
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('trusty', 'x86_64'), )
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {
'test/a.html': ['PASS', 'PASS'],
'test/b.html': ['PASS', 'FAIL'],
}
}
self._expectations_remover = self._create_expectations_remover()
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(updated_expectations, test_expectations_before)
def test_all_failure_result_types(self):
"""Tests that all failure types are treated as failure."""
test_expectations_before = _strip_multiline_string_spaces(
"""# results: [ Failure Pass ]
test/a.html [ Failure Pass ]
test/b.html [ Failure Pass ]
test/c.html [ Failure Pass ]
test/d.html [ Failure Pass ]
# Remove these two since CRASH and TIMEOUT aren't considered
# Failure.
test/e.html [ Failure Pass ]
test/f.html [ Failure Pass ]""")
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('trusty', 'x86_64'), )
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {
'test/a.html': ['PASS', 'FAIL'],
'test/b.html': ['PASS', 'FAIL'],
'test/c.html': ['PASS', 'FAIL'],
'test/d.html': ['PASS', 'FAIL'],
'test/e.html': ['PASS', 'CRASH'],
'test/f.html': ['PASS', 'TIMEOUT'],
}
}
self._expectations_remover = self._create_expectations_remover()
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(
updated_expectations,
_strip_multiline_string_spaces("""# results: [ Failure Pass ]
test/a.html [ Failure Pass ]
test/b.html [ Failure Pass ]
test/c.html [ Failure Pass ]
test/d.html [ Failure Pass ]"""))
def test_fail_mode_all_fail_types_removed(self):
"""Tests that all types of fail expectation are removed in fail mode.
Fail expectation types include Failure, Timeout, and Crash.
"""
test_expectations_before = _strip_multiline_string_spaces(
"""# results: [ Timeout Crash Failure ]
test/a.html [ Failure ]
test/b.html [ Timeout ]
test/c.html [ Crash ]
test/d.html [ Failure ]""")
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('trusty', 'x86_64'), )
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {
'test/a.html': ['PASS', 'PASS'],
'test/b.html': ['PASS', 'PASS'],
'test/c.html': ['PASS', 'PASS'],
}
}
self._expectations_remover = (self._create_expectations_remover(
self.FAIL_TYPE))
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
# The line with test/d.html is not removed since
# --remove-missing is false by default; lines for
# tests with no actual results are kept.
self.assertEquals(
updated_expectations,
_strip_multiline_string_spaces(
"""# results: [ Timeout Crash Failure ]
test/d.html [ Failure ]"""))
def test_basic_one_builder(self):
"""Tests basic functionality with a single builder.
Test that expectations with results from a single bot showing the
expected failure isn't occurring should be removed. Results with failures
of the expected type shouldn't be removed but other kinds of failures
allow removal.
"""
test_expectations_before = _strip_multiline_string_spaces(
"""# results: [ Failure Pass Crash Timeout ]
# Remove these two since they're passing all runs.
test/a.html [ Failure Pass ]
test/b.html [ Failure ]
# Remove these two since the failure is not a Timeout
test/c.html [ Pass Timeout ]
test/d.html [ Timeout ]
# Keep since we have both crashes and passes.
test/e.html [ Crash Pass ]""")
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('trusty', 'x86_64'), )
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {
'test/a.html': ['PASS', 'PASS', 'PASS'],
'test/b.html': ['PASS', 'PASS', 'PASS'],
'test/c.html': ['PASS', 'FAIL', 'PASS'],
'test/d.html': ['PASS', 'FAIL', 'PASS'],
'test/e.html': ['PASS', 'CRASH', 'PASS'],
}
}
self._expectations_remover = self._create_expectations_remover()
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(
updated_expectations,
_strip_multiline_string_spaces(
"""# results: [ Failure Pass Crash Timeout ]
# Keep since we have both crashes and passes.
test/e.html [ Crash Pass ]"""))
def test_flake_mode_all_failure_case(self):
"""Tests that results with all failures are not treated as non-flaky."""
test_expectations_before = _strip_multiline_string_spaces(
"""# results: [ Failure Pass ]
# Keep since it's all failures.
test/a.html [ Failure Pass ]""")
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('trusty', 'x86_64'), )
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {
'test/a.html': ['FAIL', 'FAIL', 'FAIL'],
}
}
self._expectations_remover = (self._create_expectations_remover(
self.FLAKE_TYPE))
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(
updated_expectations,
_strip_multiline_string_spaces("""# results: [ Failure Pass ]
# Keep since it's all failures.
test/a.html [ Failure Pass ]"""))
def test_remove_none_met(self):
"""Tests that expectations with no matching result are removed.
Expectations that are failing in a different way than specified should
be removed, even if there is no passing result.
"""
test_expectations_before = ("""# results: [ Failure Pass ]
# Remove all since CRASH and TIMEOUT aren't considered Failure.
test/a.html [ Failure Pass ]
test/b.html [ Failure Pass ]
test/c.html [ Failure ]
test/d.html [ Failure ]""")
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('trusty', 'x86_64'), )
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {
'test/a.html': ['CRASH'],
'test/b.html': ['TIMEOUT'],
'test/c.html': ['CRASH'],
'test/d.html': ['TIMEOUT'],
}
}
self._expectations_remover = self._create_expectations_remover()
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(updated_expectations,
('# results: [ Failure Pass ]'))
def test_empty_test_expectations(self):
"""Running on an empty TestExpectations file outputs an empty file."""
test_expectations_before = ''
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('trusty', 'x86_64'), )
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {
'test/a.html': ['PASS', 'PASS', 'PASS'],
}
}
self._expectations_remover = self._create_expectations_remover()
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(updated_expectations, '')
def test_basic_multiple_builders(self):
"""Tests basic functionality with multiple builders."""
test_expectations_before = _strip_multiline_string_spaces(
"""# results: [ Failure Pass ]
# Remove these two since they're passing on both builders.
test/a.html [ Failure Pass ]
test/b.html [ Failure ]
# Keep these two since they're failing on the Mac builder.
test/c.html [ Failure Pass ]
test/d.html [ Failure ]
# Keep these two since they're failing on the Linux builder.
test/e.html [ Failure Pass ]
test/f.html [ Failure ]""")
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
'WebKit Mac10.10': {
'port_name': 'mac-mac10.10',
'specifiers': ['Mac10.10', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('mac10.10', 'x86'), ('trusty', 'x86_64'))
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {
'test/a.html': ['PASS', 'PASS', 'PASS'],
'test/b.html': ['PASS', 'PASS', 'PASS'],
'test/c.html': ['PASS', 'PASS', 'PASS'],
'test/d.html': ['PASS', 'PASS', 'PASS'],
'test/e.html': ['FAIL', 'FAIL', 'FAIL'],
'test/f.html': ['FAIL', 'FAIL', 'FAIL'],
},
'WebKit Mac10.10': {
'test/a.html': ['PASS', 'PASS', 'PASS'],
'test/b.html': ['PASS', 'PASS', 'PASS'],
'test/c.html': ['PASS', 'PASS', 'FAIL'],
'test/d.html': ['PASS', 'PASS', 'FAIL'],
'test/e.html': ['PASS', 'PASS', 'PASS'],
'test/f.html': ['PASS', 'PASS', 'PASS'],
},
}
self._expectations_remover = self._create_expectations_remover()
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(
updated_expectations,
_strip_multiline_string_spaces("""# results: [ Failure Pass ]
# Keep these two since they're failing on the Mac builder.
test/c.html [ Failure Pass ]
test/d.html [ Failure ]
# Keep these two since they're failing on the Linux builder.
test/e.html [ Failure Pass ]
test/f.html [ Failure ]"""))
def test_multiple_builders_and_platform_specifiers(self):
"""Tests correct operation with platform specifiers."""
test_expectations_before = _strip_multiline_string_spaces("""
# tags: [ Linux Mac Win Mac ]
# results: [ Failure Pass ]
# Keep these two since they're failing in the Mac10.10 results.
[ Mac ] test/a.html [ Failure Pass ]
[ Mac ] test/b.html [ Failure ]
# Keep these two since they're failing on the Windows builder.
[ Linux ] test/c.html [ Failure Pass ]
[ Win ] test/c.html [ Failure Pass ]
[ Linux ] test/d.html [ Failure ]
[ Win ] test/d.html [ Failure ]
# Remove these two since they're passing on both Linux and Windows builders.
[ Linux ] test/e.html [ Failure Pass ]
[ Win ] test/e.html [ Failure Pass ]
[ Linux ] test/f.html [ Failure ]
[ Win ] test/f.html [ Failure ]
# Remove these two since they're passing on Mac results
[ Mac ] test/g.html [ Failure Pass ]
[ Mac ] test/h.html [ Failure ]""")
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
'WebKit Mac10.10': {
'port_name': 'mac-mac10.10',
'specifiers': ['Mac10.10', 'Release']
},
'WebKit Mac10.11': {
'port_name': 'mac-mac10.11',
'specifiers': ['Mac10.11', 'Release']
},
'WebKit Win7': {
'port_name': 'win-win7',
'specifiers': ['Win7', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (
('mac10.10', 'x86'),
('mac10.11', 'x86'),
('trusty', 'x86_64'),
('win7', 'x86'),
)
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {
'test/a.html': ['PASS', 'PASS', 'PASS'],
'test/b.html': ['PASS', 'PASS', 'PASS'],
'test/c.html': ['PASS', 'PASS', 'PASS'],
'test/d.html': ['PASS', 'PASS', 'PASS'],
'test/e.html': ['PASS', 'PASS', 'PASS'],
'test/f.html': ['PASS', 'PASS', 'PASS'],
'test/g.html': ['FAIL', 'PASS', 'PASS'],
'test/h.html': ['FAIL', 'PASS', 'PASS'],
},
'WebKit Mac10.10': {
'test/a.html': ['PASS', 'PASS', 'FAIL'],
'test/b.html': ['PASS', 'PASS', 'FAIL'],
'test/c.html': ['PASS', 'FAIL', 'PASS'],
'test/d.html': ['PASS', 'FAIL', 'PASS'],
'test/e.html': ['PASS', 'FAIL', 'PASS'],
'test/f.html': ['PASS', 'FAIL', 'PASS'],
'test/g.html': ['PASS', 'PASS', 'PASS'],
'test/h.html': ['PASS', 'PASS', 'PASS'],
},
'WebKit Mac10.11': {
'test/a.html': ['PASS', 'PASS', 'PASS'],
'test/b.html': ['PASS', 'PASS', 'PASS'],
'test/c.html': ['PASS', 'PASS', 'PASS'],
'test/d.html': ['PASS', 'PASS', 'PASS'],
'test/e.html': ['PASS', 'PASS', 'PASS'],
'test/f.html': ['PASS', 'PASS', 'PASS'],
'test/g.html': ['PASS', 'PASS', 'PASS'],
'test/h.html': ['PASS', 'PASS', 'PASS'],
},
'WebKit Win7': {
'test/a.html': ['PASS', 'PASS', 'PASS'],
'test/b.html': ['PASS', 'PASS', 'PASS'],
'test/c.html': ['FAIL', 'PASS', 'PASS'],
'test/d.html': ['FAIL', 'PASS', 'PASS'],
'test/e.html': ['PASS', 'PASS', 'PASS'],
'test/f.html': ['PASS', 'PASS', 'PASS'],
'test/g.html': ['FAIL', 'PASS', 'PASS'],
'test/h.html': ['FAIL', 'PASS', 'PASS'],
},
}
self._expectations_remover = self._create_expectations_remover()
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(
updated_expectations,
_strip_multiline_string_spaces("""
# tags: [ Linux Mac Win Mac ]
# results: [ Failure Pass ]
# Keep these two since they're failing in the Mac10.10 results.
[ Mac ] test/a.html [ Failure Pass ]
[ Mac ] test/b.html [ Failure ]
# Keep these two since they're failing on the Windows builder.
[ Win ] test/c.html [ Failure Pass ]
[ Win ] test/d.html [ Failure ]"""))
def test_debug_release_specifiers(self):
"""Tests correct operation of Debug/Release specifiers."""
test_expectations_before = _strip_multiline_string_spaces(
"""# Keep these two since they fail in debug.
# tags: [ Linux ]
# tags: [ Debug Release ]
# results: [ Failure Pass ]
[ Linux ] test/a.html [ Failure Pass ]
[ Linux ] test/b.html [ Failure ]
# Remove these two since failure is in Release, Debug is all PASS.
[ Debug ] test/c.html [ Failure Pass ]
[ Debug ] test/d.html [ Failure ]
# Keep these two since they fail in Linux Release.
[ Release ] test/e.html [ Failure Pass ]
[ Release ] test/f.html [ Failure ]
# Remove these two since the Release Linux builder is all passing.
[ Release Linux ] test/g.html [ Failure Pass ]
[ Release Linux ] test/h.html [ Failure ]
# Remove these two since all the Linux builders PASS.
[ Linux ] test/i.html [ Failure Pass ]
[ Linux ] test/j.html [ Failure ]""")
self._define_builders({
'WebKit Win7': {
'port_name': 'win-win7',
'specifiers': ['Win7', 'Release']
},
'WebKit Win7 (dbg)': {
'port_name': 'win-win7',
'specifiers': ['Win7', 'Debug']
},
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
'WebKit Linux Trusty (dbg)': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Debug']
},
})
self._port.all_build_types = ('release', 'debug')
self._port.all_systems = (('win7', 'x86'), ('trusty', 'x86_64'))
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {
'test/a.html': ['PASS', 'PASS', 'PASS'],
'test/b.html': ['PASS', 'PASS', 'PASS'],
'test/c.html': ['PASS', 'FAIL', 'PASS'],
'test/d.html': ['PASS', 'FAIL', 'PASS'],
'test/e.html': ['PASS', 'FAIL', 'PASS'],
'test/f.html': ['PASS', 'FAIL', 'PASS'],
'test/g.html': ['PASS', 'PASS', 'PASS'],
'test/h.html': ['PASS', 'PASS', 'PASS'],
'test/i.html': ['PASS', 'PASS', 'PASS'],
'test/j.html': ['PASS', 'PASS', 'PASS'],
},
'WebKit Linux Trusty (dbg)': {
'test/a.html': ['PASS', 'FAIL', 'PASS'],
'test/b.html': ['PASS', 'FAIL', 'PASS'],
'test/c.html': ['PASS', 'PASS', 'PASS'],
'test/d.html': ['PASS', 'PASS', 'PASS'],
'test/e.html': ['PASS', 'PASS', 'PASS'],
'test/f.html': ['PASS', 'PASS', 'PASS'],
'test/g.html': ['FAIL', 'PASS', 'PASS'],
'test/h.html': ['FAIL', 'PASS', 'PASS'],
'test/i.html': ['PASS', 'PASS', 'PASS'],
'test/j.html': ['PASS', 'PASS', 'PASS'],
},
'WebKit Win7 (dbg)': {
'test/a.html': ['PASS', 'PASS', 'PASS'],
'test/b.html': ['PASS', 'PASS', 'PASS'],
'test/c.html': ['PASS', 'PASS', 'PASS'],
'test/d.html': ['PASS', 'PASS', 'PASS'],
'test/e.html': ['PASS', 'PASS', 'PASS'],
'test/f.html': ['PASS', 'PASS', 'PASS'],
'test/g.html': ['PASS', 'FAIL', 'PASS'],
'test/h.html': ['PASS', 'FAIL', 'PASS'],
'test/i.html': ['PASS', 'PASS', 'PASS'],
'test/j.html': ['PASS', 'PASS', 'PASS'],
},
'WebKit Win7': {
'test/a.html': ['PASS', 'PASS', 'PASS'],
'test/b.html': ['PASS', 'PASS', 'PASS'],
'test/c.html': ['PASS', 'PASS', 'FAIL'],
'test/d.html': ['PASS', 'PASS', 'FAIL'],
'test/e.html': ['PASS', 'PASS', 'PASS'],
'test/f.html': ['PASS', 'PASS', 'PASS'],
'test/g.html': ['PASS', 'FAIL', 'PASS'],
'test/h.html': ['PASS', 'FAIL', 'PASS'],
'test/i.html': ['PASS', 'PASS', 'PASS'],
'test/j.html': ['PASS', 'PASS', 'PASS'],
},
}
self._expectations_remover = self._create_expectations_remover()
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(
updated_expectations,
_strip_multiline_string_spaces(
"""# Keep these two since they fail in debug.
# tags: [ Linux ]
# tags: [ Debug Release ]
# results: [ Failure Pass ]
[ Linux ] test/a.html [ Failure Pass ]
[ Linux ] test/b.html [ Failure ]
# Keep these two since they fail in Linux Release.
[ Release ] test/e.html [ Failure Pass ]
[ Release ] test/f.html [ Failure ]"""))
def test_preserve_comments_and_whitespace(self):
test_expectations_before = _strip_multiline_string_spaces("""
# results: [ Failure Pass ]
# Comment A - Keep since these aren't part of any test.
# Comment B - Keep since these aren't part of any test.
# Comment C - Remove since it's a block belonging to a
# Comment D - and a is removed.
test/a.html [ Failure Pass ]
# Comment E - Keep since it's below a.
# Comment F - Keep since only b is removed
test/b.html [ Failure Pass ]
test/c.html [ Failure Pass ]
# Comment G - Should be removed since both d and e will be removed.
test/d.html [ Failure Pass ]
test/e.html [ Failure Pass ]""")
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('trusty', 'x86_64'), )
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {
'test/a.html': ['PASS', 'PASS', 'PASS'],
'test/b.html': ['PASS', 'PASS', 'PASS'],
'test/c.html': ['PASS', 'FAIL', 'PASS'],
'test/d.html': ['PASS', 'PASS', 'PASS'],
'test/e.html': ['PASS', 'PASS', 'PASS'],
}
}
self._expectations_remover = self._create_expectations_remover()
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(updated_expectations,
(_strip_multiline_string_spaces("""
# results: [ Failure Pass ]
# Comment A - Keep since these aren't part of any test.
# Comment B - Keep since these aren't part of any test.
# Comment E - Keep since it's below a.
# Comment F - Keep since only b is removed
test/c.html [ Failure Pass ]""")))
def test_lines_with_no_results_on_builders_kept_by_default(self):
"""Tests the case where there are lines with no results on the builders.
A test that has no results returned from the builders means that all
runs passed or were skipped. This might be because the test is skipped
because it's not in the SmokeTests file (e.g. on Android); or it might
potentially be that the test is legitimately no longer run anywhere.
In the former case, we may want to keep the line; but it may also be
useful to be able to remove it.
"""
test_expectations_before = _strip_multiline_string_spaces("""
# results: [ Failure Skip Timeout Pass Crash ]
# A Skip expectation probably won't have any results but we
# shouldn't consider those passing so this line should remain.
test/a.html [ Skip ]
# The lines below should be kept since the flag for removing
# such results (--remove-missing) is not passed.
test/b.html [ Failure Timeout ]
test/c.html [ Failure Pass ]
test/d.html [ Pass Timeout ]
test/e.html [ Crash Pass ]""")
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('trusty', 'x86_64'), )
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {}
}
self._expectations_remover = self._create_expectations_remover()
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(updated_expectations, test_expectations_before)
def test_lines_with_no_results_on_builders_can_be_removed(self):
"""Tests that we remove a line that has no results on the builders.
In this test, we simulate what would happen when --remove-missing
is passed.
"""
test_expectations_before = _strip_multiline_string_spaces("""
# results: [ Failure Timeout Pass Crash Skip ]
# A Skip expectation probably won't have any results but we
# shouldn't consider those passing so this line should remain.
test/a.html [ Skip ]
# The lines below should be removed since the flag for removing
# such results (--remove-missing) is passed.
test/b.html [ Failure Timeout ]
test/e.html [ Crash Pass ]
test/c.html [ Failure Pass ]
test/d.html [ Pass Timeout ]""")
self._define_builders({
'WebKit Linux Trusty': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('trusty', 'x86_64'), )
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux Trusty': {}
}
self._expectations_remover = self._create_expectations_remover(
remove_missing=True)
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(
updated_expectations,
_strip_multiline_string_spaces("""
# results: [ Failure Timeout Pass Crash Skip ]
# A Skip expectation probably won't have any results but we
# shouldn't consider those passing so this line should remain.
test/a.html [ Skip ]"""))
def test_include_cq_results(self):
"""By default, cq results are ignored."""
test_expectations_before = _strip_multiline_string_spaces("""
# results: [ Failure Pass ]
# Remove this if cq results are ignored.
crbug.com/1111 test/a.html [ Failure Pass ]""")
self._define_builders({
'WebKit Linux': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release']
},
'WebKit Linux try': {
'port_name': 'linux-trusty',
'specifiers': ['Trusty', 'Release'],
'is_try_builder': True
},
})
self._port.all_build_types = ('release', )
self._port.all_systems = (('trusty', 'x86_64'), )
self._parse_expectations(test_expectations_before)
self._expectation_factory.all_results_by_builder = {
'WebKit Linux': {'test/a.html': ['PASS', 'PASS', 'PASS'],},
'WebKit Linux try': {'test/a.html': ['PASS', 'FAIL', 'PASS'],}
}
self._expectations_remover = self._create_expectations_remover()
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(
updated_expectations,
_strip_multiline_string_spaces("""
# results: [ Failure Pass ]"""))
self._expectations_remover = (
self._create_expectations_remover(include_cq_results=True))
updated_expectations = (
self._expectations_remover.get_updated_test_expectations())
self.assertEquals(updated_expectations, test_expectations_before)
def test_missing_builders_for_some_configurations(self):
"""Tests the behavior when there are no builders for some configurations.