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

Unified Diff: build/android/pylib/local/device/local_device_test_run.py

Issue 788753002: [Android] Implement gtest and local in platform mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years 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
Index: build/android/pylib/local/device/local_device_test_run.py
diff --git a/build/android/pylib/local/device/local_device_test_run.py b/build/android/pylib/local/device/local_device_test_run.py
new file mode 100644
index 0000000000000000000000000000000000000000..242f89ccbcc76a2f99cf53bf6e1c5a87a7b3baad
--- /dev/null
+++ b/build/android/pylib/local/device/local_device_test_run.py
@@ -0,0 +1,63 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+from pylib.base import base_test_result
+from pylib.base import test_run
+from pylib.base import test_collection
+
+
+class LocalDeviceTestRun(test_run.TestRun):
+
+ #override
+ def RunTests(self):
+ tests = self._GetTests()
+
+ def run_tests_on_device(dev, tests):
+ r = base_test_result.TestRunResults()
+ for test in tests:
+ result = self._RunTest(dev, test)
+ if isinstance(result, base_test_result.BaseTestResult):
+ r.AddResult(result)
+ elif isinstance(result, list):
+ r.AddResults(result)
+ else:
+ raise Exception('Unexpected result type: %s' % type(result).__name__)
+ if isinstance(tests, test_collection.TestCollection):
klundberg 2014/12/09 02:30:47 Should this really be called for each test in test
jbudorick 2014/12/09 15:46:52 Yep, we have to tell the TestCollection each time
+ tests.test_completed()
+ return r
+
+ tries = 0
+ results = base_test_result.TestRunResults()
+ while tries < self._env.max_tries and tests:
+ if self._ShouldShard():
+ tests = test_collection.TestCollection(self._CreateShards(tests))
+ try_results = self._env.parallel_devices.pMap(
+ run_tests_on_device, tests).pGet(None)
+ fail_results = []
+ for tr in try_results:
klundberg 2014/12/09 02:30:47 I know why you are using tr but I personally prefe
jbudorick 2014/12/09 15:46:51 expanded: tr -> try_result r -> result
+ for r in tr.GetAll():
+ if r.GetType() in (base_test_result.ResultType.PASS,
+ base_test_result.ResultType.SKIP):
+ results.AddResult(r)
+ else:
+ fail_results.append(r)
+ tests = [f.GetName() for f in fail_results]
+ tries += 1
+
+ if fail_results:
+ results.AddTestResults(fail_results)
+ return results
+
+ def _CreateShards(self, tests):
+ raise NotImplementedError
+
+ def _GetTests(self):
+ raise NotImplementedError
+
+ def _RunTest(self, device, test):
+ raise NotImplementedError
+
+ def _ShouldShard(self):
+ raise NotImplementedError

Powered by Google App Engine
This is Rietveld 408576698