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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5
6 from pylib.base import base_test_result
7 from pylib.base import test_run
8 from pylib.base import test_collection
9
10
11 class LocalDeviceTestRun(test_run.TestRun):
12
13 #override
14 def RunTests(self):
15 tests = self._GetTests()
16
17 def run_tests_on_device(dev, tests):
18 r = base_test_result.TestRunResults()
19 for test in tests:
20 result = self._RunTest(dev, test)
21 if isinstance(result, base_test_result.BaseTestResult):
22 r.AddResult(result)
23 elif isinstance(result, list):
24 r.AddResults(result)
25 else:
26 raise Exception('Unexpected result type: %s' % type(result).__name__)
27 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
28 tests.test_completed()
29 return r
30
31 tries = 0
32 results = base_test_result.TestRunResults()
33 while tries < self._env.max_tries and tests:
34 if self._ShouldShard():
35 tests = test_collection.TestCollection(self._CreateShards(tests))
36 try_results = self._env.parallel_devices.pMap(
37 run_tests_on_device, tests).pGet(None)
38 fail_results = []
39 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
40 for r in tr.GetAll():
41 if r.GetType() in (base_test_result.ResultType.PASS,
42 base_test_result.ResultType.SKIP):
43 results.AddResult(r)
44 else:
45 fail_results.append(r)
46 tests = [f.GetName() for f in fail_results]
47 tries += 1
48
49 if fail_results:
50 results.AddTestResults(fail_results)
51 return results
52
53 def _CreateShards(self, tests):
54 raise NotImplementedError
55
56 def _GetTests(self):
57 raise NotImplementedError
58
59 def _RunTest(self, device, test):
60 raise NotImplementedError
61
62 def _ShouldShard(self):
63 raise NotImplementedError
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698