Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: scripts/common/unittests/gtest_utils_test.py

Issue 373223003: Implemented parsing of the ignored failing tests spec and ignoring respective failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Fixed a typo Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « scripts/common/gtest_utils.py ('k') | scripts/slave/runtest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for classes in gtest_command.py.""" 6 """Unit tests for classes in gtest_command.py."""
7 7
8 import os
9 import tempfile
8 import unittest 10 import unittest
9 11
10 import test_env # pylint: disable=W0611 12 import test_env # pylint: disable=W0611
11 13
14 from common import chromium_utils
15 from common import find_depot_tools # pylint: disable=W0611
12 from common import gtest_utils 16 from common import gtest_utils
13 17
18 from testing_support import auto_stub
14 19
15 FAILURES = ['NavigationControllerTest.Reload', 20 FAILURES = ['NavigationControllerTest.Reload',
16 'NavigationControllerTest/SpdyNetworkTransTest.Constructor/0', 21 'NavigationControllerTest/SpdyNetworkTransTest.Constructor/0',
17 'BadTest.TimesOut', 22 'BadTest.TimesOut',
18 'MoreBadTest.TimesOutAndFails', 23 'MoreBadTest.TimesOutAndFails',
19 'SomeOtherTest.SwitchTypes', 24 'SomeOtherTest.SwitchTypes',
20 'SomeOtherTest.FAILS_ThisTestTimesOut'] 25 'SomeOtherTest.FAILS_ThisTestTimesOut']
21 26
22 FAILS_FAILURES = ['SomeOtherTest.FAILS_Bar'] 27 FAILS_FAILURES = ['SomeOtherTest.FAILS_Bar']
23 FLAKY_FAILURES = ['SomeOtherTest.FLAKY_Baz'] 28 FLAKY_FAILURES = ['SomeOtherTest.FLAKY_Baz']
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 Tests took 31 seconds. 435 Tests took 31 seconds.
431 436
432 437
433 ================================================================ 438 ================================================================
434 End output from shard index 0 (machine tag: swarm12.c, id: swarm12). Return 1 439 End output from shard index 0 (machine tag: swarm12.c, id: swarm12). Return 1
435 ================================================================ 440 ================================================================
436 441
437 """ 442 """
438 443
439 444
440 class TestGTestLogParserTests(unittest.TestCase): 445 class TestGTestLogParserTests(auto_stub.TestCase):
441 446
442 def testGTestLogParserNoSharing(self): 447 def testGTestLogParserNoSharing(self):
443 # Tests for log parsing without sharding. 448 # Tests for log parsing without sharding.
444 parser = gtest_utils.GTestLogParser() 449 parser = gtest_utils.GTestLogParser()
445 for line in TEST_DATA.splitlines(): 450 for line in TEST_DATA.splitlines():
446 parser.ProcessLine(line) 451 parser.ProcessLine(line)
447 452
448 self.assertEqual(0, len(parser.ParsingErrors())) 453 self.assertEqual(0, len(parser.ParsingErrors()))
449 self.assertFalse(parser.RunningTests()) 454 self.assertFalse(parser.RunningTests())
450 455
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 ], 636 ],
632 parser.FailureDescription('PickleTest.EncodeDecode')) 637 parser.FailureDescription('PickleTest.EncodeDecode'))
633 638
634 def testNestedGtests(self): 639 def testNestedGtests(self):
635 parser = gtest_utils.GTestLogParser() 640 parser = gtest_utils.GTestLogParser()
636 for line in TEST_DATA_NESTED_RUNS.splitlines(): 641 for line in TEST_DATA_NESTED_RUNS.splitlines():
637 parser.ProcessLine(line) 642 parser.ProcessLine(line)
638 self.assertEqual(['Foo.Bar'], parser.FailedTests(True, True)) 643 self.assertEqual(['Foo.Bar'], parser.FailedTests(True, True))
639 644
640 645
641 class TestGTestJSONParserTests(unittest.TestCase): 646 class TestGTestJSONParserTests(auto_stub.TestCase):
642 def testPassedTests(self): 647 def testPassedTests(self):
643 parser = gtest_utils.GTestJSONParser() 648 parser = gtest_utils.GTestJSONParser()
644 parser.ProcessJSONData({ 649 parser.ProcessJSONData({
645 'disabled_tests': [], 650 'disabled_tests': [],
646 'per_iteration_data': [ 651 'per_iteration_data': [
647 { 652 {
648 'Test.One': [{'status': 'SUCCESS', 'output_snippet': ''}], 653 'Test.One': [{'status': 'SUCCESS', 'output_snippet': ''}],
649 'Test.Two': [{'status': 'SUCCESS', 'output_snippet': ''}], 654 'Test.Two': [{'status': 'SUCCESS', 'output_snippet': ''}],
650 } 655 }
651 ] 656 ]
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 'Test.One': [{'status': 'SUCCESS', 'output_snippet': ''}], 707 'Test.One': [{'status': 'SUCCESS', 'output_snippet': ''}],
703 } 708 }
704 ] 709 ]
705 }) 710 })
706 711
707 self.assertEqual(['Test.One'], parser.PassedTests()) 712 self.assertEqual(['Test.One'], parser.PassedTests())
708 self.assertEqual([], parser.FailedTests()) 713 self.assertEqual([], parser.FailedTests())
709 self.assertEqual(0, parser.FlakyTests()) 714 self.assertEqual(0, parser.FlakyTests())
710 self.assertEqual(1, parser.DisabledTests()) 715 self.assertEqual(1, parser.DisabledTests())
711 716
717 def testIngoredFailedTests(self):
718 TEST_IGNORED_FAILED_TESTS_SPEC = """
719 # A comment.
720
721 crbug.com/12345 [ OS_WIN , OS_LINUX] Test.One
722 crbug.com/12345 [OS_WIN CPU_64_BITS MODE_RELEASE] Test.Two/2
723 crbug.com/12345 [,OS_MACOSX, OS_WIN CPU_64_BITS, ] Perf/Test.Three
724 crbug.com/12345 [ invalid.platform.spec ] Test.Four
725 crbug.com/12345 [ OS_WIN CPU_32_BITS MODE_RELEASE ] Test.Five
726 invalid line
727 """
728
729 _, spec_filename = tempfile.mkstemp()
730 spec_fd = open(spec_filename, 'w')
731 spec_fd.write(TEST_IGNORED_FAILED_TESTS_SPEC)
732 spec_fd.close()
733
734 self.mock(chromium_utils, 'FindUpward', lambda *_: spec_filename)
735 parser = gtest_utils.GTestJSONParser()
736
737 try:
738 parser.ProcessJSONData({
739 'disabled_tests': ['Test.Six'],
740 'per_iteration_data': [
741 {
742 'Test.One': [{'status': 'FAILURE', 'output_snippet': ''}],
743 'Test.Two/2': [{'status': 'FAILURE', 'output_snippet': ''}],
744 'Perf/Test.Three': [{'status': 'FAILURE', 'output_snippet': ''}],
745 'Test.Four': [{'status': 'FAILURE', 'output_snippet': ''}],
746 'Test.Five': [{'status': 'FAILURE', 'output_snippet': ''}],
747 }
748 ],
749 'global_tags': ['OS_WIN', 'CPU_64_BITS', 'MODE_RELEASE', 'OTHER_FLAG']
750 }, '/fake/path/to/build')
751 finally:
752 os.remove(spec_filename)
753
754 self.assertEqual(['Test.Five', 'Test.Four'], parser.FailedTests())
755 self.assertEqual(['Perf/Test.Three', 'Test.One', 'Test.Two/2'],
756 parser.IgnoredFailedTests())
757
758 # pylint: disable=R0201
759 def testDoesNotThrowExceptionOnMissingIgnoredFailedTestsFile(self):
760 parser = gtest_utils.GTestJSONParser()
761 parser.ProcessJSONData({'per_iteration_data': []}, tempfile.gettempdir())
762
712 def testCompressList(self): 763 def testCompressList(self):
713 CompressList = gtest_utils.CompressList 764 CompressList = gtest_utils.CompressList
714 self.assertEqual(['foo'], CompressList([1, 2, 3, 4], 0, 'foo')) 765 self.assertEqual(['foo'], CompressList([1, 2, 3, 4], 0, 'foo'))
715 self.assertEqual(['foo', 4], CompressList([1, 2, 3, 4], 1, 'foo')) 766 self.assertEqual(['foo', 4], CompressList([1, 2, 3, 4], 1, 'foo'))
716 self.assertEqual([1, 'foo', 4], CompressList([1, 2, 3, 4], 2, 'foo')) 767 self.assertEqual([1, 'foo', 4], CompressList([1, 2, 3, 4], 2, 'foo'))
717 self.assertEqual([1, 'foo', 3, 4], CompressList([1, 2, 3, 4], 3, 'foo')) 768 self.assertEqual([1, 'foo', 3, 4], CompressList([1, 2, 3, 4], 3, 'foo'))
718 self.assertEqual([1, 2, 3, 4], CompressList([1, 2, 3, 4], 4, 'foo')) 769 self.assertEqual([1, 2, 3, 4], CompressList([1, 2, 3, 4], 4, 'foo'))
719 self.assertEqual([1, 2, 3, 4], CompressList([1, 2, 3, 4], 5, 'foo')) 770 self.assertEqual([1, 2, 3, 4], CompressList([1, 2, 3, 4], 5, 'foo'))
720 self.assertEqual([1, 2, 3, 4], CompressList([1, 2, 3, 4], 6, 'foo')) 771 self.assertEqual([1, 2, 3, 4], CompressList([1, 2, 3, 4], 6, 'foo'))
721 772
722 773
723 if __name__ == '__main__': 774 if __name__ == '__main__':
724 unittest.main() 775 unittest.main()
OLDNEW
« no previous file with comments | « scripts/common/gtest_utils.py ('k') | scripts/slave/runtest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698