Chromium Code Reviews| Index: scripts/common/unittests/gtest_utils_test.py |
| diff --git a/scripts/common/unittests/gtest_utils_test.py b/scripts/common/unittests/gtest_utils_test.py |
| index bf8dff3faa05515c937747328bbe0aaa9b484115..9b8d9aaa273ddac3367e6b5f4b216613bf873b4e 100755 |
| --- a/scripts/common/unittests/gtest_utils_test.py |
| +++ b/scripts/common/unittests/gtest_utils_test.py |
| @@ -5,12 +5,17 @@ |
| """Unit tests for classes in gtest_command.py.""" |
| +import os |
| +import tempfile |
| import unittest |
| import test_env # pylint: disable=W0611 |
| +from common import chromium_utils |
| +from common import find_depot_tools # pylint: disable=W0611 |
| from common import gtest_utils |
| +from testing_support import auto_stub |
| FAILURES = ['NavigationControllerTest.Reload', |
| 'NavigationControllerTest/SpdyNetworkTransTest.Constructor/0', |
| @@ -437,7 +442,7 @@ End output from shard index 0 (machine tag: swarm12.c, id: swarm12). Return 1 |
| """ |
| -class TestGTestLogParserTests(unittest.TestCase): |
| +class TestGTestLogParserTests(auto_stub.TestCase): |
| def testGTestLogParserNoSharing(self): |
| # Tests for log parsing without sharding. |
| @@ -638,7 +643,7 @@ class TestGTestLogParserTests(unittest.TestCase): |
| self.assertEqual(['Foo.Bar'], parser.FailedTests(True, True)) |
| -class TestGTestJSONParserTests(unittest.TestCase): |
| +class TestGTestJSONParserTests(auto_stub.TestCase): |
| def testPassedTests(self): |
| parser = gtest_utils.GTestJSONParser() |
| parser.ProcessJSONData({ |
| @@ -709,6 +714,52 @@ class TestGTestJSONParserTests(unittest.TestCase): |
| self.assertEqual(0, parser.FlakyTests()) |
| self.assertEqual(1, parser.DisabledTests()) |
| + def testIngoredFailedTests(self): |
| + TEST_IGNORED_FAILED_TESTS_SPEC = """ |
| + # A comment. |
| + |
| + http://crbug.com/12345 [ OS_WIN , OS_LINUX] Test.One |
| + http://crbug.com/12345 [OS_WIN CPU_64_BITS MODE_RELEASE] Test.Two/2 |
| + http://crbug.com/12345 [ OS_MACOSX, OS_WIN CPU_64_BITS ] Perf/Test.Three |
| + http://crbug.com/12345 [ invalid.platform.spec ] Test.Four |
| + http://crbug.com/12345 [ OS_WIN CPU_32_BITS MODE_RELEASE ] Test.Five |
| + invalid line |
| + """ |
| + |
| + _, spec_filename = tempfile.mkstemp() |
| + spec_fd = open(spec_filename, 'w') |
| + spec_fd.write(TEST_IGNORED_FAILED_TESTS_SPEC) |
| + spec_fd.close() |
| + |
| + self.mock(chromium_utils, 'FindUpward', lambda *_: spec_filename) |
| + parser = gtest_utils.GTestJSONParser() |
| + |
| + try: |
| + parser.ProcessJSONData({ |
| + 'disabled_tests': ['Test.Six'], |
| + 'per_iteration_data': [ |
| + { |
| + 'Test.One': [{'status': 'FAILURE', 'output_snippet': ''}], |
| + 'Test.Two/2': [{'status': 'FAILURE', 'output_snippet': ''}], |
| + 'Perf/Test.Three': [{'status': 'FAILURE', 'output_snippet': ''}], |
| + 'Test.Four': [{'status': 'FAILURE', 'output_snippet': ''}], |
| + 'Test.Five': [{'status': 'FAILURE', 'output_snippet': ''}], |
| + } |
| + ], |
| + 'global_tags': ['OS_WIN', 'CPU_64_BITS', 'MODE_RELEASE', 'OTHER_FLAG'] |
| + }, '/fake/path/to/build') |
| + finally: |
| + os.remove(spec_filename) |
|
eseidel
2014/07/09 16:07:02
It's really unfortunate that this test touches the
Sergiy Byelozyorov
2014/07/09 17:23:42
I wish I could mock 'open' function with self.mock
|
| + |
| + self.assertEqual(['Test.Five', 'Test.Four'], parser.FailedTests()) |
| + self.assertEqual(['Perf/Test.Three', 'Test.One', 'Test.Two/2'], |
| + parser.IgnoredFailedTests()) |
| + |
| + # pylint: disable=R0201 |
| + def testDoesNotThrowExceptionOnMissingIgnoredFailedTestsFile(self): |
| + parser = gtest_utils.GTestJSONParser() |
| + parser.ProcessJSONData({'per_iteration_data': []}, tempfile.gettempdir()) |
| + |
| def testCompressList(self): |
| CompressList = gtest_utils.CompressList |
| self.assertEqual(['foo'], CompressList([1, 2, 3, 4], 0, 'foo')) |