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

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

Issue 12317059: [Andoid] Threaded TestRunner creation and SetUp and TearDown calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 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
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 glob 5 import glob
6 import logging 6 import logging
7 import os 7 import os
8 8
9 from pylib import android_commands 9 from pylib import android_commands
10 from pylib import constants 10 from pylib import constants
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 'filter', 233 'filter',
234 self.test_package.test_suite_basename) 234 self.test_package.test_suite_basename)
235 disabled_tests = run_tests_helper.GetExpectations( 235 disabled_tests = run_tests_helper.GetExpectations(
236 gtest_filter_base_path + '_disabled') 236 gtest_filter_base_path + '_disabled')
237 if self._running_on_emulator: 237 if self._running_on_emulator:
238 # Append emulator's filter file. 238 # Append emulator's filter file.
239 disabled_tests.extend(run_tests_helper.GetExpectations( 239 disabled_tests.extend(run_tests_helper.GetExpectations(
240 gtest_filter_base_path + '_emulator_additional_disabled')) 240 gtest_filter_base_path + '_emulator_additional_disabled'))
241 return disabled_tests 241 return disabled_tests
242 242
243 #override
243 def RunTest(self, test): 244 def RunTest(self, test):
244 """Runs a test on a single device. 245 """Runs a test on a single device.
245 246
246 Args: 247 Args:
247 test: a gtest filter string to run. 248 test: a gtest filter string to run.
248 249
249 Returns: 250 Returns:
250 Tuple: (TestResults, test to retry or None) 251 Tuple: (TestResults, test to retry or None)
251 """ 252 """
252 test_results = test_result.TestResults() 253 test_results = test_result.TestResults()
253 if not test: 254 if not test:
254 return test_results, None 255 return test_results, None
255 256
256 try: 257 try:
258 self.test_package.ClearApplicationState()
257 self.test_package.CreateTestRunnerScript(test, self._test_arguments) 259 self.test_package.CreateTestRunnerScript(test, self._test_arguments)
258 test_results = self.test_package.RunTestsAndListResults() 260 test_results = self.test_package.RunTestsAndListResults()
259 except errors.DeviceUnresponsiveError as e: 261 except errors.DeviceUnresponsiveError as e:
260 # Make sure this device is not attached 262 # Make sure this device is not attached
261 logging.warning(e) 263 logging.warning(e)
262 if android_commands.IsDeviceAttached(self.device): 264 if android_commands.IsDeviceAttached(self.device):
263 raise 265 raise
264 test_results.device_exception = device_exception
265 # Calculate unknown test results. 266 # Calculate unknown test results.
266 # TODO(frankf): Do not break TestResults encapsulation. 267 # TODO(frankf): Do not break TestResults encapsulation.
267 all_tests = set(test.split(':')) 268 all_tests = set(test.split(':'))
268 all_tests_ran = set([t.name for t in test_results.GetAll()]) 269 all_tests_ran = set([t.name for t in test_results.GetAll()])
269 unknown_tests = all_tests - all_tests_ran 270 unknown_tests = all_tests - all_tests_ran
270 test_results.unknown = [test_result.BaseTestResult(t, '') for t in 271 test_results.unknown = [test_result.BaseTestResult(t, '') for t in
271 unknown_tests] 272 unknown_tests]
272 retry = ':'.join([t.name for t in test_results.GetAllBroken()]) 273 retry = ':'.join([t.name for t in test_results.GetAllBroken()])
273 return test_results, retry 274 return test_results, retry
274 275
276 #override
275 def SetUp(self): 277 def SetUp(self):
276 """Sets up necessary test enviroment for the test suite.""" 278 """Sets up necessary test enviroment for the test suite."""
277 super(TestRunner, self).SetUp() 279 super(TestRunner, self).SetUp()
278 self.adb.ClearApplicationState(constants.CHROME_PACKAGE)
279 self.StripAndCopyFiles() 280 self.StripAndCopyFiles()
280 if _TestSuiteRequiresMockTestServer(self.test_package.test_suite_basename): 281 if _TestSuiteRequiresMockTestServer(self.test_package.test_suite_basename):
281 self.LaunchChromeTestServerSpawner() 282 self.LaunchChromeTestServerSpawner()
282 self.tool.SetupEnvironment() 283 self.tool.SetupEnvironment()
283 284
285 #override
284 def TearDown(self): 286 def TearDown(self):
285 """Cleans up the test enviroment for the test suite.""" 287 """Cleans up the test enviroment for the test suite."""
286 self.tool.CleanUpEnvironment() 288 self.tool.CleanUpEnvironment()
287 if self._cleanup_test_files: 289 if self._cleanup_test_files:
288 self.adb.RemovePushedFiles() 290 self.adb.RemovePushedFiles()
289 super(TestRunner, self).TearDown() 291 super(TestRunner, self).TearDown()
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/test_package_executable.py ('k') | build/android/pylib/utils/reraiser_thread.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698