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

Side by Side Diff: build/android/pylib/base/base_test_result.py

Issue 18770008: [Android] Redesigns the sharder to allow replicated vs distributed tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Re-adds -f short form to gtest_filter switch Created 7 years, 5 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
« no previous file with comments | « no previous file | build/android/pylib/base/shard.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 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 """Module containing base test results classes.""" 5 """Module containing base test results classes."""
6 6
7 class ResultType(object): 7 class ResultType(object):
8 """Class enumerating test types.""" 8 """Class enumerating test types."""
9 PASS = 'PASS' 9 PASS = 'PASS'
10 FAIL = 'FAIL' 10 FAIL = 'FAIL'
11 CRASH = 'CRASH' 11 CRASH = 'CRASH'
12 TIMEOUT = 'TIMEOUT' 12 TIMEOUT = 'TIMEOUT'
13 UNKNOWN = 'UNKNOWN' 13 UNKNOWN = 'UNKNOWN'
14 14
15 @staticmethod 15 @staticmethod
16 def GetTypes(): 16 def GetTypes():
17 """Get a list of all test types.""" 17 """Get a list of all test types."""
18 return [ResultType.PASS, ResultType.FAIL, ResultType.CRASH, 18 return [ResultType.PASS, ResultType.FAIL, ResultType.CRASH,
19 ResultType.TIMEOUT, ResultType.UNKNOWN] 19 ResultType.TIMEOUT, ResultType.UNKNOWN]
20 20
21 21
22 class BaseTestResult(object): 22 class BaseTestResult(object):
23 """Base class for a single test result.""" 23 """Base class for a single test result."""
24 24
25 def __init__(self, name, test_type, log=''): 25 def __init__(self, name, test_type, tag='', log=''):
26 """Construct a BaseTestResult. 26 """Construct a BaseTestResult.
27 27
28 Args: 28 Args:
29 name: Name of the test which defines uniqueness. 29 name: Name of the test which defines uniqueness.
30 test_type: Type of the test result as defined in ResultType. 30 test_type: Type of the test result as defined in ResultType.
31 log: An optional string listing any errors. 31 log: An optional string listing any errors.
32 """ 32 """
33 assert name 33 assert name
34 assert test_type in ResultType.GetTypes() 34 assert test_type in ResultType.GetTypes()
35 self._name = name 35 self._name = name
36 self._test_type = test_type 36 self._test_type = test_type
37 self._tag = tag
37 self._log = log 38 self._log = log
38 39
39 def __str__(self): 40 def __str__(self):
40 return self._name 41 return self.GetTaggedName()
41 42
42 def __repr__(self): 43 def __repr__(self):
43 return self._name 44 return self.GetTaggedName()
44 45
45 def __cmp__(self, other): 46 def __cmp__(self, other):
46 # pylint: disable=W0212 47 # pylint: disable=W0212
47 return cmp(self._name, other._name) 48 return cmp(self.GetTaggedName(), other.GetTaggedName())
48 49
49 def __hash__(self): 50 def __hash__(self):
50 return hash(self._name) 51 return hash(self.GetTaggedName())
52
53 def GetTaggedName(self):
54 """Get the test name with tag."""
55 if self._tag:
56 return '%s_%s' % (self._tag, self._name)
57 else:
58 return self._name
51 59
52 def GetName(self): 60 def GetName(self):
53 """Get the test name.""" 61 """Get the test name."""
54 return self._name 62 return self._name
55 63
56 def GetType(self): 64 def GetType(self):
57 """Get the test result type.""" 65 """Get the test result type."""
58 return self._test_type 66 return self._test_type
59 67
68 def GetTag(self):
69 """Get the test tag."""
70 return self._tag
71
60 def GetLog(self): 72 def GetLog(self):
61 """Get the test log.""" 73 """Get the test log."""
62 return self._log 74 return self._log
63 75
76 def SetTag(self, tag):
77 """Set the test tag."""
78 self._tag = tag
79
64 80
65 class TestRunResults(object): 81 class TestRunResults(object):
66 """Set of results for a test run.""" 82 """Set of results for a test run."""
67 83
68 def __init__(self): 84 def __init__(self):
69 self._results = set() 85 self._results = set()
70 86
71 def GetLogs(self): 87 def GetLogs(self):
72 """Get the string representation of all test logs.""" 88 """Get the string representation of all test logs."""
73 s = [] 89 s = []
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 """Get the set of all unknown test results.""" 175 """Get the set of all unknown test results."""
160 return self._GetType(ResultType.UNKNOWN) 176 return self._GetType(ResultType.UNKNOWN)
161 177
162 def GetNotPass(self): 178 def GetNotPass(self):
163 """Get the set of all non-passed test results.""" 179 """Get the set of all non-passed test results."""
164 return self.GetAll() - self.GetPass() 180 return self.GetAll() - self.GetPass()
165 181
166 def DidRunPass(self): 182 def DidRunPass(self):
167 """Return whether the test run was successful.""" 183 """Return whether the test run was successful."""
168 return not self.GetNotPass() 184 return not self.GetNotPass()
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/base/shard.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698