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

Side by Side Diff: content/test/gpu/gpu_tests/gpu_integration_test_unittest.py

Issue 2151983002: Adding logic to restart the browser if there is an exception (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Syncing client Created 4 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
« no previous file with comments | « content/test/gpu/gpu_tests/gpu_integration_test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import mock 6 import mock
7 import os 7 import os
8 import tempfile 8 import tempfile
9 import unittest 9 import unittest
10 10
11 from telemetry.testing import fakes 11 from telemetry.testing import fakes
12 from telemetry.testing import browser_test_runner 12 from telemetry.testing import browser_test_runner
13 13
14 import gpu_project_config 14 import gpu_project_config
15 15
16 from gpu_tests import gpu_integration_test 16 from gpu_tests import gpu_integration_test
17 from gpu_tests import gpu_test_expectations 17 from gpu_tests import gpu_test_expectations
18 18
19 _GLOBAL_TEST_COUNT = 0
19 20
20 class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest): 21 class SimpleIntegrationUnittest(gpu_integration_test.GpuIntegrationTest):
21 # Must be class-scoped since instances aren't reused across runs. 22 # Must be class-scoped since instances aren't reused across runs.
22 _num_flaky_runs_to_fail = 2 23 _num_flaky_runs_to_fail = 2
23 24
24 _num_browser_starts = 0 25 _num_browser_starts = 0
25 26
26 @classmethod 27 @classmethod
27 def Name(cls): 28 def Name(cls):
28 return 'simple_integration_unittest' 29 return 'simple_integration_unittest'
29 30
31 def setUp(self):
32 global _GLOBAL_TEST_COUNT
33 _GLOBAL_TEST_COUNT += 1
34 # If this is the first test, fail on setup to ensure that the
35 # gpu_integration_test handles failures in setup and remaining tests
36 # can be executed
37 if _GLOBAL_TEST_COUNT == 1:
38 self.tab.Navigate('chrome://crash')
39 super(SimpleIntegrationUnittest, self).setUp()
40
30 @classmethod 41 @classmethod
31 def setUpClass(cls): 42 def setUpClass(cls):
32 finder_options = fakes.CreateBrowserFinderOptions() 43 finder_options = fakes.CreateBrowserFinderOptions()
33 finder_options.browser_options.platform = fakes.FakeLinuxPlatform() 44 finder_options.browser_options.platform = fakes.FakeLinuxPlatform()
34 finder_options.output_formats = ['none'] 45 finder_options.output_formats = ['none']
35 finder_options.suppress_gtest_report = True 46 finder_options.suppress_gtest_report = True
36 finder_options.output_dir = None 47 finder_options.output_dir = None
37 finder_options.upload_bucket = 'public' 48 finder_options.upload_bucket = 'public'
38 finder_options.upload_results = False 49 finder_options.upload_results = False
39 cls._finder_options = finder_options 50 cls._finder_options = finder_options
40 cls.platform = None 51 cls.platform = None
41 cls.browser = None 52 cls.browser = None
42 cls.SetBrowserOptions(cls._finder_options) 53 cls.SetBrowserOptions(cls._finder_options)
43 cls.StartBrowser() 54 cls.StartBrowser()
44 55
45 @classmethod 56 @classmethod
46 def GenerateGpuTests(cls, options): 57 def GenerateGpuTests(cls, options):
58 yield ('setup', 'failure.html', ())
47 yield ('expected_failure', 'failure.html', ()) 59 yield ('expected_failure', 'failure.html', ())
48 yield ('expected_flaky', 'flaky.html', ()) 60 yield ('expected_flaky', 'flaky.html', ())
49 yield ('expected_skip', 'failure.html', ()) 61 yield ('expected_skip', 'failure.html', ())
50 yield ('unexpected_failure', 'failure.html', ()) 62 yield ('unexpected_failure', 'failure.html', ())
51 yield ('unexpected_error', 'error.html', ()) 63 yield ('unexpected_error', 'error.html', ())
52 64
53 @classmethod 65 @classmethod
54 def _CreateExpectations(cls): 66 def _CreateExpectations(cls):
55 expectations = gpu_test_expectations.GpuTestExpectations() 67 expectations = gpu_test_expectations.GpuTestExpectations()
56 expectations.Fail('expected_failure') 68 expectations.Fail('expected_failure')
(...skipping 28 matching lines...) Expand all
85 temp_file.close() 97 temp_file.close()
86 temp_file_name = temp_file.name 98 temp_file_name = temp_file.name
87 try: 99 try:
88 browser_test_runner.Run( 100 browser_test_runner.Run(
89 config, options, 101 config, options,
90 ['simple_integration_unittest', 102 ['simple_integration_unittest',
91 '--write-abbreviated-json-results-to=%s' % temp_file_name]) 103 '--write-abbreviated-json-results-to=%s' % temp_file_name])
92 with open(temp_file_name) as f: 104 with open(temp_file_name) as f:
93 test_result = json.load(f) 105 test_result = json.load(f)
94 self.assertEquals(test_result['failures'], [ 106 self.assertEquals(test_result['failures'], [
107 'expected_failure',
108 'setup',
95 'unexpected_error', 109 'unexpected_error',
96 'unexpected_failure']) 110 'unexpected_failure'])
97 self.assertEquals(test_result['successes'], [ 111 self.assertEquals(test_result['successes'], [
98 'expected_failure',
99 'expected_flaky']) 112 'expected_flaky'])
100 self.assertEquals(test_result['valid'], True) 113 self.assertEquals(test_result['valid'], True)
101 # It might be nice to be more precise about the order of operations 114 # It might be nice to be more precise about the order of operations
102 # with these browser restarts, but this is at least a start. 115 # with these browser restarts, but this is at least a start.
103 self.assertEquals(SimpleIntegrationUnittest._num_browser_starts, 5) 116 self.assertEquals(SimpleIntegrationUnittest._num_browser_starts, 6)
104 finally: 117 finally:
105 os.remove(temp_file_name) 118 os.remove(temp_file_name)
OLDNEW
« no previous file with comments | « content/test/gpu/gpu_tests/gpu_integration_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698