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

Unified Diff: build/android/pylib/gtest/setup.py

Issue 323073007: Android: Cleaned up python setup steps for gtests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comments from Marcus. Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/gtest/setup.py
diff --git a/build/android/pylib/gtest/setup.py b/build/android/pylib/gtest/setup.py
index e89846e3b1d46b60a7e09372084c73740e32a141..8f1f5b08651fe69b37331729319e33c937c37861 100644
--- a/build/android/pylib/gtest/setup.py
+++ b/build/android/pylib/gtest/setup.py
@@ -219,6 +219,44 @@ def _GetDisabledTestsFilterFromFile(suite_name):
return disabled_filter
+# A helper class for scheduling setup-related tasks on devices.
+class _TestSetupRunner(test_runner.TestRunner):
+ def SetUp(self):
+ pass
+
+ def TearDown(self):
+ pass
+
+ def DeviceSteps(self):
+ """ Steps to be run for device. Should be implemented in subclasses.
+
+ Returns:
+ A value that will be put into 'setup_result' field of corresponding
+ test result.
+ """
+ raise NotImplementedError()
+
+ def RunTest(self, _test):
+ result = base_test_result.BaseTestResult(
+ 'dummy', base_test_result.ResultType.PASS)
+
+ result.setup_result = self.DeviceSteps()
+ results = base_test_result.TestRunResults()
+ results.AddResult(result)
+ return results, None
+
+
+def _InstallPackage(test_options, test_package, devices):
+ def TestInstallerRunnerFactory(device, _shard_index):
+ class TestInstallerRunner(_TestSetupRunner):
+ def DeviceSteps(self):
+ self.test_package.Install(self.device)
+ return TestInstallerRunner(test_options, device, test_package)
+
+ test_dispatcher.RunTests(['setup'], TestInstallerRunnerFactory, devices,
jbudorick 2014/07/02 15:57:06 I still think that using test_dispatcher as a way
+ shard=False)
+
+
def _GetTests(test_options, test_package, devices):
"""Get a list of tests.
@@ -231,22 +269,16 @@ def _GetTests(test_options, test_package, devices):
A list of all the tests in the test suite.
"""
def TestListerRunnerFactory(device, _shard_index):
- class TestListerRunner(test_runner.TestRunner):
- def RunTest(self, _test):
- result = base_test_result.BaseTestResult(
- 'gtest_list_tests', base_test_result.ResultType.PASS)
- self.test_package.Install(self.device)
- result.test_list = self.test_package.GetAllTests(self.device)
- results = base_test_result.TestRunResults()
- results.AddResult(result)
- return results, None
+ class TestListerRunner(_TestSetupRunner):
+ def DeviceSteps(self):
+ return self.test_package.GetAllTests(self.device)
return TestListerRunner(test_options, device, test_package)
results, _no_retry = test_dispatcher.RunTests(
- ['gtest_list_tests'], TestListerRunnerFactory, devices)
+ ['setup'], TestListerRunnerFactory, devices)
tests = []
for r in results.GetAll():
- tests.extend(r.test_list)
+ tests.extend(r.setup_result)
return tests
@@ -324,6 +356,7 @@ def Setup(test_options, devices):
_GenerateDepsDirUsingIsolate(test_options.suite_name,
test_options.isolate_file_path)
+ _InstallPackage(test_options, test_package, devices)
tests = _GetTests(test_options, test_package, devices)
# Constructs a new TestRunner with the current options.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698