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

Side by Side Diff: build/android/pylib/gtest/test_runner.py

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 logging 5 import logging
6 import os 6 import os
7 import re 7 import re
8 import tempfile
8 9
9 from pylib import pexpect 10 from pylib import pexpect
10 from pylib import ports 11 from pylib import ports
11 from pylib.base import base_test_result 12 from pylib.base import base_test_result
12 from pylib.base import base_test_runner 13 from pylib.base import base_test_runner
13 from pylib.device import device_errors 14 from pylib.device import device_errors
15 from pylib.gtest import gtest_test_instance
14 from pylib.local import local_test_server_spawner 16 from pylib.local import local_test_server_spawner
15 from pylib.perf import perf_control 17 from pylib.perf import perf_control
16 18
17 # Test case statuses. 19 # Test case statuses.
18 RE_RUN = re.compile('\\[ RUN \\] ?(.*)\r\n') 20 RE_RUN = re.compile('\\[ RUN \\] ?(.*)\r\n')
19 RE_FAIL = re.compile('\\[ FAILED \\] ?(.*?)( \\((\\d+) ms\\))?\r\r\n') 21 RE_FAIL = re.compile('\\[ FAILED \\] ?(.*?)( \\((\\d+) ms\\))?\r\r\n')
20 RE_OK = re.compile('\\[ OK \\] ?(.*?)( \\((\\d+) ms\\))?\r\r\n') 22 RE_OK = re.compile('\\[ OK \\] ?(.*?)( \\((\\d+) ms\\))?\r\r\n')
21 23
22 # Test run statuses. 24 # Test run statuses.
23 RE_PASSED = re.compile('\\[ PASSED \\] ?(.*)\r\n') 25 RE_PASSED = re.compile('\\[ PASSED \\] ?(.*)\r\n')
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name): 74 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name):
73 self._perf_controller = perf_control.PerfControl(self.device) 75 self._perf_controller = perf_control.PerfControl(self.device)
74 76
75 if _TestSuiteRequiresMockTestServer(self.test_package.suite_name): 77 if _TestSuiteRequiresMockTestServer(self.test_package.suite_name):
76 self._servers = [ 78 self._servers = [
77 local_test_server_spawner.LocalTestServerSpawner( 79 local_test_server_spawner.LocalTestServerSpawner(
78 ports.AllocateTestServerPort(), self.device, self.tool)] 80 ports.AllocateTestServerPort(), self.device, self.tool)]
79 else: 81 else:
80 self._servers = [] 82 self._servers = []
81 83
84 if test_options.app_data_files:
85 self._app_data_files = test_options.app_data_files
86 if test_options.app_data_file_dir:
87 self._app_data_file_dir = test_options.app_data_file_dir
88 else:
89 self._app_data_file_dir = tempfile.mkdtemp()
90 logging.critical('Saving app files to %s', self._app_data_file_dir)
91 else:
92 self._app_data_files = None
93 self._app_data_file_dir = None
94
82 #override 95 #override
83 def InstallTestPackage(self): 96 def InstallTestPackage(self):
84 self.test_package.Install(self.device) 97 self.test_package.Install(self.device)
85 98
86 def _ParseTestOutput(self, p): 99 def _ParseTestOutput(self, p):
87 """Process the test output. 100 """Process the test output.
88 101
89 Args: 102 Args:
90 p: An instance of pexpect spawn class. 103 p: An instance of pexpect spawn class.
91 104
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 test_results = base_test_result.TestRunResults() 172 test_results = base_test_result.TestRunResults()
160 if not test: 173 if not test:
161 return test_results, None 174 return test_results, None
162 175
163 try: 176 try:
164 self.test_package.ClearApplicationState(self.device) 177 self.test_package.ClearApplicationState(self.device)
165 self.test_package.CreateCommandLineFileOnDevice( 178 self.test_package.CreateCommandLineFileOnDevice(
166 self.device, test, self._test_arguments) 179 self.device, test, self._test_arguments)
167 test_results = self._ParseTestOutput( 180 test_results = self._ParseTestOutput(
168 self.test_package.SpawnTestProcess(self.device)) 181 self.test_package.SpawnTestProcess(self.device))
182 if self._app_data_files:
183 self.test_package.PullAppFiles(self.device, self._app_data_files,
184 self._app_data_file_dir)
169 finally: 185 finally:
170 for s in self._servers: 186 for s in self._servers:
171 s.Reset() 187 s.Reset()
172 # Calculate unknown test results. 188 # Calculate unknown test results.
173 all_tests = set(test.split(':')) 189 all_tests = set(test.split(':'))
174 all_tests_ran = set([t.GetName() for t in test_results.GetAll()]) 190 all_tests_ran = set([t.GetName() for t in test_results.GetAll()])
175 unknown_tests = all_tests - all_tests_ran 191 unknown_tests = all_tests - all_tests_ran
176 test_results.AddResults( 192 test_results.AddResults(
177 [base_test_result.BaseTestResult(t, base_test_result.ResultType.UNKNOWN) 193 [base_test_result.BaseTestResult(t, base_test_result.ResultType.UNKNOWN)
178 for t in unknown_tests]) 194 for t in unknown_tests])
(...skipping 13 matching lines...) Expand all
192 #override 208 #override
193 def TearDown(self): 209 def TearDown(self):
194 """Cleans up the test enviroment for the test suite.""" 210 """Cleans up the test enviroment for the test suite."""
195 for s in self._servers: 211 for s in self._servers:
196 s.TearDown() 212 s.TearDown()
197 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name): 213 if _TestSuiteRequiresHighPerfMode(self.test_package.suite_name):
198 self._perf_controller.SetDefaultPerfMode() 214 self._perf_controller.SetDefaultPerfMode()
199 self.test_package.ClearApplicationState(self.device) 215 self.test_package.ClearApplicationState(self.device)
200 self.tool.CleanUpEnvironment() 216 self.tool.CleanUpEnvironment()
201 super(TestRunner, self).TearDown() 217 super(TestRunner, self).TearDown()
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/test_package_exe.py ('k') | build/android/pylib/instrumentation/instrumentation_test_instance.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698